Page 1 of 1

Accessing global values of the modg

Posted: Thu Jan 08, 2015 9:41 pm
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?

Re: Accessing global values of the modg

Posted: Fri Jan 09, 2015 9:00 am
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