Lua API global Variable Viewer (gvv)

by Ritn

This is a debugging tool. This mod adds commands /gvv and others and a hotkey(Ctrl+Shift+V) to allow you to check _G and global table of map or each mods. Only admins can use command if it is multiplay game. You have to input some code for temporary accessibility or have to edit "control.lua" of other mod or map to access global table of the mod or map. See "Helper" tab for instructions.

Utilities
a month ago
1.0 - 2.1
4.16K

b [0.5.21 fixes] Wrong argument error

1 year, 4 months ago
(updated 1 year, 4 months ago)

Hi! With gvv 0.5.15, I just noticed this error message in my chat:

__gvv__/modules/tree.lua:262: bad argument #1 of 2 to 'pairs' (table expected, got nil)

I'm not sure how to reproduce that because I don't know what I did when the message appeared (didn't notice it immediately as the error was handled graciously and caused just this message). The bug can be fixed by providing a empty table to fall back on:

for k, obj in pairs(tbl or {}) do

But of course, it would be better to find out why tbl could be nil in the first place. :-)

1 year, 4 months ago

Hi, it doesn't seem like it's going to be too much of a problem right now. I'll keep it on my to-do list for when I have more time to mod.

1 year, 4 months ago

That's OK, thank you! :-)

a month ago

Hi, it finally got some time on my to-do list!

I found why tbl could be nil. When you open a folder (or click "Continue to load"), gvv doesn't reuse the data from the drawn tree: it fetches the data again and follows the stored path to that entry. If the entry was removed or replaced by the mod since the tree was last refreshed, the path leads to nil, and Tree.draw crashed on pairs(nil).

This is fixed in 0.5.21: the path is now checked before drawing. If the entry no longer exists, gvv shows a message and refreshes the tree instead of throwing an error. Tree.draw also ignores non-table input as a safety net.

While investigating, I also found and fixed a related bug: table or LuaObject keys inside sub-tables produced an "<ERROR>" key that could never be opened (it always led to nil too). Such keys are now shown as <table_1>, <table_2>, <LuaEntity_1>... and open normally.

Thanks again for the detailed report and the suggestion!

New response