ID:179166
 
Okay, so I have a command that goes like this:


mob/verb/MoveFromList(obj/O in list1+list2+list3+list4)


And I want to move O from it's current list to a new list I specify. What can I do to find out which of list1-4 O was originally taken from, so that I can delete it from that original list and move it to the new one?
You could do it the long way like this:

if(list1.Find(O)) list1 -= O
else if(list2.Find(O)) list2 -= O
else if(list3.Find(O)) list3 -= O
else if(list4.Find(O)) list4 -= O


I don't think there is any other way to do it because there is no var that stores the list (and location in that list) where it is pointed to. This is probably because multiple lists can be pointing to one object.

Actually, you could probably do it without the if statements:

list1-=O
list2-=O
list3-=O
list4-=O
Good day, Foomer,

mob/verb/MoveFromList(obj/O in list1+list2+list3+list4)


Maybe it would be handy for you to add another variable in obj/O, witch could be used to determine current list.

Like:
-= Code =-
obj/O
var/tmp/cur_list[] = null // null = not in any list

proc/add_to_some_list(O as obj,lst as list)
if( O.cur_list != null )
O.cur_list.Remove( O )
O.cur_list = lst
lst.Add( O )
-= Code =-

My example most likely have some mistakes, but you should get the idea.

Have fun ! :)
Kestutis
In response to Kestutis
I suggest using the Add abd Remove procs, look them up.