Ir para o conteúdo principal
Version: latest - a1.148.0 ⚖️

🔤 Console

Exposes access to registering Console Commands and Logging messages.

🗿Static ClassClient & Server🧑‍💻API Source

🎒 Examples

(Console.Log) Basic
Console.Log("Hello, world!")
-- Outputs "Hello, world!"
(Console.Log) With formatting (string)
local player_name = "John"
Console.Log("Hello %s!", player_name)
-- Outputs "Hello John!"
(Console.Log) With formatting (integer)
local health = 50
local max_health = 100
Console.Log("Player health: %d/%d", health, max_health)
-- Outputs "Player health: 50/100"
(Console.RegisterCommand) Registering to a command that sends a message to everyone
Console.RegisterCommand("hello", function(text)
Console.Log("Sending a 'Hello %s' to everyone!", text)
Chat.BroadcastMessage("Hello " .. text)
end, "says a message to everyone", { "my_text" })
(Console.RunCommand) Running a Console Command
Console.RunCommand("hello")
(Console "PlayerSubmit" Event) Handles Console Inputs
Console.Subscribe("PlayerSubmit", function(text)
if (text == "some_text") then
Console.Log("Player submitted some_text!")
end
end)

🗿 Static Functions

ReturnsNameDescription
DebugLogs a debug message in the console, with formatted arguments. Outputted only when the current log level is Debug or Verbose
ErrorLogs a red error in the console with stack information
LogLogs and formats a message in the console
RegisterCommandRegisters a new Console Command
RunCommandRuns a Console Command programmatically (only scripting-registered commands can be triggered)
functionSubscribeSubscribes to an Event
UnsubscribeUnsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
WarnLogs an orange warning in the console with stack information

Optimal

Debug

Logs a debug message in the console, with formatted arguments. Outputted only when the current log level is Debug or Verbose
Console.Debug(message, args...?)

Parameters

TypeParameterDefaultDescription
stringmessage Required parameter Message to print
anyargs...?nil
Other arguments to format with the message using string.format

Optimal

Error

Logs a red error in the console with stack information, with formatted arguments
Console.Error(message, args...?)

Parameters

TypeParameterDefaultDescription
stringmessage Required parameter Message to print
anyargs...?nil
Other arguments to format with the message using string.format

Optimal

Log

Logs and formats a message in the console, with formatted arguments
Console.Log(message, args...?)

Parameters

TypeParameterDefaultDescription
stringmessage Required parameter Message to print
anyargs...?nil
Other arguments to format with the message using string.format
Console.Log Examples
Basic
Console.Log("Hello, world!")
-- Outputs "Hello, world!"
With formatting (string)
local player_name = "John"
Console.Log("Hello %s!", player_name)
-- Outputs "Hello John!"
With formatting (integer)
local health = 50
local max_health = 100
Console.Log("Player health: %d/%d", health, max_health)
-- Outputs "Player health: 50/100"

Optimal

RegisterCommand

Registers a new Console Command
Console.RegisterCommand(command, callback, description?, parameters?)

Parameters

TypeParameterDefaultDescription
stringcommand Required parameter The command
functioncallback Required parameter The callback to be called when the command is inputted with this format
stringdescription?
The command description to display in the console
table of stringparameters?{}
The list of supported parameters to display in the console
Console.RegisterCommand Examples
Registering to a command that sends a message to everyone
Console.RegisterCommand("hello", function(text)
Console.Log("Sending a 'Hello %s' to everyone!", text)
Chat.BroadcastMessage("Hello " .. text)
end, "says a message to everyone", { "my_text" })

Moderate

RunCommand

Runs a Console Command programmatically (only scripting-registered commands can be triggered)
Console.RunCommand(command)

Parameters

TypeParameterDefaultDescription
stringcommand Required parameter The command
Console.RunCommand Examples
Running a Console Command
Console.RunCommand("hello")

Optimal

Subscribe

Subscribes to an Event
local ret = Console.Subscribe(event_name, callback)

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter Event to subscribe to
functioncallback Required parameter Callback to run on the event occurring

Returns

TypeDescription
functionThe function callback

Optimal

Unsubscribe

Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
Console.Unsubscribe(event_name, callback?)

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter Event to unsubscribe to
functioncallback?nil
Optional callback to specifically unsubscribe to

Optimal

Warn

Logs an orange warning in the console with stack information, with formatted arguments
Console.Warn(message, args...?)

Parameters

TypeParameterDefaultDescription
stringmessage Required parameter Message to print
anyargs...?nil
Other arguments to format with the message using string.format

🚀 Events

NameDescription
LogEntryCalled when a log is received
PlayerSubmitCalled when a console command is submitted

LogEntry

Called when a log is received
Console.Subscribe("LogEntry", function(text, type)
-- LogEntry was called
end)

Arguments

TypeArgumentDescription
stringtextLog Message
LogTypetypeType of the log

PlayerSubmit

Called when a console command is submitted
Console.Subscribe("PlayerSubmit", function(text)
-- PlayerSubmit was called
end)

Arguments

TypeArgumentDescription
stringtextText submitted
Console "PlayerSubmit" Event Examples
Handles Console Inputs
Console.Subscribe("PlayerSubmit", function(text)
if (text == "some_text") then
Console.Log("Player submitted some_text!")
end
end)