Base class of the tool gun tools that Flux loads. It reimplements the tool object of Sandbox, so that a tool file written for Sandbox works as it is: the same fields (Mode, ClientConVar, Objects and so on), the same callbacks to override (LeftClick, RightClick, Reload, Think, Deploy, Holster, DrawHUD) and the same helpers for console variables, selected objects and ghost entities. What Flux adds is that the name and the description of a tool come from the tool.<id>.name and tool.<id>.desc language phrases. Tool files are loaded from the tools folders by the Flux.Tool library, which creates the object and passes it to the file as TOOL.

Summary

Methods

Converts the tool to a string for printing.
Allowed()shared
Checks whether the tool is allowed to be used on the server.
Builds a list of the client console variables of the tool with their defaults.
Clears the selected objects if any of their entities has been removed.
Clears the selected objects, removes the ghost entity and resets the stage and operation.
Creates the console variables of the tool: the ones listed in ClientConVar on the client, and 'toolmode_allow_<mode>' on the server.
Deploy()shared
Called when the tool gun is deployed.
DrawHUD()client
Gives the tool an opportunity to draw to the HUD.
Draws the scrolling name of the tool on the screen of the tool gun.
Determines whether the view angles of the owner should be frozen while using the tool.
Returns the physics bone number of the numbered hit (for ragdolls).
Returns the value of a client console variable of the tool for its owner.
Returns the value of a client console variable of the tool for its owner as a number.
GetEnt(i)shared
Returns the entity of the numbered hit.
Returns the translated description of the tool.
Returns the position of the numbered hit local to the entity that was hit.
GetMode()shared
Returns the mode (ID) of the tool.
Returns the surface normal of the numbered hit in world space.
Returns the current operation of the tool.
Returns the player who holds the tool gun.
Returns the physics object of the numbered hit.
GetPos(i)shared
Returns the world position of the numbered hit.
Returns the value of a console variable of the tool.
Returns the current stage of the tool.
GetSWEP()shared
Returns the tool gun that this tool belongs to.
Returns the weapon entity of the tool gun.
Holster()shared
Called when the tool gun is holstered.
init()shared
Creates a new tool with the default values of its fields.
Init()shared
Called when the tool gun initializes the tool.
Called when the owner presses primary attack.
Creates a translucent ghost prop that previews the result of the tool, replacing the previous one.
Returns the number of selected objects.
Removes the ghost entity of the tool.
Reload()shared
Called when the owner presses reload.
Called when the owner presses secondary attack.
Stores a selected object.
Sets the operation of the tool and networks it to the clients.
Sets the stage of the tool and networks it to the clients.
Creates a ghost entity that copies the model, position and angles of the specified entity.
Think()shared
Called every tick while the tool is active.
Sets the stage of the tool to the number of selected objects.
Moves the ghost entity to where the first selected object would end up if the tool was applied to the spot the owner is aiming at.

Methods

Converts the tool to a string for printing.

Returns

  • String

Checks whether the tool is allowed to be used on the server. Always true on the client.

Returns

  • Boolean

Tool:BuildConVarList()

shared packages/flow/lib/classes/sh_tool.lua:367

Builds a list of the client console variables of the tool with their defaults.

Returns

  • Map default values by full variable name

Tool:CheckObjects()

shared packages/flow/lib/classes/sh_tool.lua:440

Clears the selected objects if any of their entities has been removed.

Tool:ClearObjects()

shared packages/flow/lib/classes/sh_tool.lua:189

Clears the selected objects, removes the ghost entity and resets the stage and operation.

Tool:CreateConVars()

shared packages/flow/lib/classes/sh_tool.lua:343

Creates the console variables of the tool: the ones listed in ClientConVar on the client, and 'toolmode_allow_<mode>' on the server.

Called when the tool gun is deployed. Removes the ghost entity by default.

Gives the tool an opportunity to draw to the HUD. Does nothing by default.

Tool:DrawToolScreen(_w, _h)

shared packages/flow/lib/classes/sh_tool.lua:20

Draws the scrolling name of the tool on the screen of the tool gun.

Parameters

  • _w Number width of the screen
  • _h Number height of the screen

Tool:FreezeMovement()

client packages/flow/lib/classes/sh_tool.lua:318

Determines whether the view angles of the owner should be frozen while using the tool. Returns false by default.

Returns

  • Boolean

Returns the physics bone number of the numbered hit (for ragdolls).

Parameters

  • i Number index of the selected object

