ID:830166
 
var/list/l1[1]
var/list/l2[1]

mob/verb/add_group_test(mob/m)
if(!m in l1)
l1.Add(m)
else if(m in l1)
l2.Add(m)
while(1)
for(var/mob/x in l1)
for(var/mob/y in l2)
if(src.loc==locate(12,6,1) && x in l1| y in l2)
x.loc=locate(12,3,1)
else if(src.loc==locate(12,6,1) && x in l1 && y in l2)
x.loc=locate(12,3,1)
y.loc=locate(11,9,1)
sleep(10)


The problem is that it believes that there is no mob in the list when I have added it.
how do I define the size of the list?
Actually, "var L[0]" is proper syntax for creating an empty list object.
The problem here is order of operations in the expression, "!m in l1", which reads "(not m) in l1", or "null in l1". This can be fixed by putting parentheses around the "in" operation, like so:

!(m in l1)
That worked. Why doesn't this:

                if(src.loc==locate(12,6,1) && x in l1| y in l2)
x.loc=locate(12,3,1)
else if(src.loc==locate(12,6,1) && x in l1 && y in l2)
x.loc=locate(12,3,1)
y.loc=locate(11,9,1)
?
In response to TheDarkChakra (#3)
Same problem. Order of operations.

Instead of "a in c && b in c" you need "(a in c) && (b in c)".
What is it that you expect this thing to do? As far as I can tell, it's just a jumble of nonsense. I'm surprised it even compiles.

You're asking if x and y, objects in the list you're referencing, are in fact in the list, when they HAVE to be in the list in order for the code to even be executing at all. If they WEREN'T in the list, it would never even GET to the if statements.

What are you trying to accomplish by constantly moving 2 mobs to the same place forever?
If I am asking these questions, maybe I am just a novice after all. I thought I was intermediate because I managed to do a lot of things I wanted to do through trial and error. But I don't know many basics and much of my codings are a mess.
Which is what we've been telling you, and what I tried to make you understand last night.
There, this is the code I managed to get to work:

mob/verb/add_group_test(mob/m)
if(!(m in l1))
l1.Add(m)
else if(m in l1)
l2.Add(m)
while(1)
for(var/mob/x in l1)
if(src.loc==locate(12,6,1))
x.loc=locate(12,3,1)
for(var/mob/y in l2)
if(src.loc==locate(12,6,1))
y.loc=locate(11,9,1)
sleep(10)


Just wanted to share that that's all.