util.input.execute
Client
Executes a registered console command as if it had been typed into the console
Syntax
local status = util.input.execute(
name,
args = {}
)Fires every handler registered under name, the same way console input does.
- Strings only —
argsvalues are converted withtostringinternally, so pass strings where possible to match what a real console handler receives. - Not for binding — this only reaches handlers set up with
util.input.register.
Key and mouse binds registered throughutil.input.bindlive in a separate registry entirely and won't fire from this call.
Parameters
| Type | Name | Description |
|---|---|---|
string | name | Command name to execute |
table | args | Array of arguments to pass through to the handler |
Returns
| Type | Name | Description |
|---|---|---|
bool | status | true if a handler for name exists and was invoked, false otherwise |
Examples
util.input.register("respawn", function(args)
core.engine.print("info", "Respawning player")
end)
util.input.execute("respawn")util.input.register("teleport", function(args)
core.engine.print("info", "Teleporting to", args[1], args[2], args[3])
end)
util.input.execute("teleport", {"10", "20", "30"})if not util.input.execute("debug_dump") then
core.engine.print("warn", "debug_dump is not registered")
endutil.input.register("set_speed", function(args)
core.engine.print("info", "New speed:", args[1])
end)
-- Numbers are converted to strings before the handler receives them
util.input.execute("set_speed", {15.5})