预期数量,布尔值

时间:2019-04-28 19:41:59

标签: dynamic lua scoping

运行此代码时,我收到一条错误消息,如下所示:

Runtime Error:
AI.lua:7: bad argument #2 to 'getlocal' (number      
expected, got boolean)

该如何解决?我需要布尔值。

Anything = not nil
Nothing = not Anything
Everything = Anything and not Nothing
Overtaking = Anything and Nothing
God = Everything and Overtaking
Divinity = God and not not God
Better = debug.getlocal(1, Divinity)
x = ""
repeat
   i = 32
   repeat
      i = i + 1
      a = string.char(i)
      if Better == true then
          x = x .. a
      else x = x
      end
   until (i == 126)
until (x == x .. "")
print (x)

1 个答案:

答案 0 :(得分:0)

首先,getlocal需要一个整数作为第二个参数,并且您要传递布尔值,因此它对您不起作用。其次,getlocal返回在一定范围内声明的局部变量,因此这实际上取决于您在此处尝试执行的操作。我在您的代码中看不到任何本地人,因此使用getlocal不会到任何地方。

看看getlocal usage