Returns

  • Number

Tool:GetClientInfo(property)

shared packages/flow/lib/classes/sh_tool.lua:379

Returns the value of a client console variable of the tool for its owner.

Parameters

  • property String name of the variable without the tool mode prefix

Returns

  • String

Tool:GetClientNumber(property, default)

shared packages/flow/lib/classes/sh_tool.lua:387

Returns the value of a client console variable of the tool for its owner as a number.

Parameters

  • property String name of the variable without the tool mode prefix
  • default Number optional, defaults to 0 returned if the variable is not a number

Returns

  • Number

Returns the entity of the numbered hit.

Parameters

  • i Number index of the selected object

Returns

  • Entity the entity
  • NULL if there is no object with this index

Tool:GetHelpText()

shared packages/flow/lib/classes/sh_tool.lua:47

Returns the translated description of the tool.

Returns

  • String

Tool:GetLocalPos(i)

shared packages/flow/lib/classes/sh_tool.lua:225

Returns the position of the numbered hit local to the entity that was hit.

Parameters

  • i Number index of the selected object

Returns

  • Vector

Returns the mode (ID) of the tool.

Returns

  • String

Returns the surface normal of the numbered hit in world space.

Parameters

  • i Number index of the selected object

Returns

  • Vector

Tool:GetOperation()

shared packages/flow/lib/classes/sh_tool.lua:184

Returns the current operation of the tool.

Returns

  • Number

Returns the player who holds the tool gun.

Returns

  • Player

Returns the physics object of the numbered hit.

Parameters

  • i Number index of the selected object

Returns

  • PhysObj

Returns the world position of the numbered hit.

Parameters

  • i Number index of the selected object

Returns

  • Vector

Tool:GetServerInfo(property)

shared packages/flow/lib/classes/sh_tool.lua:360

Returns the value of a console variable of the tool.

Parameters

  • property String name of the variable without the tool mode prefix

Returns

  • String

Returns the current stage of the tool.

Returns

  • Number

Returns the tool gun that this tool belongs to.

Returns

  • Weapon

Returns the weapon entity of the tool gun.

Returns

  • Weapon

Called when the tool gun is holstered. Removes the ghost entity by default.

Creates a new tool with the default values of its fields.

Called when the tool gun initializes the tool. Does nothing by default.

Called when the owner presses primary attack. Returns false by default.

Returns

  • Boolean false, overrides should return true if the tool has done something

Tool:MakeGhostEntity(model, pos, angle)

shared packages/flow/lib/classes/sh_tool.lua:56

Creates a translucent ghost prop that previews the result of the tool, replacing the previous one. Ragdolls and effects cannot be ghosts.

Parameters

  • model String path to the model
  • pos Vector
  • angle Angle

Returns the number of selected objects. On the client this is the stage of the tool.

Returns

  • Number

Tool:ReleaseGhostEntity()

shared packages/flow/lib/classes/sh_tool.lua:104

Removes the ghost entity of the tool.

Called when the owner presses reload. Clears the selected objects by default.

Called when the owner presses secondary attack. Returns false by default.

Returns

  • Boolean false, overrides should return true if the tool has done something

Tool:SetObject(i, ent, pos, phys, bone, norm)

shared packages/flow/lib/classes/sh_tool.lua:278

Stores a selected object. The position and the normal are converted to be local to the physics object (or the entity), so that they stay valid when it moves.

Parameters

  • i Number index to store the object under
  • ent Entity the entity that was hit
  • pos Vector world position of the hit
  • phys PhysObj physics object that was hit
  • bone Number physics bone number
  • norm Vector surface normal of the hit

Tool:SetOperation(i)

shared packages/flow/lib/classes/sh_tool.lua:176

Sets the operation of the tool and networks it to the clients. Does nothing on the client.

Parameters

  • i Number

Sets the stage of the tool and networks it to the clients. Does nothing on the client.

Parameters

  • i Number

Tool:StartGhostEntity(ent)

shared packages/flow/lib/classes/sh_tool.lua:96

Creates a ghost entity that copies the model, position and angles of the specified entity.

Parameters

  • ent Entity

Called every tick while the tool is active. Removes the ghost entity by default.

Sets the stage of the tool to the number of selected objects.

Tool:UpdateGhostEntity()

shared packages/flow/lib/classes/sh_tool.lua:131

Moves the ghost entity to where the first selected object would end up if the tool was applied to the spot the owner is aiming at.

Defined in