cw.tool.Class object
Object table CLASS_TABLE in core/libraries/sh_tool.lua
Summary
Methods
Methods
Returns whether the tool may be used.
Returns
- Boolean Always
trueon the client; thetoolmode_allow_<mode>variable on the server
Returns the tool's client console variables with their full names, for presets in the control panel.
Returns
- Map Default values indexed by
<mode>_<name>
Clears the selected objects when any of them has been removed.
Clears the selected objects, removes the ghost entity and resets the stage and operation.
Creates a new tool object with the default fields.
Use cw.tool:New instead.
Returns
- Tool The new tool
Creates the tool's console variables.
On the client, creates a saved, user-info console variable <mode>_<name> for every entry of
ClientConVar. On the server, creates the toolmode_allow_<mode> variable checked by
CLASS_TABLE:Allowed.
Called when the tool is selected; removes the ghost entity.
Called to draw the tool's HUD; does nothing by default.
Returns whether the owner's view should be frozen while using the tool.
Returns
- Boolean
falseby default
Returns the physics bone of a selected object.
Parameters
- i Number Index of the object
Returns
- Number The bone index
Returns the value of one of the owner's client console variables for this tool.
Parameters
- property String Name of the variable, as a key of
ClientConVar
Returns
- String The value
CLASS_TABLE:GetClientNumber(property, default)
shared gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:69Returns the value of one of the owner's client console variables for this tool as a number.
Parameters
- property String Name of the variable, as a key of
ClientConVar - default Number optional, defaults to
0Value returned when the variable is not a number
Returns
- Number The value
Returns the entity of a selected object.
Parameters
- i Number Index of the object
Returns
- Entity The entity, or
NULLwhen no object has that index
Returns the help text shown on the tool gun HUD.
Returns
- String The tool's
HelpText, or the#tool.<mode>.<stage>language phrase
Returns the position of a selected object as stored, local to its entity unless it is the world.
Parameters
- i Number Index of the object
Returns
- Vector The stored position
Returns the tool's mode, its unique ID.
Returns
- String The mode
Returns the world-space hit normal of a selected object.
Parameters
- i Number Index of the object
Returns
- Vector The normal
Returns the tool's current operation.
Returns
- Number The operation;
0when not set
Returns the player using the tool.
Returns
- Player The owner of the tool gun
Returns the physics object of a selected object.
Parameters
- i Number Index of the object
Returns
- PhysObj The stored physics object, or the entity's own when none was stored
Returns the world position of a selected object.
The position is stored relative to the object's entity or physics object, so it follows the entity as it moves.
Parameters
- i Number Index of the object
Returns
- Vector The world position
Returns the value of one of the tool's console variables in this realm.
Parameters
- property String Name of the variable, without the
<mode>_prefix
Returns
- String The value, or
''when it does not exist
Returns the tool's stage.
Returns
- Number The stage;
0when not set
Returns the tool gun weapon table using this tool.
Returns
- Weapon The tool gun
Returns the tool gun weapon entity.
Returns
- Weapon The tool gun entity
Called when the tool is put away; removes the ghost entity.
Called when the tool is initialized; does nothing by default.
Called when the owner left clicks with the tool; does nothing by default.
Return true to fire the tool gun effect. Tools with leftClickCMD set get a replacement that
runs that command.
Returns
- Boolean Whether the click did something
CLASS_TABLE:MakeGhostEntity(model, pos, angle)
shared gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:308Creates a translucent ghost entity to preview a placement.
The ghost is a client prop in multiplayer and a server prop in singleplayer; the call does nothing in the other realm.
Parameters
- model String Model of the ghost
- pos Vector Position of the ghost
- angle Angle Angles of the ghost
Returns how many objects are selected.
Returns
- Number The number of objects; the stage on the client
Registers the tool.
See also
Removes the tool's ghost entities.
Called when the owner reloads with the tool; clears the selected objects by default.
Called when the owner right clicks with the tool; does nothing by default.
Return true to fire the tool gun effect. Tools with rightClickCMD set get a replacement that
runs that command.
Returns
- Boolean Whether the click did something
CLASS_TABLE:SetObject(i, ent, pos, phys, bone, norm)
shared gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:262Selects an object for the tool, storing its position and normal relative to the entity.
Usually called from LeftClick with the values of the trace.
self:SetObject(self:NumObjects() + 1, trace.Entity, trace.HitPos,
trace.Entity:GetPhysicsObjectNum(trace.PhysicsBone), trace.PhysicsBone, trace.HitNormal)
Parameters
- i Number Index of the object
- ent Entity The entity, or the world
- pos Vector The world position
- phys PhysObj The physics object
- bone Number The physics bone
- norm Vector The hit normal
Sets the tool's current operation, networked through the tool gun.
Does nothing on the client.
Parameters
- i Number The operation
Sets the tool's stage, networked through the tool gun.
Does nothing on the client.
Parameters
- i Number The stage
Creates a ghost entity with the model, position and angles of an entity.
Parameters
- ent Entity The entity to copy
Called every frame while the tool is held; removes the ghost entity by default.
Sets the tool's stage to the number of selected objects.
Moves the ghost entity to where the first selected object would be placed on the owner's aim.