RegisterConsoleCommandHandler

The RegisterConsoleCommandHandler function executes the provided Lua function whenever the supplied custom command is entered into the UE console.

Parameters

#TypeInformation
1stringThe name of the custom command
2functionThe callback to execute when the custom command is entered into the UE console

Callback Parameters

#TypeInformation
1stringThe name of the custom command
2tableTable containing all parameters
3FOutputDeviceThe output device to write to

Callback Return Value

#TypeInformation
1boolWhether to prevent other handlers from handling this command

Example

RegisterConsoleCommandHandler("CommandExample", function(FullCommand, Parameters, OutputDevice)
    print("Custom command callback for 'CommandExample' command executed.\n")
    print(string.format("Full command: %s\n", FullCommand))
    print(string.format("Number of parameters: %i\n", #Parameters))
    
    for ParameterNumber, Parameter in pairs(Parameters) do
        print(string.format("Parameter #%i -> '%s'\n", ParameterNumber, Parameter))
    end

    return true
end)

-- Entered into console: CommandExample 1 2 3
-- Output
--[[
Custom command callback for 'CommandExample' command executed.
Full command: CommandExample 1 2 3
Number of parameters: 3
Parameter #1 -> '1'
Parameter #2 -> '2'
Parameter #3 -> '3'
Parameter #0 -> 'CommandExample'
--]]