ID:144514
 
Noone at Developer How To gave a damn about this, so im bringing it here for GhostAnime to help me :P

Lets say, I want to make a verb that changes ur form into a mob in oview...
It's all fine and I did it, works great except for 1 thing... When it does that, usr.oldicon = usr.icon (of course when u revert, usr.icon = usr.oldicon) BUT! I made a list for the overlays
usr.Overlays = null
for(var/L in usr.overlays)
usr.Overlays += L
usr.overlays = null

and when u revert
usr.overlays = null
for(var/L in usr.Overlays)
usr.overlays += L
usr.Overlays = null

But when I change my form back to my orig, my icon changes back and all but I dont get my old overlays... (I also didnt check if I get the mob's overlays when I form change into him...) so my question is, how I do it, so it keeps ur overlays somewhere for future use?
Unfortunately, overlays/underlays are not your typical list as they do not hold any actual types in there (well, they do but they don't get pulled out properly, per say).

One method is:
for(var/L in usr.overlays) usr.Overlays+=image(L:icon,L:icon_state)
The : is vital in this case.

Also, don't make <code>usr.Overlays = null</code> if you are using it as a list, it can give you problems in hwich you don't want. Instead, use <code>usr.Overlays = list()</code> so the variable's value is understood as a list rather than as a null type.

However, someone else please verify me :/

Another option is to make an overlay-add/minus procedure which adds the overlays in the usr.overlays and a same copy in usr.Overlays but that can be a bit troublesome.

And I hope that is from a verb and not a mob/proc (the use of usr within that is).

Edit: I forgot the most simplest method ever >_<
usr.Overlays=usr.overlays
usr.overlays=null
and when you're done:
usr.overlays=usr.Overlays
usr.Overlays=list() //well, I guess you can have this as null if you want since we directly set the overlays value to it but meh it


- GhostAnime
In response to GhostAnime
Okay, after doing a few things, when I transform into a mob its all fine and I get hes icons, and I dont keep my old overlays... BUT!
When I revert my icon changes back to my old icon, BUT I dont get my old overlays... this is the transform and revert code:

Transform
                            for(var/X in usr.Overlays)
del(X)
for(var/image/L in usr.overlays)
usr.Overlays+=image(L:icon,L:icon_state)
for(var/Y in usr.overlays)
usr.overlays -= Y
usr.oldicon = usr.icon


Revert
                    usr.icon = usr.oldicon
for(var/X in usr.overlays)
usr.overlays -= X
for(var/image/L in usr.Overlays)
usr.overlays += L
for(var/image/Y in usr.Overlays)
usr.Overlays.Remove(Y)
In response to Souloron
Hn, try outputting the values of what has been added, I GUESS you need to use :

But if I were you, I'd do the example I showed at the end of my last post, less abuse, hassle and headaches :)

- GhostAnime
In response to GhostAnime
I did the example, but still I dont get my overlays back...

Transform:
                            usr.Overlays=usr.overlays
usr.overlays=M.overlays
usr.oldicon = usr.icon


Revert:
                    usr.icon = usr.oldicon
usr.overlays=usr.Overlays
usr.Overlays=list()
In response to Souloron
Hm, strange.. I wish I was at home so I can look up what I did >_<

For the revert in the other one, try using the samething method I showed for adding into Overlays (using : when looping through the Overlays)

- GhostAnime
In response to GhostAnime
making a naruto game? lol >.>
In response to Ruben7
Nope.
In response to GhostAnime
Still doesnt work...
In response to Souloron
After using the search button, I found a way to make it work.

Transform:
                            usr.Overlays = usr.overlays.Copy()
usr.overlays = usr.overlays.Remove(usr.overlays)
usr.overlays -= usr.overlays
usr.overlays += M.overlays
usr.oldicon = usr.icon
usr.icon = M.icon


Revert:
                    usr.icon = usr.oldicon
usr.overlays -= usr.overlays
usr.overlays = usr.overlays.Remove(usr.overlays)
usr.overlays = usr.Overlays.Copy()
usr.Overlays = list()
In response to Souloron
Early mornings are not my favourite hours >_<

Why do you have this anyways:
                    usr.overlays -= usr.overlays
usr.overlays = usr.overlays.Remove(usr.overlays)


They both do the same exact thing, get rid of one. THINK OF THE BYTES MAN! >_>''

- GhostAnime, The digital hippie <_<;
In response to GhostAnime
I know, but thats what he did and it finally worked so I didnt want to risk it :P
In response to Souloron
Well, if you don't take a risk, what will get to gain? Eh, not much in this case I guess though.

Nice job using the forum search, maybe you can learn a few more tricks from it before asking a question? >_>

Now where's my coffee? :|

- GhostAnime
In response to GhostAnime
GhostAnime wrote:
However, someone else please verify me :/

I set lists to null all the time. All you have to do is initialize it to new when you want to use it next and it should still retain it's type.

mob
var/list/ItemFinds = null
Login()
..()
if(!ItemFinds) ItemFinds = new
world << "[istype(ItemFinds, /list) ? 1 : 0]"
ItemFinds = null
ItemFinds = new
world << "[istype(ItemFinds, /list) ? 1 : 0]"