So I have a dictionary that contains two teams, and their total kill count as the values. How would I determine if all the keys found in the dictionary all contain the same value?
I need to know this so I can script a stalemate.
So I have a dictionary that contains two teams, and their total kill count as the values. How would I determine if all the keys found in the dictionary all contain the same value?
I need to know this so I can script a stalemate.
You can keep track of the integers by creating an array. For 3+ teams, you can do:
local KillCounts = {};
for i, v in pairs(Dictionary) do
local ispresent= false;
for i = 1,# KillCounts do
if (KillCounts[i] == v) then
ispresent= true -- Killcount is present in table
break; -- Stop the loop
end
end
if (ispresent) then -- If the same killcount is present
-- do something
else
table.inset(v) -- Add the kill count into the table
end
end
That is scaleable for multiple teams, if you only have two teams. You could just compare both dictionary values dirrectly.
if (Dictionary[Team1] == Dictionary[Team2]) then
-- Identical kill count, do something
end
Thanks!
Also, the line where you add the kill count into the table should be
table.insert(KillCount, v)
not
table.inset(v).
Haha yes my bad, darn typos!