ID:273790
 
Hello,

I'm a complete newb to this, so bear with me. Please.

I want to add 'clothing' to this game, and I thought setting overlays was the best way to do it. So I followed this:

http://www.byond.com/ members/?command=reference&path=atom%2Fvar%2Foverlays

I pretty much did what the second example states.

The problem is, every time the user logs out the game and re-enters, the overlay cannot be removed with the 'remove_clothes()' verb.

Upon reading note 2 at the bottom, it says that I have to do something to keep the overlay separate from the icon file, by messing around in the Write and Read procs.

But, I have NO clue what to add to these.

Can someone help? I've been trying to think of ways, but it's such a brain hurter. :D

EDIT: Forgot to mention, the removing verb works if I save the game with a save() verb though, just when logging out and logging in, it seems to not want to work. It does auto-save when logging off, mind.

Thank you!
I believe something as simple as this should handle it (mind you, I don't work with savefiles very often..)

mob
Write(savefile/F)
// Back-up the overlays lists
var/list/tmpOverlays = overlays.Copy()
var/list/tmpUnderlays = underlays.Copy()

// Empty out the lists so they aren't saved
overlays.Cut()
underlays.Cut()

// Do the default action (save the mob)
. = ..()

// Re-add the backed-up overlays
overlays += tmpOverlays;
underlays += tmpUnderlays;


Basically, whenever you save a datum (the most basic, low level type in DM. All atoms, turfs, objects, mobs, ect inherit from it) with either Datum.Write(Savefile) or Savefile<<Datum, the datum's Write() process gets called. By overriding this process, we can temporarily empty out the overlays lists, let it do its normal thing, and then add the overlays back. This way, the saving routine won't blend them into the icon.

The reason you only saw the problem when you re-logged, was you had to load the icon from the savefile.

Also, I believe it's generally a bad idea to save icons at all, unless it's absolutely necessary. It bloats the savefiles.
In response to DarkCampainger (#1)
Thanks for that.

It seems that when I log out with the clothes on, and log back in, the clothes are not equipped.

Must I be adding more stuff on the Read proc now?
In response to Darth Mo 72 (#2)
Bump.

Still looking for a way to keep the overlays intact after logging in. Instead of needing to 'wear' them again.

:)
In response to Darth Mo 72 (#3)
Read through the Code and comments properly. Hes copying his overlays to a temporary list.

You'll have to add overlays after loading from the list.
In response to Slic3y (#4)
Yeah, I got that (I think).

But when logged off, the temp list is emptied, is it not?

So how would I go about re-adding the overlays when logging back in?

I think I'm getting more confused now...
In response to Darth Mo 72 (#5)
So basically he saves your overlays to another list because saving stuff in the built in overlays is kind of different than from doing it with a list. Then he empties the overlay list so that Write doesn't end up saving it. When Read does it thing, it reads the list you saved and then add it to your built in overlays list, thus you have overlays again after you log out.
In response to Gr1m d4 r34p3r (#6)
Hi again,

So am I supposed to add anything to Read for it to grab the info from the tmp list?

If so, how would I do it? :o

Thanks again guys.
recently I've been working with a few overlays, they all seem to save to the characters when i logout and are there when i login. Are you addressing the clothing by the correct object names? a simple:
for(hat in src.overlays)
src.overlays-=hat

should do the trick where hat is your overlay that you want to take from the list.