Summary

Methods

Allowed()shared
Returns whether the tool may be used.
Returns the tool's client console variables with their full names, for presets in the control panel.
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.
Create()shared
Creates a new tool object with the default fields.
Creates the tool's console variables.
Deploy()shared
Called when the tool is selected; removes the ghost entity.
DrawHUD()client
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 the physics bone of a selected object.
Returns the value of one of the owner's client console variables for this tool.
Returns the value of one of the owner's client console variables for this tool as a number.
GetEnt(i)shared
Returns the entity of a selected object.
Returns the help text shown on the tool gun HUD.
Returns the position of a selected object as stored, local to its entity unless it is the world.
GetMode()shared
Returns the tool's mode, its unique ID.
Returns the world-space hit normal of a selected object.
Returns the tool's current operation.
Returns the player using the tool.
Returns the physics object of a selected object.
GetPos(i)shared
Returns the world position of a selected object.
Returns the value of one of the tool's console variables in this realm.
Returns the tool's stage.
GetSWEP()shared
Returns the tool gun weapon table using this tool.
Returns the tool gun weapon entity.
Holster()shared
Called when the tool is put away; removes the ghost entity.
Init()shared
Called when the tool is initialized; does nothing by default.
Called when the owner left clicks with the tool; does nothing by default.
Creates a translucent ghost entity to preview a placement.
Returns how many objects are selected.
Registers the tool.
Removes the tool's ghost entities.
Reload()shared
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.
Selects an object for the tool, storing its position and normal relative to the entity.
Sets the tool's current operation, networked through the tool gun.
Sets the tool's stage, networked through the tool gun.
Creates a ghost entity with the model, position and angles of an entity.
Think()shared
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.

Methods

Returns whether the tool may be used.

Returns

  • Boolean Always true on the client; the toolmode_allow_<mode> variable on the server

CLASS_TABLE:BuildConVarList()

shared gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:48

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.

CLASS_TABLE:FreezeMovement()

client gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:398

Returns whether the owner's view should be frozen while using the tool.

Returns

  • Boolean false by default

Returns the physics bone of a selected object.

Parameters

  • i Number Index of the object

Returns

  • Number The bone index

CLASS_TABLE:GetClientInfo(property)

shared gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:60

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:69

Returns 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 0 Value 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 NULL when 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; 0 when 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

CLASS_TABLE:GetServerInfo(property)

shared gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:40

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; 0 when 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:308

Creates 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

CLASS_TABLE:ReleaseGhostEntity()

shared gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:350

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:262

Selects 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

CLASS_TABLE:StartGhostEntity(ent)

shared gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:342

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.

CLASS_TABLE:UpdateGhostEntity()

shared gamemodes/catwork/gamemode/core/libraries/sh_tool.lua:374

Moves the ghost entity to where the first selected object would be placed on the owner's aim.

Defined in