Lua脚本不接受参数。

我试图让全息投影仪工作,但遇到了以下错误:

bad arguments #3 (number expected, got no value)

我的脚本是:

local component = require("component")
local hologram = component.hologram

function setVoxel(x, y, z, value)
  print(x)
  print(y)
  print(z)
  print(value)
  local current = hologram.get(x, z)
  local positiveMask = bit32.lshift(1, y - 1)
  if value then
    hologram.set(x, z, bit32.bor(current, positiveMask))
  else
    local negativeMask = bit32.bnot(positiveMask)
    hologram.set(x, z, bit32.band(current, negativeMask))
  end
end

local args = {...}
print(args[1])
print(args[2])
print(args[3])
print(args[4])
setVoxel(tonumber(args[1]), tonumber(args[2]), tonumber(args[3]), args[4])

我使用了:

holo-set 8 16 20 true

打印命令返回:

8
16
20
true

但它没有起作用。 我检查了拼写。 此外,全息图已正确初始化。

点赞
用户258523
用户258523

那个错误意味着某个函数(错误信息的剩余部分是什么?)本来希望得到三个参数,但实际只接收到两个。

根据那段代码片段中的内容,我看到可能与此相关的函数只有 hologram.get

根据快速查阅文档(感谢谷歌),事实上该函数的确需要 三个参数

get(x:number, y:number, z:number):number
返回指定位置处的值。
2014-08-07 15:15:25