Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop parameter names #58

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/debugger/debugger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ Debugger.__index = Debugger
```
]=]

--[=[
@prop loopParameterNames {string}
@within Debugger

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.

```lua
debugger.loopParameterNames = {"World", "State", "Widgets"}
```
]=]

--[=[
Creates a new Debugger.

Expand Down Expand Up @@ -149,6 +163,7 @@ function Debugger.new(plasma)
local self = setmetatable({
plasma = plasma,
loop = nil,
loopParameterNames = {},
enabled = false,
componentRefreshFrequency = 3,
_windowCount = 0,
Expand Down
5 changes: 4 additions & 1 deletion lib/debugger/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ local function ui(debugger, loop)
local selected = (#objectStack > 0 and object == objectStack[#objectStack].value)
or (debugger.debugWorld == object and worldViewOpen)

local name = debugger.loopParameterNames[index]
local defaultName = (if isWorld then "World" else "table") .. " " .. index

table.insert(items, {
text = (if isWorld then "World" else "table") .. " " .. index,
text = if name then name else defaultName,
icon = if isWorld then "🌐" else "{}",
object = object,
selected = selected,
Expand Down
Loading