ID:139933
 
Quick Note: I currently have a stat panel set up to display the current RGB values so that i know if there getting changed.


Code: For Reference Sake
//The olay builder. launched on new char, load etc.
mob/proc/Overlay_Build() //This is a somewhat of a overlay builder so as to streamline saves.
var/L[0]
var/hair
var/eye
eye = 'Eyes_Base.dmi'
if(eye)
eye+=rgb(src.eye_red,src.eye_green,src.eye_blue)
L+= eye

switch(src.hair_type) //Define all hair types under this.
if(1)
hair='Hair_Kakashi.dmi'
if(2)
hair='Hair_Deidara.dmi'

if(hair)
hair+=rgb(src.hair_red,src.hair_green,src.hair_blue)
L+= hair


src.overlays=L


Code: Attempt #1
mob/verb/Zet(B as color)
var/list/Colours = ReadRGB(B) //From lummox iconproc lib + his guide
src.hair_red = "[Colours[1]]"
src.hair_green = "[Colours[2]]"
src.hair_blue = "[Colours[3]]"
src.Overlay_Build()

Results: The RGB values i have set (hair_red,green,blue) etc get set properly to the values i chose but the hair remains black (tried saving and loading where the colours are rewritten again remains a black hairstyle when the codes clearly denote a colour such as purple for example)


Code: Attempt #2
mob/verb/Fail()
var/list/color = ReadRGB(name_colour)
usr.hair_red = "[color[1]]"
usr.hair_green = "[color[2]]"
usr.hair_blue = "[color[3]]"
usr.Overlay_Build()

Results: For this test i pulled up "Crashed's" library for name/text colour changing and tried RGBing that value. same results as Attempt 1 where it outputs a hairdo thats meant to be purple but gives me a black hairdo when values denote the purple variables.


Code: Attempt #3
    haircolour_rgb
icon='colours.dmi'
icon_state="rgb"
Click(Hairgb as color)
var/list/Colours = ReadHSV(Hairgb)
usr.hair_red = "[Colours[1]]"
usr.hair_green = "[Colours[2]]"
usr.hair_blue = "[Colours[3]]"
usr.Overlay_Build()

Results: was actually my first attempt but doesnt matter, quite simply doesn't launch that windows palette lookalike thing


Code: Attempt #4
//Error received
runtime error: cannot read from list
verb name: Zet (/mob/verb/Zet)
source file: B. Creation.dm,482
usr: Midgetbuster (/mob/human/player)
src: Midgetbuster (/mob/human/player)
call stack:
Midgetbuster (/mob/human/player): Zet(null)
the haircolour rgb (/obj/HairSelection2/haircolour_rgb): Click("22", "main_creation.grid_haircolour", "icon-x=24;icon-y=18;left=1;dra...")

Results: Simply the above attempt put into a proc/verb and trying to launch on click. gives me an error (noted above in the DM tags)

Problem description: So as far as i can tell the code is stuffing up somewhere along the line or i just totally suck and am skipping something (id go with the sucking part) but as you can see by those im trying to make an option that will open up a RGB kind of selector so that a player can choose any kind of hair they want with a graphical interface (alongside an array of predefined choices)

Just having some real headscratchers on why the RGB values are to a purple colour but im getting a black colour.

Thanks in advance to all the experienced personnel who tolerate my noobyness i appreciate it greatly.


You are calling rgb() with three text strings as arguments, which will always return "#000000", or black. You need to give it numerical arguments.

Of course, you don't need to do this at all, as simply taking the result from "X as color" and adding it to overlays is enough. So, for example:

mob
var/hair_color
verb/select_hair_color(C as color)
hair_color = C
overlays += ('hair.dmi' + hair_color)
In response to Garthor
I guess that is one way of doing it but it would require me making all the pre-defined hairs that i currently have abolish the current system i have, although that isn't such a big deal i guess for a better method as you mentioned.

Current System
obj/HairSelection1 //Grabs and gets outputted to grid
Bald
icon = 'Hair_Kakashi.dmi' //Test hair
icon_state = "bald" //Simply placed here because new dmi does not need to be made (gives a "flick of the char's head with hair"
Click()
usr.hair_type = 0 //0 = bald
usr.Overlay_Build()

obj/HairSelection2
var
r=0
g=0
b=0
icon='colours.dmi'
haircolour1
icon_state="0,1"
r=0
g=0
b=0
Click()
..()
var/mod=0.5//intensity
usr.hair_red=round(src.r*mod)
usr.hair_blue=round(src.b*mod)
usr.hair_green=round(src.g*mod)
usr.Overlay_Build()


How would you call that on a click() command? cause it is giving errors. "bad icon operation" if launched through the click by linking it or not opening when placed directly as the click command.
In response to Midgetbuster
Again, instead of having three separate variables, just use one, and store the rgb() value directly. As in:

obj/HairSelection2
var/color
haircolor1
color = rgb(0,0,0)
In response to Garthor
Sorry, Yeah i got all that down im just trying to figure out how to get that code you mentioned above (X as Color) to work as a click command since there on a grid and for some reason it just doesn't launch that colour console.
In response to Midgetbuster
colour = input(...) as color
In response to GhostAnime
Tryed sticking that inside the Click(<here>) and also under the click both ways give a compilation error of a possible infinite cross reference loop.

EDIT: I ended up re-adding the crash colour library by Crashed and made it launch via a proc for the object click command and it works for the most part so i guess for the most part this is now resolved.

Extra Note: Iunno why but for some reason with the "X as color" thing code you gave earlier garthor the left hand side colours autowipe the overlay it adds the colour then just wipes them, but if you manually select the colours of that left side they work fine. just a weird error i saw.

Thanks to
Garthor
and
Ghost