ID:160895
 
What my goal is to flip a mob upside down for a verb and it works. However, my hairs and clothing are based on overlays. When I flip a mob, their icon flips, but their overlays refuse to.

I've tried..

mob
verb
test()
var/image/A = src.overlays
src.overlays = null
src<<A


or..

mob
verb
test()
var/A = (src.icon+src.overlays)


And continue on from there. Any help would be appreciated.
Try this one:
mob
verb
Up_Side_Down()
var/list/L = overlays.Copy()
overlays = null
icon = turn(icon,180)
for(var/o in L)
var/image/i = o
var/icon/I = turn(i.icon,180)
overlays += I
In response to Jemai1
Any implementation of that kind of approach is just not going to work well, if at all. Read the Reference:

The individual items in the list may not be directly accessed, since they are stored in a special internal format.

The items inside overlays are not /image objects, /icon objects, atoms or otherwise a known manipulatable format.
Yeah, make a separate list which stores the player's overlays, and then when you edit the list, null the overlays and re-add the list to the overlays.
e.g:
mob/var/list/crap
mob/proc/add_crap(var/A)
src.crap+=A
src.overlays=null
src.overlays+=src.crap
mob/proc/turn_crap()
var/list/L=list
for(var/A in src.crap)
var/icon/I
if(istype(A,/obj))
I=icon(A:icon,A:icon_state)
else if(istext(A))
I=icon(src.icon,A)
else if(ispath(A))
var/obj/O=new A
I=icon(O.icon,O.icon_state)
del O
else
I=icon(A)
I.Turn(180)
L+=I
src.crap=L
src.overlays=null
src.overlays+=src.crap
A lot of stuff isn't included here, but I hope you get the gist of it. You're basically using a list that you can get each individual value from instead of the overlays var itself.