ID:262484
 
Code:
mob
verb
Top_Icon(I as icon)
set category = "Icon"
if(Head)
overlays-=Head
del(Head)
var/image/Top=image(I)
Top.pixel_y=32
overlays+=Top
Head=Top
Top_Icon_State(state as text)
set category = "Icon"
if(Head)
overlays-=Head
var/image/Top=image(state)
Top.pixel_y=32
overlays+=Top
Head=Top


Problem description:
When I test it; loading the Top Icon works but when I try to change the Top Icon State it just deletes the Top Icon.
what is the 'head' var, what does it have? a number, text a icon?

O-matic
In response to O-matic
mob/var/head

In response to OnLy SoUlJaH
I guess the head var holds a icon >_>.
well, its kinda easy to figure out where the head is dissapearing.
   if(Head)
overlays-=Head

what you are doing there is removing the head overlay. so it doesn't get a change to change the icon_state.
        Top_Icon_State(state as text)
set category = "Icon"
var/image/Top=image(state)
Top.pixel_y=32
overlays+=Top
Head=Top


if you remove that part it will probarly work.
and also, that verb is to change a icon state right? I don't see you changing the icon state anywhere >_>
        Top_Icon_State(state as text)
set category = "Icon"
var/image/Top=image(state)
Top.pixel_y=32
overlays+=Top
Head.icon_state="[state]"
Head=Top


I think that'll work. =)

O-matic
</dm>
In response to O-matic
I've put in exactly what you wrote, but I come up with 1 error.
customize.dm:17:error:Head.icon_state:undefined var

The Head var is just
mob/var
Head
In response to O-matic
O-matic wrote:
what you are doing there is removing the head overlay. so it doesn't get a change to change the icon_state.

And then it creates a new image... the previous line was to "get rid of the old and welcome in the new"
>        Top_Icon_State(state as text)
> set category = "Icon"
> if(Head)
> overlays-=Head
> var/image/Top=image(state)
> Top.pixel_y=32
> overlays+=Top
> Head=Top
>

and also, that verb is to change a icon state right? I don't see you changing the icon state anywhere >_>
O-matic
Actually, he is. var/image/Top=image(state)
but you didn't supply an icon for the image. Therefore having a null icon with the icon_state of whatever state is.
Look up image proc, in the DM Help. (Press F1)
Then you will know how to fix it.
In response to OnLy SoUlJaH
Do mob/var/icon/Head. That should work.
Just set the icon_state for the head.
mob
verb
Top_Icon(I as icon)
set category = "Icon"
if(Head)
overlays-=Head
del(Head)
var/image/Top=image(I)
Top.pixel_y=32
overlays+=Top
Head=Top
Top_Icon_State(state as text)
set category = "Icon"
if(Head)
overlays-=Head
var/image/Top=Head
Top.icon_state = state
overlays+=Top

If you define the Head as an image object as well, you don't even need the Top variable in the Top_Icon_State and can just change its icon_state with Head.icon_state=state, then overlays+=Head.
In response to Loduwijk
Thanks it worked. But I was wondering, is it possible to make the Top Icon State select a state from a list? Instead of typing the state? I've got it with just normal icon. But I can't use it on the Top Icon. Below is the Change Icon State coding I have for the list version.
Change_Icon_State()
set category = "Customize"
var/states=list("")
for(var/L in icon_states(usr.icon)+"Default")
states+=list("[L]")
if("Default")
usr.icon_state = ""

Anyone know how make the list version for the Top Icon?
In response to OnLy SoUlJaH
Top is not an icon, as you made it an image. image objects have an icon variable too, though. So you could do Top.icon
In response to Loduwijk
O.o... I'm confused.
In response to OnLy SoUlJaH
You defined Top as an object of type /image. Look up /image in the help file. They have variables for icon, icon_state, pixel_x, pixel_y, loc, and other things.

An object of type /image is basically an object that wraps up additional information along with an icon in order to make better use of it.
var/image/I = image('icon.dmi')
I.icon_state = "this"
I.icon_state = "that"
I.icon_state = "the other"

You can change the icon state of an /image object. That makes things much easier for you, as you do not have to use the image function to create an entirely new image just for that icon_state.