ID:171668
 
I'm stuck and I just cant figure it out. I want to use SwapColor() to change the color of my mobs icon, but Its a multi tiled mob using overlays. I can't figure out How to do it. When I try to SwapColor on my overlays, the overlays just disappear.. Can anyone help me with this one?
This belongs in the newbie central and your answer is probably RGB().
Troglodyte wrote:
I'm stuck and I just cant figure it out. I want to use SwapColor() to change the color of my mobs icon, but Its a multi tiled mob using overlays. I can't figure out How to do it. When I try to SwapColor on my overlays, the overlays just disappear.. Can anyone help me with this one?

I had a similar problem. I went the long way, and made a proc to reset the overlays when you changed the color or the mob.
In response to Jik
So what did you do, remove the overlays, make new objects and swapcolor them, and then add them to overlays?
In response to Troglodyte
What I did was reset the icon for the mob.
(if the mob.icon was 'this.dmi' I just re-assigned it :

mob.icon = 'this.dmi')

also remove all overlays with

mob.overlays = ""

As to changing the color, the initial mob was a greyscale, and I used :

mob.icon += rgb(255,0,0) //this is red

to adjust the "hue" of the mob.
In response to Jik
Jik wrote:
also remove all overlays with

mob.overlays = ""

You're better off using null or list() here. The overlays var is never equal to a string, so setting it to one could give you unpredictable results.

Lummox JR
Troglodyte wrote:
I'm stuck and I just cant figure it out. I want to use SwapColor() to change the color of my mobs icon, but Its a multi tiled mob using overlays. I can't figure out How to do it. When I try to SwapColor on my overlays, the overlays just disappear.. Can anyone help me with this one?

Once an overlay is set you can't simply modify it; it has to be deleted and redone.

Lummox JR
atom
icon = 'icons.dmi'
mob
icon_state = "player"
Login()
..()
var/obj/o = new /obj()
o.desc = "mob part"
o.icon_state = "hat"
o.layer = MOB_LAYER+1
src.overlays += o
verb
Change_Color()
for(var/i in usr.overlays)
if(i:desc == "mob part")
var/icon/I = icon(i:icon,i:icon_state)

I.SwapColor(rgb(105,105,105),rgb(255,0,255))
usr.overlays -= i

var/obj/o = new /obj()
o.desc = "mob part"
o.icon = I
o.layer = MOB_LAYER+1
usr.overlays += o


That would change the color of all overlays with a desc of "mob part". However, for that to work, you must add the overlays just like that.