ID:165131
 
Ok, this is pretty sad but... I'm not sure how to put an icon state on a variable that has an icon... This is used when you click on a turf, so what i'm doing now is changing the icon state of the turf
var/hair='hair.dmi'; icon_state="Short"
Any ideas?
Look up and use the icon() proc to create an /icon object with the wanted icon_state and/or direction (and it'd come in handy to look up the 'icon' entry as well as related ones too).
In response to Kaioken
mob/var/hair
turf
hair
icon='hair.dmi'
icon_state="Bald"
Click()
alert(usr,"Select a hair style.")
var/select=input("","") in list("Spikey","Bald","Short")
switch(select)
if("Spikey")
src.icon_state="Spikey"
var/red = input("What color red","select") as num
var/blue = input("What color blue","select") as num
var/green = input("What color green","select") as num
var/hair=icon('hair.dmi',"Spikey")
hair+=rgb(red,green,blue)
usr.overlays+=hair
usr.hair=hair
src.icon=hair
if("Bald")
src.icon_state="Bald"
if("Short")
src.icon_state="Short"
var/red = input("What color red","select") as num
var/blue = input("What color blue","select") as num
var/green = input("What color green","select") as num
var/hair=icon('hair.dmi',"Short")
hair+=rgb(red,green,blue)
usr.overlays+=hair
usr.hair=hair
src.icon=hair
Yeah, so once I tried the icon procedure, it gives me this error: runtime error: <font color=red> type mismatch
proc name: Click (/turf/hair/Click)
usr: Speedro (/mob)
src: the hair (4,8,2) (/turf/hair)
call stack:
the hair (4,8,2) (/turf/hair): Click(the hair (4,8,2) (/turf/hair))</font color=red>

The problem is, i'm not too good at reading these and understanding so i'm kind of lost (which is very fustrating).
In response to Beatmewithastick
bump
In response to Beatmewithastick
Perhaps this is what you're looking for?

mob
var/icon/hair


and probably this is what you want to do...

   usr.hair = icon('hair.dmi', "Short")
In response to Beatmewithastick
Which line is it referring to?
In response to Kaioken
Kaioken wrote:
Which line is it referring to?

Hmm? What do you mean? If you mean what i think you mean, you mean that when does the error occur? That's probably not what you mean - but it occurs after I finish putting in a number for red green and blue.
In response to Goten84
No, that still gives the same error.. :/
In response to Beatmewithastick
put this anywhere in the code, then the error will tell you which line of coding is breaking (press Ctrl+G to go to a specific line)

#define DEBUG
In response to Chase_Hammer
But that's just the thing, I know where the error is coming from already, I just need to know how to get the var to hold the icon along with the icon state. It works fine when I don't try to add an icon state to the variable, but I need one there.
In response to Beatmewithastick
if it were me i would make a obj with the icon and state you wish and then just have the var hold the obj/turf/mob...of course if there were tons of icons/states then this wont work lol.

and src.hair = icon('hair.dmi',"short") doesnt work?
In response to Chase_Hammer
Compile errors appear the same in debug mode, it just affects alerts at runtime. Also, you can just double-click on an error line in the error window to jump to that place in the code, rather then using CTRL-G manually.
In response to Beatmewithastick
Well, >_> I took the lazy quick way in my last post since you didn't specify the actual error line, but it's obviously the hair+=rgb(red,green,blue) line. Look up 'icon arithmetic' in the DM Reference. The method of using operators on icons is being phased out, and works on icon files, not /icon objects. That's why you get a type-mismatch error, since += may not be used with the '/icon object' type, only numbers, lists etc.
Use the icon.Blend() proc instead.
Also, you have a lot of repeating code over there in the switch() cases... just farm it out to outside the switch() so you have it once.
In response to Kaioken
hair = Blend('hair.dmi',function=ICON_OVERLAY)


Umm, the blend procedure doesn't exsist??? >_>

I wish the reference would explain things in baby words, I don't understand the slightest thing it's saying >_>
In response to Beatmewithastick
Kaioken wrote:
Use the icon.Blend() proc instead.

Gah. You can at least look around before posting, there are countless posts on this.