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
12 days ago
1.0 - 2.0
3.24K

g UPS

3 years ago

Hi! I have a simple table built like this:

global.entities[base.unit_number] = { base = entity, pole = entity}

The only problem is, I've got a saved game from a user of one of my mods that put almost 10k entries into this table. While browsing the global table to check if my migration script worked correctly, I accidentally opened this table in gvv. The computer became almost unusable, with sound, mouse, and keyboard freezing for a while at times while Factorio used up almost all of the 16GB RAM I have, and already started swapping. That's when I decided to kill the process (which wasn't easy to do because of the much delayed response to my keyboard input).

This probably isn't a bug because I should have known better than trying to open such a long table. I did know better -- it just was an accidental click that got me there. Would a safeguard against such events be possible? Something like if table_size > x, don't try to show the table immediately but give a warning first? :-)

3 years ago

Thanks for feedback. I'll look for a way to solve such situation... This may take a time.

3 years ago

Hi! I have a simple table built like this:

global.entities[base.unit_number] = { base = entity, pole = entity}

The only problem is, I've got a saved game from a user of one of my mods that put almost 10k entries into this table. While browsing the global table to check if my migration script worked correctly, I accidentally opened this table in gvv. The computer became almost unusable, with sound, mouse, and keyboard freezing for a while at times while Factorio used up almost all of the 16GB RAM I have, and already started swapping. That's when I decided to kill the process (which wasn't easy to do because of the much delayed response to my keyboard input).

This probably isn't a bug because I should have known better than trying to open such a long table. I did know better -- it just was an accidental click that got me there. Would a safeguard against such events be possible? Something like if table_size > x, don't try to show the table immediately but give a warning first? :-)

Alternative method is log(serpent.block(the table you are interested in)). Font display is very slow, even in ue4 or unity, this is also a problem.

3 years ago

I'll look for a way to solve such situation... This may take a time.

Thanks, and never mind if it takes a while or two. :-)

Alternative method is log(serpent.block(the table you are interested in)). Font display is very slow, even in ue4 or unity, this is also a problem.

I already make ample use of serpent.block, my mods have heavy logging everywhere (without spamming players' logs). But there are cases where I want to see changes on the fly. This proved to be invaluable when I was debugging the code for growing trees in Bio Industries, where trees are moved to another table at the end of each stage. So whenever I noticed any change in the table size, I could pause the game and switch over to the log with a fair chance of finding the relevant output in the heap of log spam.

But of course you're right: The GUI is updated every few ticks, I guess it has to be rebuilt if any tables are added or removed, and with lots of data in nested tables, this must be expensive.

3 years ago

I already make ample use of serpent.block, my mods have heavy logging everywhere (without spamming players' logs). But there are cases where I want to see changes on the fly. This proved to be invaluable when I was debugging the code for growing trees in Bio Industries, where trees are moved to another table at the end of each stage. So whenever I noticed any change in the table size, I could pause the game and switch over to the log with a fair chance of finding the relevant output in the heap of log spam.

But of course you're right: The GUI is updated every few ticks, I guess it has to be rebuilt if any tables are added or removed, and with lots of data in nested tables, this must be expensive.

I have no idea the concrete issue you encountered. But according to what I saw when I tried to read some lua code in the community of Factorio, I found most of the people programmed in a very primitive way. It even made me thought lua has no infrastructure to do oop. I don't know what style your code is in. I think it's useful to rewrite the oop style before any debugging. If you would like to try what I mentioned, you could directly check my new scenario.

New response