ID:157854
 
mob/Login()
usr.icon='guy.dmi'
usr.icon_state = "guy"
density = 1
switch(input("What hair style would you like?", text) in list ("Mushroom","Spikey","Long","None"))
if("Mushroom")
del usr.hair
var/hairred = input("How much red do you want to put into your hair?") as num
var/hairblue = input("How much blue do you want to put into your hair?") as num
var/hairgreen = input("How much green do you want to put into your hair?") as num
var/hairover = 'Hair.dmi'
icon_state = "Mushroom_Hair"
hairover += rgb(hairred,hairgreen,hairblue)
usr.hair = hairover
usr.overlays += usr.hair
if("Spikey")
del usr.hair
var/hairred = input("How much red do you want to put into your hair?") as num
var/hairblue = input("How much blue do you want to put into your hair?") as num
var/hairgreen = input("How much green do you want to put into your hair?") as num
var/hairover = 'Hair.dmi'
icon_state = "Spikey_Hair"
hairover += rgb(hairred,hairgreen,hairblue)
usr.hair = hairover
usr.overlays += usr.hair
if("None")
del usr.hair
usr.loc=locate(1,1,1)

Its deleting, and i dont want that to happen !_!
you should change del usr.hair to usr.hair = null
and create Overlays() proc

for exmple

mob
proc
Overlays()
usr.overlays = null
usr.overlays += usr.hair
usr.overlays += any other overlays should be added

this will remove all the overlays and re-add them to the player

you will be able to fix overlays more easly that way you might want to add that proc when players login, also XD yeah dont chagne the hair icon state...



This would be because you are changing the icon_state of the player.
Your bug is in the line where you set icon_state. Instead of setting the hairs icon_state, you are setting the usr icon_state. Since "Mushroom_State" isn't inside your guy.dmi file, it gets set to the first icon in guy.dmi without a name. Since you don't have an icon without a name in guy.dmi, it sets the icon_state to nothing.

Here's a quick write up that might help.

turf
grass
icon='grass.dmi'
icon_state="grass"
mob
icon = 'guy.dmi'
icon_state = "guy"

var
icon/hair;
verb
ChangeHair()
Mob_ChangeHair()
proc
Mob_ChangeHair()
if (hair)
{
overlays -= hair
}
switch(input("What hair style would you like?", text) in list ("Mushroom","Spikey"))
if("Mushroom")
hair = new('Hair.dmi', "Mushroom_Hair");
if("Spikey")
hair = new('Hair.dmi', "Spikey_Hair");

var/hairred = input("How much red do you want to put into your hair?",,255) as num
var/hairblue = input("How much blue do you want to put into your hair?",,0) as num
var/hairgreen = input("How much green do you want to put into your hair?",,0) as num
hair.Blend(rgb(hairred,hairgreen,hairblue), ICON_MULTIPLY)
overlays += hair
Login()
loc = locate(1,1,1)
In response to Tsfreaks
Tsfreaks wrote:
Your bug is in the line where you set icon_state. Instead of setting the hairs icon_state, you are setting the usr icon_state. Since "Mushroom_State" isn't inside your guy.dmi file, it gets set to the first icon in guy.dmi without a name. Since you don't have an icon without a name in guy.dmi, it sets the icon_state to nothing.

Here's a quick write up that might help.

> turf
> grass
> icon='grass.dmi'
> icon_state="grass"
> mob
> icon = 'guy.dmi'
> icon_state = "guy"
>
> var
> icon/hair;
> verb
> ChangeHair()
> Mob_ChangeHair()
> proc
> Mob_ChangeHair()
> if (hair)
> {
> overlays -= hair
> }
> switch(input("What hair style would you like?", text) in list ("Mushroom","Spikey"))
> if("Mushroom")
> hair = new('Hair.dmi', "Mushroom_Hair");
> if("Spikey")
> hair = new('Hair.dmi', "Spikey_Hair");
>
> var/hairred = input("How much red do you want to put into your hair?",,255) as num
> var/hairblue = input("How much blue do you want to put into your hair?",,0) as num
> var/hairgreen = input("How much green do you want to put into your hair?",,0) as num
> hair.Blend(rgb(hairred,hairgreen,hairblue), ICON_MULTIPLY)
> overlays += hair
> Login()
> loc = locate(1,1,1)
>


When I use this, the hair layer is below the mob layer instead of above , otherwise it works ok. Any advice?
In response to Darkjohn66
Here's an example project containing exact source. As far as the layering problem, this exact code will place hair on top of mob. You might have something modifying the layer of the mob or hair. Look for something like "layer = MOB_LAYER+1".

Example

ts
In response to Tsfreaks
Wow thanks! Trying to do the best I can until I get my guide.