ID:2060886
 
Code:
var/list/clientimages=list()
mob
verb
ImageTest()
if(!clientimages["Dope"])
for(var/turf/T in range())
var/list/l=new
l.Add(clientimages["Image Test"],image('Piece.dmi',T,"cover"))
clientimages["Image Test"]=l
//src<<clientimages["Dope"]
src.client.images+=clientimages["Dope"]
spawn(30)
src.client.images-=clientimages["Dope"]


Problem description:
Basically I want to be able to display and remove a list of images from a usr with a line of code. The list of images are stored in an array. I was seeing if theirs a plausible way of doing this, so I can avoid looping through a list to display the images.
You should be adding clientimages["Image Test"] to client.images.
Is that not what this line is doing?
src.client.images+=clientimages["Dope"]
In response to Fat Albert
Not at all. clientimages["Dope"] is not the same as clientimages["Image Test"].
lol
ok, I can't seem to associate an array to a list...
In response to Fat Albert
List associations are pretty much the same as variable accesses.
// define 
mob/var/blah

// create a new empty list (can also be written as var/list/data = new)
var data[0]

// set the blah variable of some_mob
some_mob.blah = 123

// (add and) set the value associated to the key "blah"
data["blah"] = 123

// read and output the blah variable of some_mob
world << some_mob.blah

// read and output the value associated to the key "blah"
world << data["blah"]
Okay, I found the problem
mob
verb
ImageTest()
if(!clientimages["Image Test"])
clientimages["Image Test"]=new//the part I was missing.
for(var/turf/T in range())
var/list/l=new
l.Add(clientimages["Image Test"],image('Piece.dmi',T,"cover"))
clientimages["Image Test"]=l
//src<<clientimages["Dope"]
src.client.images+=clientimages["Image Test"]
spawn(30)
src.client.images-=clientimages["Image Test"]


I needed to initialize the list, it keep telling me runtime error: wrong type of value for list. I thought setting the setting the clientimages["Image Test"] to the variable l would of made it a list. Thanks a lot, I'm glad I figured this out.