[英]Lua script wont accept args
我試圖使全息投影儀正常工作,但遇到以下錯誤:
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
但它不起作用。 我已經檢查了拼寫。 全息圖也已正確初始化。
該錯誤意味着某些函數(剩下的錯誤是什么?)本應獲得三個參數的函數卻只有兩個。
鑒於該代碼段,我可以看到的唯一適用於hologram.get
函數。
快速瀏覽文檔(感謝Google),實際上似乎需要三個參數 。
get(x:number, y:number, z:number):number
Returns the value at the specified position.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.