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
8 days ago
1.0 - 2.0
3.14K

Changelog

Version: 0.5.4
Date: 2024-10-27

  Adds:
    - converter runtime-api.json to runtime-api.lua compatible for gvv (thanks Thaui).
    - LuaObject add: LuaPrototypes and LuaHelpers.
  Fixes:
    - fixed "is_valid_sprite_path". using helpers instead of game now.
Version: 0.5.3
Date: 2024-10-25

  Fixes:
    - Fixed crash when "on_runtime_mod_setting_changed" occurs. (changing gvv mod settings while playing game.)
Version: 0.5.2
Date: 2024-10-22

  Changes:
    - Changed version string to Factorio 2.0
    - Changed a few reserved words in source code to make compatible to 2.0
Version: 0.5.1
Date: 2022-03-16

  Changes:
    - Tried "global" diagnostic in trouble shooter to do not iterate inside metatables and recursive tables.
Version: 0.5.0
Date: 2022-03-16

  Changes:
    - Tried afforts to avoid metatable related errors.
    - "global" table bringer will now work like "_G" table bringer, not simple copy anymore. This may be worse for performance, but you can explore function and metatable statements inside of global table.
    - "global" diagnostic in trouble shooter will not iterate inside metatable.
Version: 0.4.5
Date: 2021-07-29

  Changes:
    - In remote "_G" function, table inspecting method for Factorio stock objects(LuaBlabla...) is slightly changed to avoid(hopefully) blinded invoking metamethod of tables with custom metatable.
Version: 0.4.4
Date: 2021-07-29

  Changes:
    - For remote "_G" function, errors are handled per element instead of denying to load entire _G tree.
    - Removed error message shortening in tree view. Now full error message is shown like as variable value.
Version: 0.4.3
Date: 2021-02-13

  Changes:
    - Added limiter for tree loading to prevent to render too much entries in single folder at once.

  Info:
    - Default limit is 500 entries per folder, and this can be changed by following command,
      /c __gvv__ global.meta_data.treelimit=1234
      If number of entries to load in single folder at once exceeds the limit, an alternative entry to click is generated for continue to load manually.
Version: 0.4.2
Date: 2021-02-08

  Fixes:
    - Fixed some types of branch line in tree view look broken in Factorio 1.1.19.
Version: 0.4.1
Date: 2020-11-25

  Changes:
    - * Changes from 0.3.6, 0.4.0.
    - Added refresh button at tree tabs.
    - Added refresh hotkey (default : SHIFT+X) usable at tracking variables tab and tree tabs.

  Fixes:
    - * Fixes from 0.3.6, 0.4.0.
    - Fixed error shown when trying to edit tracking interval number.
    - Cleared misinputs of flow/frame guistyle properties.
Version: 0.4.0
Date: 2020-11-24

  Changes:
    - Quick adaptation to Factorio 1.1
    - Removed dodging codes for some bugs/crashes fixed in Factorio 1.1
Version: 0.3.8
Date: 2020-11-25

  Changes:
    - Added refresh button at tree tabs.
    - Added refresh hotkey (default : SHIFT+X) usable at tracking variables tab and tree tabs.

  Fixes:
    - Cleared misinputs of flow/frame guistyle properties.
Version: 0.3.6
Date: 2020-10-04

  Fixes:
    - Fixed a normal table having a child with a key "object_name" isn't shown properly in tree GUI.
    - Blacklisted LuaCustomTable, LuaMapSettings, LuaDifficultySettings and LuaFlowStatistics at remote.call("__<mod_name>__gvv","_G").
      To prove their existence in "_G" and to prevent game crash. (Still cannot be opened by tree GUI.)
      Reason why is that they are not supported by remote.call().
Version: 0.3.5
Date: 2020-10-04

  Changes:
    - In tree GUI, if an entry is a prototype object and it has a sprite then, a sprite icon will be shown at left of key name.
      Supported prototypes are listed here.
      https://lua-api.factorio.com/1.0.0/Concepts.html#SpritePath
Version: 0.3.4
Date: 2020-09-28

  Changes:
    - "global" tab now shows rest of "_G" or "global" contents even if one of both have error.

  Fixes:
    - Fixed remote.call("__<mod_name>__gvv","_G") pops stack overflow error when trying to bring recursive table from remote _G.
Version: 0.3.3
Date: 2020-09-23

  Changes:
    - Added search UI for tree viewers.
    - Added "show/hide nil"
Version: 0.3.2
Date: 2020-09-14

  Changes:
    - Entries in "Variable trace" now can be reordered, imported and exported.
Version: 0.3.1
Date: 2020-09-12

  Changes:
    - Entries in "Variable trace" now can be edited.
    - "_G" scope of gvv mod now have "util" of "__core__/lualib/util.lua". gvv itself doesn't use it but you can use it for custom codes.
    - Changed default examples of "Variable trace" entries.
