我目前的代码是:
obj1 = object:new{x = math.random(1,92), y = math.random(1,92), roomx = 0, roomy = 0, symbol = "t", name = "Tree"}
obj2 = object:new{x = math.random(1,92), y = math.random(1,92), roomx = 0, roomy = 0, symbol = "t", name = "Tree"}
obj3 = object:new{x = math.random(1,92), y = math.random(1,92), roomx = 0, roomy = 0, symbol = "t", name = "Tree"}
等等。由于它们都是相同的东西,我希望能够生成一个变量,我可以将名称加一,然后使用 for 循环创建很多它们。有没有办法在 Lua 中做到这一点?谢谢!