Skip to main content

Debug

Debug is a global class that provides access to various debugging functions which are useful for testing and debugging your scripts.

warning

Some of these functions can have a notable impact on performance if used in frame or gametick-based functions

Functions

FunctionDescription
PrintWrites a message out to the script console.
WarnWrites a warning out to the script console.
ErrorWrites an error out to the script console.
WatchAdds a static value or a table to the watch panel in the script console.
ClearWatchStops watching a static value or table.

Debug:Print(message)

Writes a message out to the script console.

Parameters

ParameterTypeDescription
messagestringThe message to write out to the console.

Usage

script.lua
Debug:Print("Logging something")


Debug:Warn(message)

Writes a warning out to the script console.

Parameters

ParameterTypeDescription
messagestringThe warning message to write out to the console.

Usage

script.lua
Debug:Warn("Oh no, something happened")


Debug:Error(message)

Writes an error out to the script console.

Parameters

ParameterTypeDescription
messagestringThe error message to write out to the console.

Usage

script.lua
Debug:Error("Oh no, something very bad happened")


Debug:Watch(key, value)

Adds a static value or a table to the watch panel in the script console.

Parameters

ParameterTypeDescription
keystringThe key to show in the watch panel.
valuetableThe value or table to watch.

Usage

script.lua
MyTable = {}

Debug:Watch("My Table", MyTable)

TODO: Add watch table pic here



Debug:ClearWatch(key)

Stops watching a static value or table.

Parameters

ParameterTypeDescription
keystringThe key used when calling Debug:Watch.

Usage

script.lua
MyTable = {}

Debug:Watch("My Table", MyTable)

-- some time later...

Debug:ClearWatch("My Table")