Ancores
Active Member
- Joined
- Jan 17, 2010
- Messages
- 538
- Reaction score
- 28
I have a table like this:
If [1], [4] and [7] has the same value I want to add +1 to variable something
and if [1], [4], [7] and [10] has the same value I want to add +1 to variable something again
and if [1], [4], [7], [10] and [13] has the same value I want to add +1 to variable something again.
The only way I can come up with to do this is:
But I need a way to do this in the same if/for or whatever, I guess this is simple but I just can't lol.
Something like:
Idk
Code:
{
1000, 5000, 3000, 1000, 4000, -- The numbers are different everytime the script runs.
5000, 1000, 3000, 5000, 1000,
5000, 5000, 1000, 4000, 2000
}
If [1], [4] and [7] has the same value I want to add +1 to variable something
and if [1], [4], [7] and [10] has the same value I want to add +1 to variable something again
and if [1], [4], [7], [10] and [13] has the same value I want to add +1 to variable something again.
The only way I can come up with to do this is:
Code:
if(table[1] == table[4] and table[1] == table[7]) then
something = something+1
end
if(table[1] == table[4] and table[1] == table[7] and table[1] == table[10]) then
something = something+1
end
if...
Something like:
Code:
for i = 1, 5 do
if(...) then
something = something + 1
end
end
Idk
Last edited: