I have created a class to to create a basic dominoes set, and like to distribute the pieces among the quantity of players. My “dominoes.lua” file have two functions
[code]function shuffle(t)
– Shuffles the pieces
end
function dominoesSet()
– code to create the set, an table with 28 pieces
– Every index of my table holds some piece information, like an image, a value, etc.
– For example: “set[1] = {value1 = 1, value2 = 5, …}”
return set;
end
[/code]
After this, in my “main.lua”, I’ve created an object to get the set:
local dominoes = require("dominoes");
local set = dominoes.dominoesSet();
Everything is fine at this point, but i want to make other tables to separate the pieces for the players, I created a function, in main, to get 7 pieces from the set and copy them to a new table:
function players(n, set)
if ( players == 1) then
p1 = {};
for i = 1, 7 do
p1[i] = set[i];
end
-- in main
local p1 = players(1, set);
All seems to be simple, but I get error in the code when I try to print any value of this new table. For example:
print (set[1].value) -- works
print (p1[1].value) -- get an error
What I’m missing? If I delete the second print line, It’s all ok…
Thanks!!! [import]uid: 54349 topic_id: 13026 reply_id: 313026[/import]