ID:163088
 
I used the search function, but couldn't find an easy answer to my problem. I can't seem to figure out how to get overlays turned, using the turn proc (applied to an icon). Using for() to look for all icons in the overlays var doesn't work.
Kaiochao2536 wrote:
Using for() to look for all icons in the overlays var doesn't work.

That's because it isn't an ordinary list, and the items (icons) are in a special format, not an icon file or /icon object. So what you can do with it is limited, neither can you change icon snapshots already in the list.

From what I remember, what you must do in a case like this is keep track of every overlay added and removed, then when you need to turn/color/otherwise affect the overlayed icons, remake the overlays list; set it to null (shouldn't require setting it to a new list as its a special variable) then start readding overlays (now altered [ie turned]) to it based on the data you kept track of.
Though you may have missed it in your search, note that it HAS been discussed before. Try broader and different keywords in your future searches.
In response to Kaioken
If you want a bug-free version of what he said: search for crashLays by Crashed.(This is probably the 5th time I've mentioned this.)
In response to Kakashi24142
This is what I've come up with.
mob
var/list/Overlays=list()
proc
Overlay_Check(angle=0)
overlays = null
if(angle!=0)OverlayTurn(angle)
for(var/i in Overlays)overlays+=i
src<<"Overlay test finished. "
OverlayTurn(angle=0)
overlays=null
src<<"Setting overlays to null."
for(var/icon/i in Overlays)
src<<"Searching for overlays."
var/icon/I=i
src<<"Checking angle."
if(angle!=0)
src<<"Turning icon."
I=turn(I,angle)
src<<"Changing icon."
i=I
src<<"Adding overlays."
overlays+=Overlays


When I call the Overlay_Check() proc with a number, it gets to OverlayTurn() and stops at "Turning icon.", giving me a runtime error saying "bad turn." It's a little messy, so a little help?
In response to Kaiochao2536
I would think you would use I.Turn(I,angle)? Because the normal turn proc returns a number.
In response to Kakashi24142
I wouldn't think there's a difference. Plus, this worked for the mob's icon:

icon=turn(icon,90)


Just can't get it to work for overlays.

EDIT:

Fixed it. :)
For some reason it doesn't work when it is added to the alternate overlays list like this:
overlays2+=icon

But it works like this:
var/icon/I=icon('icon.dmi')
overlays2+=I

</dm>
In response to Kaiochao2536
Look up at least the /icon object in the DM Reference.