Summary

Functions

Adds a mode to the area tool and merges the mode's convars into the tool's convars.

Functions

Add(list, data)

shared plugins/areas/plugin/sh_plugin.lua:53

Adds a mode to the area tool and merges the mode's convars into the tool's convars. Meant to be called from the AddAreaToolModes hook as mode_list:Add(mode).

function PLUGIN:AddAreaToolModes(mode_list)
  local mode = {}
  mode.title = 'Text Area'
  mode.area_type = 'textarea'
  mode.ClientConVar = { height = '512' }

  function mode:OnLeftClick(tool, trace)
    tool.area = tool.area or Areas.create('my_area', 512, { type = self.area_type })
    tool.area:add_vertex(trace.HitPos)

    return true
  end

  mode_list:Add(mode)
end

Parameters

  • list Map the Area.tool_modes table the mode is appended to
  • data Map mode definition: title, area_type, ClientConVar and the optional functions OnLeftClick(mode, tool, trace), OnRightClick(mode, tool, trace), OnReload(mode, tool, trace) and BuildCPanel(mode, panel). The default OnReload removes the area of that type under the trace

Defined in