Accessing global values of the modg

Place to get help with not working mods / modding interface.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Accessing global values of the modg

Post by Adil »

So, why a variable created like this:

Code: Select all

game.oninit(function()
     glob.bomber = 0
end)
is completely inaccessible through console and of what scope exactly it is then?
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Accessing global values of the modg

Post by Choumiko »

it is in _G.glob.bomber (i think)
The console might be it's own chunk, with only interfaces available? And every mod has it's own _G as you can't access the glob from another mod.
For quick console debugging im using sth like

Code: Select all

remote.addinterface("st",
  {
    printGlob = function(name)
      if name then
        serpent.dump(glob[name], true)
      else
        serpent.dump(glob, true)
      end
    end,
    printFile = function(var, name)
      local name = name or "log"
      if glob[var] then
        game.makefile(name, serpent.block(glob[var]))
      else
        game.makefile(name, serpent.block(glob))
      end
    end})
then /c remote.call("st", "printGlob") dumps your glob
Post Reply

Return to “Modding help”