Lua 全局 table 不同文件不同

Lua global table different in different files

我在 Android 上使用 LuaJava 的 AndroLua 端口,当我在文件 A 中定义全局 table 并尝试从文件 B 访问它时,一些条目丢失了:

文件A:

Game = {
  name = "name"
}

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

Game:init() 方法从 java 调用。

文件 B:

require('A')

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

为什么文件 B 不打印 '7' 和 'othername'?

文件 A 中存在语法错误:函数应以 end 结尾,而不是 }

您应该收到这样的错误消息:

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

问题出在文件 B 中的 require('A')