Ir para o conteúdo principal
Version: latest - a1.172.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​

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)
Subscribe: functionSubscribes 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

DebugOptimal​

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
NameTypeDescrição
messagestringMessage to print
args...?anyOther arguments to format with the message using string.format Default nil

ErrorOptimal​

Logs a red error in the console with stack information

The message is formatted with the given arguments

Console.Error(message, args...?)
Parameters
NameTypeDescrição
messagestringMessage to print
args...?anyOther arguments to format with the message using string.format Default nil

LogOptimal​

Logs and formats a message in the console

The message is formatted with the given arguments

Console.Log(message, args...?)
Parameters
NameTypeDescrição
messagestringMessage to print
args...?anyOther arguments to format with the message using string.format Default nil
Examples (3)
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"

RegisterCommandOptimal​

Registers a new Console Command

Console.RegisterCommand(command, callback, description?, parameters?)
Parameters
NameTypeDescrição
commandstringThe command
callbackfunctionThe callback to be called when the command is inputted with this format
description?stringThe command description to display in the console Default
parameters?table of stringThe list of supported parameters to display in the console Default {}
Examples (1)
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" })

RunCommandModerate​

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

Console.RunCommand(command)
Parameters
NameTypeDescrição
commandstringThe command
Examples (1)
Running a Console Command
Console.RunCommand("hello")

SubscribeOptimal​

Subscribes to an Event

local ret = Console.Subscribe(event_name, callback)
Parameters
NameTypeDescrição
event_namestringEvent to subscribe to
callbackfunctionCallback to run on the event occurring
Returns
TypeDescrição
functionThe function callback

UnsubscribeOptimal​

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
NameTypeDescrição
event_namestringEvent to unsubscribe to
callback?functionOptional callback to specifically unsubscribe to Default nil

WarnOptimal​

Logs an orange warning in the console with stack information

The message is formatted with the given arguments

Console.Warn(message, args...?)
Parameters
NameTypeDescrição
messagestringMessage to print
args...?anyOther arguments to format with the message using string.format Default nil

🚀 Events​

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
NameTypeDescrição
textstringLog Message
typeLogTypeType of the log

PlayerSubmit​

Called when a console command is submitted

Console.Subscribe("PlayerSubmit", function(text)
-- PlayerSubmit was called
end)
Arguments
NameTypeDescrição
textstringText submitted
Examples (1)
Handles Console Inputs
Console.Subscribe("PlayerSubmit", function(text)
if (text == "some_text") then
Console.Log("Player submitted some_text!")
end
end)