1 | a = 10 |
2 | b = 1 |
3 | 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.
01 | local a = 10 |
02 | local b = 1 |
03 | local c = 5 |
04 |
05 | 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" } |
06 |
07 | function Compare(Args) |
08 | local HighestNumber = nil --The highestnumber out of the table |
09 | local Letter = nil --The letter that goes with the highestnumber like A,B,C, etc. |
10 | for I,v in pairs (Args) do --Grabs all of the variables from the table, and cycles until it's read through eah variable. |
11 | if HighestNumber = = nil then |
12 | HighestNumber = v |
13 | Letter = Dictionary [ I ] |
14 | else |
15 | if v > HighestNumber then |
01 | a = 10 |
02 | b = 1 |
03 | c = 5 |
04 | if a > b and a > c then |
05 | print ( "a wins" ) |
06 | else |
07 | if b > a and b > c then |
08 | print ( "b wins" ) |
09 | else |
10 | if c > a and c > b then |
11 | print ( " c wins" ) |
12 | end |
13 | wait() |
14 | end |
15 | wait() |
16 | end |