Garry's Mod Wiki

Tool

A list of functions available inside a Sandbox Toolgun tool.

You can find the hooks and members here.

Methods

boolean Tool:Allowed()
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.
table Tool:BuildConVarList()
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.
Tool:CheckObjects()
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.
Tool:ClearObjects()
Clears all objects previously set with Tool:SetObject.
Tool Tool:Create()
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
Tool:CreateConVars()
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.
string Tool:GetClientInfo( string name )
Attempts to grab a clientside tool ConVar.
number Tool:GetClientNumber( string name, number default = 0 )
Attempts to grab a clientside tool ConVar.
Entity Tool:GetEnt( number id )
Retrieves an Entity previously stored using Tool:SetObject.
string Tool:GetHelpText()
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.
string Tool:GetMode()
Returns the name of the current tool mode.
Vector Tool:GetNormal( number id )
Retrieves an normal vector previously stored using Tool:SetObject.
number Tool:GetOperation()
Returns the current operation of the tool set by Tool:SetOperation.
Entity Tool:GetOwner()
Returns the owner of this tool.
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.
number Tool:GetStage()
Returns the current stage of the tool set by Tool:SetStage.
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.
number Tool:NumObjects()
Returns the amount of stored objects ( Entitys ) the tool has. Are TOOLs limited to 4 entities?
Tool:ReleaseGhostEntity()
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.
Tool:StartGhostEntity( Entity ent )
Initializes the ghost entity based on the supplied entity.
Tool:UpdateData()
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.
Tool:UpdateGhostEntity()
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.

Page Links


Special Pages


Wikis

?

Render Time: 31ms

Session 0
DB GetPage 4
Generate Html 3
SaveChanges 8
Render Body 0
Render Sidebar 14