ID:163569
 
My Code:
mob
verb
hi()
for(var/obj/weapon/w in usr.contents)
var/list/l = new/list
l.Add(w)
world << "[l.len]"
usr.client.screen += new/obj/name/dork


My Question:

If their is more than 1 obj/weapon in usr.contents why is the line "world << "[l.len]" only outputting 1?


Any help or (polite)comments will be appreciated.

CyanHB
You are defining the variable, l, within the verb. That means that l will contain and exist only until the verb ends. If it is executed again, the l will return to default. Since it's in the for() loop, every time the loop goes to the next item, l is being formatted (redefined as new/list)

Try defining l before the for loop so it doesn't keep resetting.