RegisterConsoleCommandGlobalHandler

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

Unlike RegisterConsoleCommandHandler, this global variant runs the callback for all contexts.

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
1stringFull command string
2tableTable with parameters (without the command name)
3FOutputDeviceThe output device to write to

Callback Return Value

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

Example

RegisterConsoleCommandGlobalHandler("CommandExample", function(FullCommand, Parameters, OutputDevice)
    print("RegisterConsoleCommandGlobalHandler:\n")

    print(string.format("Command: %s\n", FullCommand))
    print(string.format("Number of parameters: %i\n", #Parameters))
    
    for ParameterNumber, Parameter in ipairs(Parameters) do
        print(string.format("Parameter #%i -> '%s'\n", ParameterNumber, Parameter))
    end

    OutputDevice:Log("Write something to game console")

    return false
end)

-- Entered into console: CommandExample param1 "param 2" 3
-- Output
--[[
RegisterConsoleCommandGlobalHandler:
Command: CommandExample param1 "param 2" 3
Number of parameters: 3
Parameter #1 -> 'param1'
Parameter #2 -> 'param 2'
Parameter #3 -> '3'
--]]