So I have this table, and I want to change all the 0's to 1's, How would I go about this?
colors = {
{"Gray",0},
{"Cyan",0},
{"Brown",0},
{"Green",0},
{"Pink",0},
{"Peach",0},
{"Blue",0},
{"Purple",0},
{"Red",0},
{"Yellow",0},
}
So I have this table, and I want to change all the 0's to 1's, How would I go about this?
colors = {
{"Gray",0},
{"Cyan",0},
{"Brown",0},
{"Green",0},
{"Pink",0},
{"Peach",0},
{"Blue",0},
{"Purple",0},
{"Red",0},
{"Yellow",0},
}
You can iterate through a table with a for loop.
Since your table contains tables, you will want to do:
for i,inTable in pairs(colors) do
inTable[2]=1
end
This discussion is preserved as it was. New answers, comments, and votes are closed.