ID:269543
 
Is it possible to check for a position in a list?

Like a list of people Jim, Joe, Jake.
Is there a way to find that Joe is in position 2?
list.Find(item) will return the position of item in the list or 0 if it's not in there.
In response to tenkuu
_> Actually, if I use list.Find(Joe) it will just do that, I am looking for it to output like "2", etc.
if(list[2]=="Joe")return 1
if(list.Find("Joe")==2)return 1

Something like that should work. =p
I dunno if this is the most efficient way, but it should work(untested):
mob/verb/locatepos()
var/list/People=list("Jim","Joe","Jake")
var/Count
for(var/X in People)
Count++
usr<<"[X] is position [Count]"


EDIT
Bah, their ways look better. But I tried. =P
In response to Sniper Joe
Sniper Joe wrote:
_> Actually, if I use list.Find(Joe) it will just do that, I am looking for it to output like "2", etc.

var/position = my_list.Find(Joe)
world << "Joe is in position #[position]!"