Hullo!
So there is this game where there are tiles, I need to get a specific subset of them, shuffle them, and lay them out on the table.
Each tile CAN be unique, or MAY be in a stack of tiles. I take the each tile stack, shuffle, and draw one, OR I just take the unique tile. I do this for a few different tiles, to make a table.
However, when I iterate through the table Lua is grouping any tiles that might come from the same stack into one 'object'.
So instead of getting TileIce1, TileIce2, TileFire, I get TileIceStack, TileFire.
How to I stop the table from grouping the like objects together?
Code:
function setTiles()
print("getting tiles")
tiles = { getTile(iceId), getTile(iceId), getTile(fireId)}
--this is shuffle function that does work on the table
tiles = shuffle(tiles)
TILE_WIDTH = 2.7
-- the size of the tiles table comes back as 2, not 3
for i = 1, #tiles do
xpos = i * TILE_WIDTH
tiles[i].setPosition(Vector((xpos-2.7) , 0 , 4.6))
end
end
function getTile(id)
tileStack = getObjectFromGUID(id)
if pcall(tileStack.shuffle()) then
t = tileStack.takeObject()
else
-- tile is single
t = tileStack
end
t.setPosition(Vector(0,0,0))
return t
end
Thanks in advance