如何用Lua制作2D阵列?我需要动态创建它.
local tbl = { { } }
Run Code Online (Sandbox Code Playgroud)
像上面的东西,但我可以指定多少项.在我的情况下,他们将是相同的金额.我基本上想要像tbl [3] [5]那样访问它.
谢谢
The*_*Saw 24
-- Create a 3 x 5 array
grid = {}
for i = 1, 3 do
grid[i] = {}
for j = 1, 5 do
grid[i][j] = 0 -- Fill the values here
end
end
Run Code Online (Sandbox Code Playgroud)