cw.tool class
Defines the cw.tool library, which lets the framework and plugins define tools for the tool gun.
A tool made with cw.tool:New has the interface of a sandbox TOOL (console variables, selected objects, ghost
entities, stages) and is registered under its UniqueID. Setting leftClickCMD, rightClickCMD or reloadCMD
makes that action run a Catwork command.
Summary
Methods
Methods
Returns every registered tool, indexed by unique ID.
The gamemode adds them to the tool gun and the spawn menu.
Returns
- Map<Tool> The tools indexed by unique ID
Creates a new tool for the tool gun.
Set UniqueID, Name, Category and ClientConVar on it, define its callbacks and register
it with CLASS_TABLE:Register. Setting leftClickCMD, rightClickCMD or reloadCMD makes the
action run that Catwork command instead of a callback.
local TOOL = cw.tool:New()
TOOL.UniqueID = 'static'
TOOL.Name = '#tool.static.name'
function TOOL:LeftClick(trace)
if CLIENT then return true end
plugin.Call('PlayerMakeStatic', self:GetOwner(), true)
return true
end
TOOL:Register()
Returns
- Tool The new tool
Registers a tool so it is added to the tool gun.
Sets the tool's mode to its UniqueID and creates its console variables. For each of
leftClickCMD, rightClickCMD and reloadCMD that is set, replaces the matching callback with
one that runs the command for the owner; leftClickFire, rightClickFire and reloadFire
(default true) are returned on the client. Tools without a UniqueID are not registered and
an error is printed.
Parameters
- tool Tool The tool