ID:139946
 
Code:
mob/proc/Hair()
icon = 'GoldenSunHair3.dmi'
var/hairtype = icon_state
switch(input("Please Choose a Hair Type:", "Hair?") in list ("Short", "Long Hair", "Swift", "Twisted(Female)"))
if("Short")
var/hair_color = input("What hair color do you want?","Hair Color")as color
hairtype = "malehairshort"
hairtype+= hair_color
src.hair= hairtype
src.overlays += hair
if("Swift")
var/hair_color = input("What hair color do you want?","Hair Color")as color
hairtype = "malehairswift"
hairtype+= hair_color
src.hair= hairtype
src.overlays += hair
if("Long Hair")
var/hair_color = input("What hair color do you want?","Hair Color")as color
hairtype = "femalehairlong"
hairtype+= hair_color
src.hair= hairtype
src.overlays += hair
if("Twisted(Female)")
var/hair_color = input("What hair color do you want?","Hair Color")as color
hairtype = "femalehairtwisted"
hairtype+= hair_color
src.hair= hairtype
src.overlays += hair


Problem description: When I logg in, it lets me choose the hairstyle and color, but it wont add the hair to the character. I get no errors in my code. I added the hair variable to mob/var if anyone thinks it's missing.

You can't set a text string as an overlay. Also, this would be much easier if you just used an /obj type for the choices.

hair
parent_type = /obj

short
parent_type = /hair

long
parent_type = /hair

swift
parent_type = /hair

player/proc/choose_hair()
var/choice = input(src, "hair blah", "hair")in list(/long, /short, /swift)
src.overlays += choice
In response to tidus123
tidus123 wrote:
You can't set a text string as an overlay.

Yes you can. The overlay then acts to match the base object's icon, with its icon_state set to the text string.
In response to Garthor
Garthor wrote:
tidus123 wrote:
You can't set a text string as an overlay.

Yes you can. The overlay then acts to match the base object's icon, with its icon_state set to the text string.

So what do I need to do to get it working ? x.x
In response to Mariahh
mob/proc/Hair()
var/obj/Hair=new()
Hair.icon='GoldenSunHair3.dmi'
Hair.icon_state=input(src,"Please Choose a Hair Type:", "Hair?") in icon_states(Hair.icon)
src.hairColor=input(src,"What hair color do you want?", "Hair Color", src.hairColor) as color //You probably want to save their hair color too
src.hairStyle=Hair.icon_state
Hair.icon+=src.hairColor
src.overlays+=Hair
In response to Falacy
Falacy wrote:
> mob/proc/Hair()
> var/obj/Hair=new()
> Hair.icon='GoldenSunHair3.dmi'
> Hair.icon_state=input(src,"Please Choose a Hair Type:", "Hair?") in icon_states(Hair.icon)
> src.hairColor=input(src,"What hair color do you want?", "Hair Color", src.hairColor) as color //You probably want to save their hair color too
> src.hairStyle=Hair.icon_state
> Hair.icon+=src.hairColor
> src.overlays+=Hair
>


I like this code, it looks nice and simple :D But it doesn't work x.x
In response to Mariahh
Mariahh wrote:
But it doesn't work x.x

Which part doesn't work?
In response to Mariahh
Loduwijk wrote:
BeignetLover wrote:
still not working, appreciate your attempt to help, though.

It is not working because you are not properly doing what was suggested to you, then, instead of showing what you attempted and asking for help, you say "it doesn't work"

Please, when someone gives you (...) help and you don't understand how to apply it, don't waste everyone's time by saying "thanks, but your help is no good" as that's basically what you're doing.

Obviously, you want to create something and possibly also learn. We also want you to succeed at learning and creating. When you don't know how to apply something, help us help you.

Now, show (...) your code (...) and hopefully someone will explain to you where your problem is, and, more importantly, why it is a problem. You have to have patience, learning this stuff has a steep learning curve, and you might have to go through several rounds of changing something and asking for more help and changing again and asking for more help.
In response to Falacy
In case anyone comes back to read this 50 yeas from now, the problem was that the Hair was on a lower layer than the player.