Code: Select all
grid = {}
for y = 1, 14 do
grid[y] = {}
for x = 1, 19 do
grid[y][x] = {flower = false}
end
end
local possibleFlowerPositions = {}
for y = 1, 14 do
for x = 1, 19 do
table.insert(possibleFlowerPositions, {x = x, y = y})
end
end
for flowerIndex = 1, 40 do
local position = table.remove(possibleFlowerPositions, love.math.random(#possibleFlowerPositions))
grid[position.y][position.x].flower = true
end
Second, I've searched in "Programming in Lua, Forth Edition" book and did some google but had never seen something like this before, so, If you were at my position what would you do to deal with this problem otherwise asking someone directly?