a = 10
b = 1
c = 5
If people voted and these were the results how would I figure out whats the highest?
a = 10
b = 1
c = 5
If people voted and these were the results how would I figure out whats the highest?
This is a more complex way, but would be able to work with multiple numbers, or variables. Which could all be set into a table. I know you didn't ask for this exactly but this might help fix the problem or help in the future.
local a = 10
local b = 1
local c = 5
local Dictionary = {"a", "b", "c", "d", "e", "f", "g", "h", "I", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
function Compare(Args)
local HighestNumber = nil --The highestnumber out of the table
local Letter = nil --The letter that goes with the highestnumber like A,B,C, etc.
for I,v in pairs(Args) do --Grabs all of the variables from the table, and cycles until it's read through eah variable.
if HighestNumber == nil then
HighestNumber = v
Letter = Dictionary[I]
else
if v > HighestNumber then
HighestNumber = v
Letter = Dictionary[I]
end
end
end
end
Compare({a, b, c}) --{a,b,c} --A table, it stores the numbers from the variables a,b, and c.
a = 10
b = 1
c = 5
if a > b and a > c then
print("a wins")
else
if b > a and b > c then
print("b wins")
else
if c > a and c > b then
print(" c wins")
end
wait()
end
wait()
end
Change the values around (a,b,c) to test out the script!
Good idea, but recheck your code. :P There are 'if then end' statements in the each 'if then end' statements; consider changing to 'elseif' for the two inside the first.
Also, post an explanation, not just code.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Sorry about the capital I's, most of them are suppose to be lower cased. But my computer automatically capitalizeses I's.
thx anyways
Np, hope you can understand that in some ways. Thought it would just be cool to show you how you can expand on that type of stuff.