Hello
I am messing around with a game Match3Gems to help learn the fundamental of lua and corona. The screenshot will show this.
I am trying to to shuffle the table when the player presses the button, but I am having sum trouble doing this.
The code that fills the table is
[lua]
local gemsTable = {}
for i = 1, 8, 1 do
gemsTable[i] = {}
for j = 1, 8, 1 do
gemsTable[i][j] = newGem(i,j)
end
end
[/lua]
I came across this code online but cant get it working
[lua]
function table.shuffle(t)
math.randomseed(os.time())
assert(t, “table.shuffle() expected a table, got nil”)
local iterations = #t
local j
for i = iterations, 2, -1 do
j = math.random(i)
t[i], t[j] = t[j], t[i]
end
end
function shuffleGameButton(event)
for i = 1, 8, 1 do
gemsTable[i] = i
for j = 1, 8, 1 do
gemsTable[j] =j
end
end
[/lua]
Does anyone know what the best way to get this done
Thanking You
Alan Fletcher