Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[Solved]How would I detect if one of the three values are the highest?

Asked by 10 years ago
1= 10
2b = 1
3c = 5

If people voted and these were the results how would I figure out whats the highest?

2 answers

Log in to vote
3
Answered by 10 years ago

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.

01local a = 10
02local b = 1
03local c = 5
04 
05local 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 
07function Compare(Args)
08local HighestNumber = nil --The highestnumber out of the table
09local Letter = nil --The letter that goes with the highestnumber like A,B,C, etc.
10for I,v in pairs(Args) do --Grabs all of the variables from the table, and cycles until it's read through eah variable.
11if HighestNumber == nil then
12HighestNumber = v
13Letter = Dictionary[I]
14else
15if v > HighestNumber then
View all 22 lines...
0
Sorry about the capital I's, most of them are suppose to be lower cased. But my computer automatically capitalizeses I's. xImmortalChaos 565 — 10y
0
thx anyways rabidhalofan12345 55 — 10y
1
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. xImmortalChaos 565 — 10y
Ad
Log in to vote
1
Answered by
Hybric 271 Moderation Voter
10 years ago
01= 10
02b = 1
03c = 5
04if a > b and a > c then
05print("a wins")
06else
07if b > a and b > c then
08print("b wins")
09else
10if c > a and c > b then
11print(" c wins")
12end
13wait()
14end
15wait()
16end
0
Change the values around (a,b,c) to test out the script! Hybric 271 — 10y
2
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. TheeDeathCaster 2368 — 10y
0
Also, post an explanation, not just code. Perci1 4988 — 10y

Answer this question