A list of functions available inside a Sandbox Toolgun tool.
You can find the hooks and members here.
Checks whether the tool is allowed on the server. This will always return true clientside and will not be affected by SANDBOX:CanTool. This function uses TOOL.AllowedCVar which is a ConVar object pointing to **toolmode_allow_*toolname*** convar.
Builds a list of all ConVars set via the ClientConVar variable on the Structures/TOOL and their default values. This is used for the preset system.
This is used internally - although you're able to use it you probably shouldn't. This is called automatically for most toolgun actions so you shouldn't need to use it. Checks all added objects to see if they're still valid, if not, clears the list of objects.
Clears all objects previously set with Tool:SetObject.
This is used internally - although you're able to use it you probably shouldn't. This is called automatically for all tools. Initializes the tool object
This is used internally - although you're able to use it you probably shouldn't. This is called automatically for all tools. Creates clientside ConVars based on the ClientConVar table specified in the tool structure. Also creates the 'toolmode_allow_X' ConVar.
number Tool:GetBone( number id )
Retrieves a physics bone number previously stored using Tool:SetObject.
number Tool:GetClientNumber( string name, number default = 0 )
Attempts to grab a clientside tool ConVar.
Returns a language key based on this tool's name and the current stage it is on.
Vector Tool:GetLocalPos( number id )
Retrieves an local vector previously stored using Tool:SetObject. See also Tool:GetPos.
Vector Tool:GetNormal( number id )
Retrieves an normal vector previously stored using Tool:SetObject.
PhysObj Tool:GetPhys( number id )
Retrieves an PhysObj previously stored using Tool:SetObject. See also Tool:GetEnt.
Vector Tool:GetPos( number id )
Retrieves an vector previously stored using Tool:SetObject. See also Tool:GetLocalPos.
string Tool:GetServerInfo( string name )
Attempts to grab a serverside tool ConVar. This will not do anything on client, despite the function being defined shared.
Tool:MakeGhostEntity( string model, Vector pos, Angle angle )
Initializes the ghost entity with the given model. Removes any old ghost entity if called multiple times. The ghost is a regular prop_physics entity in singleplayer games, and a clientside prop in multiplayer games.
Returns the amount of stored objects ( Entitys ) the tool has. Are TOOLs limited to 4 entities?
Removes any ghost entity created for this tool.
Tool:SetObject( number id, Entity ent, Vector pos, PhysObj phys, number bone, Vector normal )
Stores an Entity for later use in the tool. The stored values can be retrieved by Tool:GetEnt, Tool:GetPos, Tool:GetLocalPos, Tool:GetPhys, Tool:GetBone and Tool:GetNormal
Tool:SetOperation( number operation )
Sets the current operation of the tool. Does nothing clientside. See also Tool:SetStage. Operations and stages work as follows: Operation 1 Stage 1 Stage 2 Stage 3 Operation 2 Stage 1 Stage 2 Stage ...
Tool:SetStage( number stage )
Sets the current stage of the tool. Does nothing clientside. See also Tool:SetOperation.
This is used internally - although you're able to use it you probably shouldn't. Called on deploy automatically Sets the tool's stage to how many stored objects the tool has.
Updates the position and orientation of the ghost entity based on where the toolgun owner is looking along with data from object with id 1 set by Tool:SetObject. This should be called in the tool's TOOL:Think hook. This command is only used for tools that move props, such as easy weld, axis and motor. If you want to update a ghost like the thruster tool does it for example, check its source code.