codeAPI Reference
s&box ToolAction: Toolgun input binding
ToolAction Enums and ToolActionEntry API Reference
ToolInput, InputMode, and ToolActionEntry are used by the toolgun system to bind actions to input slots with configurable input sampling modes.
Type Signatures
CSHARP
public enum ToolInput
{
Primary,
Secondary,
Reload
}
public enum InputMode
{
Pressed,
Down
}
public sealed record ToolActionEntry(
ToolInput Input,
Func<string> Name,
Action Callback,
InputMode Mode = InputMode.Pressed
)
{
public string InputAction => Input switch
{
ToolInput.Primary => "attack1",
ToolInput.Secondary => "attack2",
ToolInput.Reload => "reload",
_ => null
};
}ToolInput Values
InputMode Values
- Pressed - Fires once when the button is first pressed (edge detection)
- Down - Fires every frame while the button is held (continuous)
ToolActionEntry Properties
- ToolInput Input - The input slot this action is bound to
- Func<string> Name - Dynamic display-name lambda for the action
- Action Callback - The callback to invoke when input fires
- InputMode Mode - How the input is sampled (default: Pressed)
- string InputAction - The engine input action string for this ToolInput
Usage
CSHARP
// Register a tool action that fires on primary press
var action = new ToolActionEntry(
ToolInput.Primary,
() => "My Action",
() => DoSomething(),
InputMode.Pressed
);
// Register a continuous action on secondary
var continuousAction = new ToolActionEntry(
ToolInput.Secondary,
() => "Continuous",
() => DoSomethingContinuous(),
InputMode.Down
);Notes
- Used by toolgun modes to register actions for the toolgun UI
- InputAction maps ToolInput to engine input action strings
- Pressed is for single-trigger actions (shoot, place)
- Down is for continuous actions (hold to charge, continuous fire)
Was this helpful?