ID:141225
 
Code: Multi Tiled Overlay problem.
obj
Shirt
icon = 'Shirt.dmi'
pixel_y=32
layer=MOB_LAYER+2
verb
Drop()
set src in usr
src.Move(usr.loc)
Get()
set src in oview(1)
src.Move(usr)
Equip()
set src in usr
usr.overlays += 'Shirt.dmi'
Unequip()
set src in usr
usr.overlays -= 'Shirt.dmi'


Problem description: I just made a simple Shirt that overlays when you right-click it, then choose equip, you get the point. But i have a Multi Tiled base icon, and i want to equip the shirt on the upper body. Thats why i put pixel_y=32 there. Any suggestions on how to do this? *Note that the Base Icon is 32x64 px.

Nobody has a solution for this problem?
usr.overlays+=src

usr.overlays-=src

Do this instead.

The reason is you are adding the pixel adjustment to the object (that is fine) but then you are adding the base icon to the overlays of the user (that is not fine). That is just putting the icon there, NOT the object (which has the pixel modification on it)
In response to AJX
Yes, but when i'm trying the save the overlays there, the overlay will stay when unequipping.
In response to Mitzzz
This is because when you save overlays, it sort of compiles all of the overlays (shirt, shoes, pants) in 1 image. Best is to add overlays to another list, and make a proc to remove overlays and re-add them from the other list.
In response to Mitzzz
More accurately, that's because after overlays is loaded, some types of overlays can't be removed by conventional means anymore. This includes those made by adding an object reference or type path, and not those made by adding an icon file, hence you've only seen the problem with your initial code. The course of action here should really be to not save overlays at all (also saves the icon data space in the file), and instead reconstruct them after every time a mob is loaded. To do this you should keep track of what items a mob actually has equipped, though - as of now all you're doing is adding and removing a hardcoded overlay when something is equipped (and with separate verbs for all equipment, I'd guess). All in all, not a very good or handy equipment system.
You should store what the mob has equipped in a list on that mob, and use object oriented programming to share common properties between similar objects without duplicating them on each one - f.ex. give all your items a single Get() verb to share. Read here for more info: [link]

After you've made an equipment list like above, all you need is loop through it and apply overlays to the currently equipped items after a mob is loaded. If you have other sources of overlays, like, say, separate hair, you'd need to include that in the overlay reapplying, of course. We can do stuff when an object is saved/loaded by overriding the Write()/Read() procs - look 'em up. It'd look something like this:
mob/person
var/list/equipment
...
Write(savefile/F)
//before the mob is saved, temporarily empty overlays< so they're not needlessly saved
var/overlays_backup = src.overlays
src.overlays = null
..() //do the actual saving
//somewhat optional: remove the savefile entry of overlays (now holding a null value)
F.dir -= "overlays"
src.overlays = overlays_backup //restore the actual mob's overlays back
Read(savefile/F)
..()
//after a mob is loaded, rebuild his overlays
src.RebuildOverlays()
proc/RebuildOverlays()
src.overlays = null

//add hair and every equipped item to overlays
src.overlays += src.GetHair()
for(var/obj/O in src.equipment)
src.overlays += O

Note a dummy overlays list isn't needed.