Version: 0.3.0
Date: 2020-09-11

  Changes:
    - "_G" global table of Lua is now shown at "global" tab.
    - Added a new LuaRemote interface, remote.call("__<mod_name>__gvv","_G")
Version: 0.2.3
Date: 2020-09-10

  Fixes:
    - Fixed mistakes in "/gdump-json" command which was not following js object notation strictly.
    - Missing LuaLazyLoadedValue in remote "diag" is now recognized as errorful entry in global.
Version: 0.2.2
Date: 2020-09-10

  Changes:
    - When trying to track already non-existing LuaObject reference found in "global" tab, pops error message immediately instead of opening it at "property" tab.

  Fixes:
    - Fixed a few missing "local" notations in source code.
Version: 0.2.1
Date: 2020-09-08

  Changes:
    - Removed /g-c commands because I found built-in /c commands also can access mod via /c __<mod_name>__ <code>.
    - Now mods are also can be made to be temporarily accessible by gvv without changing "control.lua".
    - Added mod setting option to completely turn "on_tick" event of gvv off/on. (can be used in playtime)

  Info:
    - Though /g-c is gone, but remote.call("__<mod_name>__gvv", "c", <script>, ...) still remains. Usable in Lua snippet of /editor or elsewhere.
    - To turn off on_tick in server console, use /sc __gvv__ settings.global["gvv-mod_enable-on-tick"]={value= false }
Version: 0.2.0
Date: 2020-09-07

  Changes:
    - Command /g-c and same kinds now have ability to run Lua code in global scope of other mod (not only level, gvv).
    - Added a new remote function, remote.call("__<mod_name>__gvv", "c", <script>, ...) . /g-c is using this for executing code in other mods.
    - Added new examples of using /g-c in "Usage Tips".
    - Added a new example of using new remote function for Lua snippet of /editor in "Usage Tips".
    - Little bit changed stringify process of some LuaObjects not supporting .help() function, to make it do not make trouble when Factorio is updated to have .help() function for them later(or never...).


  Info:
    - To run Lua code in a specific mod except level or gvv, for example, mod name is my Mod-1 then type :
    - /g-c --[[my Mod-1]] game.print(script.mod_name)
    - New remote function is remote.call("__my Mod-1__gvv","c", script, arg1, arg2, arg3, ...) and script(string type) is for loadstring(script) function.
    - arg1, arg2, arg3, ... will become local arg = {arg1, arg2, arg3, ...} inside of script.
Version: 0.1.2
Date: 2020-09-06

  Changes:
    - Added new commands : /g-c, /g-sc, /g-command, /g-silent-command, which are almost equivalents to built-in commands such as /c, /sc but execution scope is global of gvv, not level(map).
    - Now return values in tracking list can be copied.
    - Added "Usage Tips" menu in "Helper" tab.
    - Added path in tooltip of object list at left side in "property" tab.

  Info:
    - In new "Usage Tips", I wrote tips I forgot to write before, and introduced a trick to use global table space for memo.

  Fixes:
    - Fixed unable to right-click in "Variable trace" if there is nothing.
    - Fixed loading map saved when gvv is 0.1.0 causing global CRC check fail.
    - Little fix in remote diagnose code. Changed few report name strings that is not changing behavior of previous versions to make it show key names properly in some cases.
    - Fixed "global" tree gui to show functions(if they are placed in global of gvv) regardless of "method view" setting of "property" or "LuaObject". functions in global cannot be saved, and cannot be brought by LuaRemote. Only functions in gvv global can be shown because there is no need to "bring" for gvv itself.
Version: 0.1.1
Date: 2020-09-05

  Changes:
    - Remote code(Which I recommended to paste in remote mod/map's control.lua) is changed to shorter code referring the code inside of gvv mod. Then it doesn't need to update your remote code by hand anymore when gvv provide updated remote code. Thanks for giving me this idea.
    - Added guide text that suggesting how to handle remote code at "control.lua" help page. Shortly explaining a way to put it anywhere.
    - Made 2nd tab (global) to reload available mod list when everytime changed from other tab, instead of reopening whole main GUI to refresh.
    - Aligned text in buttons in Troubleshooting menu to center.

  Info:
    - Remote code will be a function when called by require. Mods or map can freely decide whether to run the code to register gvv interface now or later or not. "now" is just having "()" brackets after require(...) function, like "require(...)()". For "later", you need to assign it to a local value first like "local something = require(...)".
    - Remote code from 0.1.0 will work fine for now. No changes to it, but it is recommended to change it to code of 0.1.1. Then no further by hand.
    - Still you can get raw remote code from "Helper" - "Console command - 1" page. Just delete leading "/c ".

  Fixes:
    - Fixed changelog.txt to be parsed correctly.
    - Fixed error message shown when /gdump <modname> failed due to demand mod is not supporting remote interface is shown as the message of map.
    - Fixed /gmods not showing an interface registered mod in list if global table of that have errorful entry in its global table.
Version: 0.1.0
Date: 2020-09-05

  Info:
    - First release to public.