Search code examples
androidlualua-tableluajava

Lua global table different in different files


I use the AndroLua port of LuaJava on Android and when I define a global table in file A and try to access it from file B some entries are missing:

file A:

Game = {
  name = "name"
}

function Game:init()
  self.score = 7
  self.player = "othername"
  require('B')
end

The Game:init() method is called from java.

file B:

require('A')

print(Game.score) -- nil
print(Game.player) -- 'name'

Why does file B not print '7' and 'othername'?


Solution

  • There is a syntax error in file A: A function should end with end, not }.

    You should have got an error message like this:

    error loading module 'A' from file './A.lua':
        ./A.lua:9: unexpected symbol near '}'