1
嗨,我是一個相當新的Lua程序員,我試圖將參數傳遞給多維數組,但我一直得到一個零值錯誤。Lua傳遞多維數組
我有一個多維數組:
local transform = {
forward = {
distance = 1,
swing = robot.swing,
move = robot.forward
},
left = {
distance = 1,
swing = robot.swing,
move = robot.forward
},
down = {
distance = 1,
swing = robot.swingDown,
move = robot.down
}
}
,我試圖通過陣列的部分,像這樣:
function testFunc(transform, direction)
print(transform.direction.distance)
end
myFunc(transform, forward)
這些都是表,而不是陣列。好的,在Lua中,數組是表格,但它們不是類似數組的表格。它們只是鍵值表。 –