ID:139790
 
Code: Character Preview Clickable Colours.
        colourtable
red
icon = 'Colour.dmi' // color table
icon_state = "red"
Click()
if(usr.iconset["Hair"]==0)
usr << "You haven't selected a hairstyle yet!"
return
var/L
if(usr.iconset["Hair"] == 1)
L = 'Hairichigo.dmi'
if(usr.iconset["Hair"] == 2)
L = 'Hairrenji.dmi'
if(usr.iconset["Hair"] == 3)
L = 'Hairhitsugaya.dmi'
if(usr.iconset["Hair"] == 4)
L = 'Hairkira.dmi'
if(usr.iconset["Hair"] == 5)
L = 'Hairafro.dmi'
if(usr.iconset["Hair"] == 6)
L = 'Hairaizen.dmi'
if(usr.iconset["Hair"] == 7)
L = 'Hairamelie.dmi'
if(usr.iconset["Hair"] == 8)
L = 'Hairgin.dmi'
if(usr.iconset["Hair"] == 9)
L = 'Hairhinamori.dmi'
if(usr.iconset["Hair"] == 10)
L = 'Hairlisa.dmi'
if(usr.iconset["Hair"] == 11)
L = 'Hairrukia.dmi'
if(usr.iconset["Hair"] == 12)
L = 'Hairsado.dmi'
if(usr.iconset["Hair"] == 13)
L = 'Hairukitake.dmi'
if(usr.iconset["Hair"] == 14)
L = 'Hairuryuu.dmi'
if(usr.iconset["Hair"] == 15)
L = 'Hairzaraki.dmi'
if(usr.iconset["Hair"] == 16)
L = 'IsshenComplete.dmi'
if(usr.iconset["Hair"] == 17)
L = 'MatsumotoComplete.dmi'
if(usr.iconset["Hair"] == 18)
L = 'JidanbouComplete.dmi'
if(usr.iconset["Hair"] == 19)
L = 'YoruichiComplete.dmi'
L += rgb(160,0,0)
usr.hairover = rgb(160,0,0)
var/T = image(L, usr)
usr.client.images += T


Problem description: I get about 1128 compile errors, 7 warnings. The first error gives that I did define L but it's not used.

okie dokies.

lets start of with this one.. as far as i know.. an if statement for click would need to actually be Inside the click() proc.. you have it on the same line. so if you read the compile error it would most likely say L is undefined.

and as you mentioned L is defined but not used for that very reason.

Furthermore your code is way to long and pretty much an impractical use..

heres a snip. that may prove more usefull.

mob/var/colour_hair = "#000000"
mob/var/type_hair = "Bald"

var/list/hair_types = list("bald" = 'blank.dmi', "test1" = 'Hair_test1.dmi', "test12" = 'Hair_test12.dmi')

mob/proc/Build_Icons()
var/L[0]
var/hair = hair_types[type_hair || "bald"] + colour_hair
var/eye = 'Eyes_Base.dmi' + colour_eye
L += hair
L += eye


src.overlays = L
//that above should pretty much cover the adding and stuff with a mere 2 mob variables a mob proc and a list that holds all the types. (beats having 4563252 if's right?)

//next up a random clickable object
obj/creationstuff/HairSelection2
var
colour
icon='colours.dmi'
Black
icon_state="1"
colour = "#000000"
Buttercup
icon_state="15"
colour = "#F2E1A9"
Twilight
icon_state="16"
colour = "#177B9F"
Sweet_Leaf
icon_state="17"
colour = "#C2CB93"
Click()
..()
usr.colour_hair = src.colour
usr.Build_Icons()

RGB
icon='colours.dmi'
icon_state="rgb"
Click()
colour = input("Choose a custom hair colour. Then press OK (NOTE: If your colour selection is hovering over any of the objects that object command will also be called resulting in changed settings.)","Character Creation") as color
usr.colour_hair = src.colour
usr.Build_Icons()


tada. hope that helps.

EDIT: As you may have noticed i have eyes base there aswell. this is because its pretty much a direct rip from my source with some crud removed for readability. (and i dont intend to remove it with this edit)
In response to Midgetbuster
Thanks man, edited my code to the likes of yours and it works now.