Passer au contenu principal
Version: bleeding-edge 🩸

🔤 Console

Exposes access to registering Console Commands and Logging messages.

🗿Static Class
This is a Static Class. Access it's methods directly with .. It's not possible to spawn new instances.
💂Authority
This static class can be accessed on both 🟧 Client and 🟦 Server side.
🧑‍💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

🎒 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("Console", function()
if (text == "some_text") then
Console.Log("Player submitted some_text!")
end
end)

🗿 Static Functions

ReturnsNameDescription
ErrorLogs a red error in the console
LogLogs and formats a message in the console
RegisterCommandRegisters a new Console Command
RunCommandRuns a Console Command programmatically
WarnLogs an orange warning in the console

Error

Logs a red error in the console, with formatted arguments

Console.Error(message, args...?)
TypeParameterDefaultDescription
stringmessage Required parameter Message to print
anyargs...?nilOther arguments to format with the message using string.format

Log

Logs and formats a message in the console, with formatted arguments

Console.Log(message, args...?)
TypeParameterDefaultDescription
stringmessage Required parameter Message to print
anyargs...?nilOther 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"

RegisterCommand

Registers a new Console Command

Console.RegisterCommand(command, callback, description, parameters)
TypeParameterDefaultDescription
stringcommand Required parameter The command
functioncallback Required parameter The callback to be called when the command is inputted with this format
stringdescription Required parameter The command description to display in the console
table of stringparameters Required parameter 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" })

RunCommand

Runs a Console Command programmatically

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

Warn

Logs an orange warning in the console, with formatted arguments

Console.Warn(message, args...?)
TypeParameterDefaultDescription
stringmessage Required parameter Message to print
anyargs...?nilOther arguments to format with the message using string.format

🚀 Events

NameDescription
CloseWhen player closes the Console
LogEntryCalled when a log is received
OpenWhen player opens the Console
PlayerSubmitCalled when a console command is submitted

Close

When player closes the Console
Console.Subscribe("Close", function()
-- Close was called
end)

LogEntry

Called when a log is received
Console.Subscribe("LogEntry", function(text, type)
-- LogEntry was called
end)
TypeArgumentDescription
stringtextLog Message
LogTypetypeType of the log

Open

When player opens the Console
Console.Subscribe("Open", function()
-- Open was called
end)

PlayerSubmit

Called when a console command is submitted
Console.Subscribe("PlayerSubmit", function(text)
-- PlayerSubmit was called
end)
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)