ID:155788
 
I'm trying to make a train/chain of objects that can be created, then deleted by the user. I'm trying to do this with a array/list but i can't figure it out.

Are you not allowed to add objects to a variable while the game is running because i keep getting a run time error.
objs can be stored in lists, no problem. Try giving us the runtime error and the function where it occurs and maybe we can help.

ts
mob/verb/Objs_in_list_test()
var/list/L = list()
world<<"<i>Size of list: [L.len]"
world<<"<b>Adding 20 objects to list."
for(var/i = 1 to 20)
var/obj/o = new
o.name = "Object [i]"
L.Add(o) //or L += o
world<<"[o.name] added to list."
world<<"<i>Size of list: [L.len]"
world<<"<b>Removing 5 random objs from list."
for(var/i = 1 to 5)
if(L.len <= 0)break //If there is nothing in the list we won't be removing anything so we will exit the loop.
var/obj/o = pick(L)
L.Remove(o) //or L -= o
world<<"[o.name] removed from list."
world<<"<i>Size of list: [L.len]"
world<<"<b>Removing last 5 objs in list from list."
for(var/i = 0 to 4)
if(L.len <= 0)break //If there is nothing in the list we won't be removing anything so we will exit the loop.
var/obj/o = L[L.len] //L's length will keep decreasing by one as we remove objs from the list.
L.Remove(o) //or L -= o
world<<"[o.name] removed from list."
world<<"<i>Size of list: [L.len]"
world<<"<b>Emptying the list"
L = list()
world<<"<i>Size of list: [L.len]"
In response to Zaltron
I just realized I had forgotten to come back and thank you guys for this. It's much appreciated!!