Debugger
Attaches a Debugger to the Matter instance, allowing you to create debug widgets in your systems.
local debugger = Matter.Debugger.new(Plasma)
local widgets = debugger:getWidgets()
local loop = Matter.Loop.new(world, widgets) -- pass the widgets to your systems
debugger:autoInitialize(loop)
if IS_CLIENT then
debugger:show()
end
When the debugger is not open, the widgets do not render.
Properties
authorize
Create this property in Debugger to specify a function that will be called to determine if a player should be allowed to connect to the server-side debugger. In Studio, this property is ignored.
If not specified, the default behavior is to allow anyone in Studio and disallow everyone in a live game.
debugger.authorize = function(player)
if player:GetRankInGroup(372) > 250 then -- etc
return true
end
end
findInstanceFromEntity
Create this property in Debugger to specify a function that will be called to determine what Instance is associated with an entity. This is used for the in-world highlight in the World inspector.
If not specified, the in-world highlight will not work.
debugger.findInstanceFromEntity = function(id)
if not world:contains(id) then
return
end
local model = world:get(id, components.Model)
return model and model.model or nil
end
componentRefreshFrequency
Debugger.componentRefreshFrequency:
number
Create this property in Debugger to specify the frequency (in seconds) that the unique component list will refresh.
If not specified, it will use a default time of 3 seconds.
debugger.componentRefreshFrequency = 1
loopParameterNames
Debugger.loopParameterNames:
{
string
}
Create this property in Debugger to specify the names of the parameters to your Loop constructor. This is used to display a more accurate name in the debugger.
If not specified, the default behavior is to label Worlds as "World" and tables as "table", followed by its index.
debugger.loopParameterNames = {"World", "State", "Widgets"}
Functions
new
Creates a new Debugger.
You need to depend on Plasma in your project and pass a handle to it here.
show
This item only works when running on the client. ClientDebugger:
show
(
) →
(
)
Shows the debugger panel
hide
This item only works when running on the client. ClientDebugger:
hide
(
) →
(
)
Hides the debugger panel
toggle
This item only works when running on the client. ClientDebugger:
toggle
(
) →
(
)
Toggles visibility of the debugger panel
autoInitialize
Adds middleware to your Loop to set up the debugger every frame.
tip
The debugger must also be shown on a client with Debugger:show or Debugger:toggle to be used.
caution
Debugger:autoInitialize should be called before Loop:begin to function as expected.
If you also want to use Plasma for more than just the debugger, you can opt to not call this function and instead do what it does yourself.
replaceSystem
Alert the debugger when a system is hot reloaded.
switchToServerView
This item only works when running on the client. ClientDebugger:
switchToServerView
(
) →
(
)
Switch the client to server view. This starts the server debugger if it isn't already started.
switchToClientView
Debugger:
switchToClientView
(
) →
(
)
Switch the client to client view. This stops the server debugger if there are no other players connected.
update
Debugger:
update
(
) →
(
)
This should be called to draw the debugger UI.
This is automatically set up when you call Debugger:autoInitialize, so you don't need to call this yourself unless
you didn't call autoInitialize
.
getWidgets
Debugger:
getWidgets
(
) →
{
[
string
]
:
Widget
}
Returns a handle to the debug widgets you can pass to your systems.
All plasma widgets are available under this namespace.
-- ...
local debugger = Debugger.new(Plasma)
local loop = Loop.new(world, state, debugger:getWidgets())
When the Debugger is not open, calls to widgets are no-ops.
If the widget normally returns a handle (e.g., button returns a table with clicked
), it returns a static dummy
handle that always returns a default value:
checkbox
clicked
: falsechecked
: false
button
clicked
: false
slider
: 0