0

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

档案一:

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'?

4

2 回答 2

0

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

于 2015-04-06T13:21:08.713 回答
0

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

您应该收到如下错误消息:

error loading module 'A' from file './A.lua':
    ./A.lua:9: unexpected symbol near '}'
于 2015-04-06T12:14:32.710 回答