ID:155043
 
So lets say I have four variables
mob
var
a
b
c
d


I'll do something to make the variables increase depending on what the player does. But I want the program to see which variable has the highest value.
mob
verb
Highest_Value()
if(a has highest value)
//
else if(b has highest value)
//
else if(c has highest value)
//


and so on.

So basically, find the outlier of the variables, and so something different for each outlier.
mob

var
a = 2
b = 5
c = 10
d = 1

verb
Highest_Value()
switch(global.getHighestValue(list("a" = src.vars["a"], "b" = src.vars["b"], "c" = src.vars["c"], "d" = src.vars["d"])))

if("a")
world << "a has highest"

if("b")
world << "omg no, b does!"

if("c")
world << "nop. c does"

if("d")
world << "wrong"

proc
getHighestValue(array[])
for(var/something in array)
if( (!.) || (array[something] > array[.]) ) . = something


simpler approach, simpler one is better anyway
i did 1st one with string literals becuz i mistakenly thought that was the format u wanted

mob

var
a = 2
b = 5
c = 10
d = 1

verb
Highest_Value()

var
max = max(src.a, src.b, src.c, src.d) // max() returns the max number

if(src.a >= max)
world << "a has highest"

else if(src.b >= max)
world << "b has highest"

else if(src.c >= max)
world << "c has highest"

else
world << "d has highest"
In response to Towers
include comments, please? some of it I didn't understand
In response to BeignetLover
are u content
In response to Towers
?
In response to BeignetLover
bump