ID:263670
 
Code:
obj
thewings
undereast
icon = 'blackwing.dmi'
icon_state="undereast"
pixel_x =-32
underwest
icon = 'blackwing.dmi'
icon_state="underwest"
pixel_x = 32
under
icon = 'blackwing.dmi'
icon_state="under1"
over2
icon = 'blackwing.dmi'
icon_state="north2"
pixel_x = -32
over3
icon = 'blackwing.dmi'
icon_state="north3"
pixel_x = 32
over4
icon = 'blackwing.dmi'
icon_state="south2"
pixel_x = -32
over5
icon = 'blackwing.dmi'
icon_state="south3"
pixel_x = 32
ova
icon = 'blackwing.dmi'
icon_state="over"

obj
Items
JinWings
name = "Fallen Angel"
icon = 'wings display.dmi'
Click()
if (src.equipped == 1)
usr.underlays -= /obj/thewings/undereast
usr.underlays -= /obj/thewings/underwest
usr.underlays -= /obj/thewings/under
usr.overlays -= /obj/thewings/over2
usr.overlays -= /obj/thewings/over3
usr.underlays -= /obj/thewings/over4
usr.underlays -= /obj/thewings/over5
usr.overlays -= icon('blackwing.dmi',"over")
usr << "You remove [src.name]"
src.suffix=""
usr.wingsequip=0
src.equipped = 0
usr.Strmax += 25
usr.Strmin += 25
usr.speed = 2
return
else
if(usr.wingsequip==0)
usr.wingsequip = 1
usr.underlays += /obj/thewings/undereast
usr.underlays += /obj/thewings/underwest
usr.underlays += /obj/thewings/under
usr.overlays += /obj/thewings/over2
usr.overlays += /obj/thewings/over3
usr.underlays += /obj/thewings/over4
usr.underlays += /obj/thewings/over5
usr.overlays += icon('blackwing.dmi',"over")
src.suffix="Equipped"
usr << "You equiped [src.name]"
src.equipped = 1
usr.Strmax += 25
usr.Strmin += 25
usr.speed = 0


Problem description:
When you equip the wings and save and relog, and try to unequip them, some of the overlays and underlays stay. Does anybody know what i am doing wrong?
is there supposed to be another way to remove obj overlays?
The thing with saving a mob with overlays is that the overlays get merged into the icon that's saved so when it's loaded they're no longer overlays but a part of the icon.

The best way to do saving with overlays is to remove all overlays before saving the player making sure you have some way of telling the game to readd them after you load your player.
mob
var/has_overlays = 0
verb
Save()
overlays = list()
// Saving stuff here
Load()
// Loading stuff here
if(has_overlays)
// Add the overlays again.


Of course you'd have to change has_overlays to 1 when you add the overlays and to 0 when you remove them to make sure it adds them properly when you load the player.
In response to Nadrew
so store the overlays and underlays in lists and remove them when the logout and when they login, give the overlays and underlays back from the lists to the person?

heres my save code, i did what you said to do, but im not sure if its right

mob
proc
SaveK()
if(src.cansave)
var/start = 1
var/end = 2
var/first_initial = copytext(src.key, start, end)
var/savefile/F = new("players/[first_initial]/[src.key].sav")
F["name"] << src.name
src.V = src.verbs
src.xco = src.x
src.yco = src.y
src.zco = src.z
src.overlayslist = src.overlays
src.underlayslist = src.underlays
src.overlays = null
src.underlays = null
src.has_overlays = 1
Write(F)
src.overlays = src.overlayslist
src.underlays = src.underlayslist
src.has_overlays = 0
In response to Nadrew
I was under the impression if you added overlays as an icon it would work fine and avoid this problem. Either doing src.overlays += icon('pizza.dmi',"pizza")

Or by doing
obj/shirt
var/icon/shirtoverlay = icon('pizza.dmi',"pizza")


And then when you equip just add the shirtoverlay as the overlay. That's always worked for me...

[Sorry if there's alignment problems w/ the code I'm using my phone not computer]

-Dession
In response to Dession
so when i want to try to define a pixel_x or y for it i just do this ?

obj/shirt
var/icon/shirtoverlay = icon('pizza.dmi',"pizza")
pixel_y = 32
In response to Max Omega
Max Omega wrote:
so when i want to try to define a pixel_x or y for it i just do this ?

> obj/shirt
> var/icon/shirtoverlay = icon('pizza.dmi',"pizza")
> pixel_y = 32
>


Yes I think so. Sorry I'd be more help if I was on a computer but yeah try that and see if it works and you're able to relog and still remove it.
In response to Dession
i set the variable but when i use it it says the variable is undifined, when i clearly defined it

obj
thewings
undereast
var/bwingoverlay1 = icon('blackwing.dmi',"undereast")
pixel_x =-32
underwest
var/bwingoverlay2 = icon('blackwing.dmi',"underwest")
pixel_x = 32
under
var/bwingoverlay3 = icon('blackwing.dmi',"under1")
over2
var/bwingoverlay4 = icon('blackwing.dmi',"north1")
pixel_x = -32
over3
var/bwingoverlay5 = icon('blackwing.dmi',"north3")
pixel_x = 32
over4
var/bwingoverlay6 = icon('blackwing.dmi',"south2")
pixel_x = -32
over5
var/bwingoverlay7 = icon('blackwing.dmi',"south3")
pixel_x = 32


obj
Items
JinWings
name = "Fallen Angel Wings"
icon = 'wings display.dmi'
Click()
if (src.equipped == 1)
usr.underlays -= bwingoverlay1
usr.underlays -= bwingoverlay2
usr.underlays -= bwingoverlay3
usr.overlays -= bwingoverlay4
usr.overlays -= bwingoverlay5
usr.underlays -= bwingoverlay6
usr.underlays -= bwingoverlay7
usr.overlays -= icon('blackwing.dmi',"over")
usr << "You remove [src.name]"
src.suffix=""
usr.wingsequip=0
src.equipped = 0
usr.Strmax += 25
usr.Strmin += 25
usr.speed = 2
return
else
if(usr.wingsequip==0)
usr.wingsequip = 1
usr.underlays += bwingoverlay1
usr.underlays += bwingoverlay2
usr.underlays += bwingoverlay3
usr.overlays += bwingoverlay4
usr.overlays += bwingoverlay5
usr.underlays += bwingoverlay6
usr.underlays += bwingoverlay7
usr.overlays += icon('blackwing.dmi',"over")
src.suffix="Equipped"
usr << "You equiped [src.name]"
src.equipped = 1
usr.Strmax += 25
usr.Strmin += 25
usr.speed = 0
In response to Max Omega
Well the variables you created aren't global so that wouldn't work.
In response to Dession
The way I deal with overlays is to have checks that run through vars with objs that are overlayed. For example, if I had a sword and shield equipped, but nothing else, yet I had other overlays I wanted to get rid of, first I would delete overlays completely by making them null, then I would re-add the overlays, but only the ones who's vars return positive.