ID:1682165
 
Code:
        DblClick()
var/c = input("What would you like to purchase? Everything is 10 Ryo today! You have [usr.ryo]") in list ("T-Shirt","Fishnet","Tuxedo","Sandals","Bandages","Cloak","Pants","Cancel")
if(c=="T-Shirt")
if(usr.ryo<10)
return
if(usr.ryo>=10)
usr.ryo-=10
var/obj/clothing/p = new/obj/clothing/Shirt
usr.contents:Add(p)
var/r = input("How much red?") as num//set its red amount
var/g = input("How much green?") as num//set its green amount
var/b = input("How much blue?") as num//set its blue amount
p += rgb(r,g,b)


runtime error: type mismatch: T-Shirt (/obj/clothing/Shirt) += "#640014"
proc name: DblClick (/mob/Clothing_Seller/DblClick)
source file: Vendor.dm,81
usr: Character (/mob)
src: Clothing Seller (/mob/Clothing_Seller)
call stack:
Clothing Seller (/mob/Clothing_Seller): DblClick(GrassD (66,187,4) (/turf/nturfs/GrassD), "default.map1", "icon-x=33;icon-y=36;left=1;scr...")

When I attempt to colour the T-Shirt, it spits out that error. What am I doing wrong to cause this?
You're adding a text color value to a shirt object. Instead, set the shirts color var.

p.color = rgb(r,g,b)


EDIT:
You really shouldn't be using the 'Select r, b, g' method of setting a color either.

var/newColor = input(usr, "Select New Color") as color|null
if(newColor)
p.color = newColor
In response to Flick
I never knew there was such an innovative way to do that XD.

I need to get with the times. Thank you very much.

EDIT: The colours won't change to the newColor.
Kboy33 wrote:
Code:
>       DblClick()
> var/obj/clothing/p = new/obj/clothing/Shirt
> usr.contents:Add(p)
>



No, I don't like this. This would be better (for your future info):
var/obj/clothing/Shirt/p = new(usr)


When defining variables, you have: var/_path_/_varname_. When you do new() with no /path defined after it (ex: new /path), it will use the /path in the variable (here: /obj/clothing/Shirt)

The argument of new() is the location. By specifying usr, the shirt will be placed in the usr's content.

If you had no point for a variable (just creating an item instance), just do: new /path(Loc)
You need to apply the color to p's icon, rather than p itself:

// Example.
mob/verb/Hulk()
src.icon += rgb(0, 255, 0)

A thing to keep in mind (since Flick mentioned simply setting p.color) is that adding a color directly to an atom's icon and modifying the color variable will change the appearance of the icon in different ways. I don't recall the proper terms for what they do (additive and multiplicative?) though.
atom.color is a multiplier, which works for white icons. Darker pixels are less affected.

Black icons would have to use color addition or something.
In response to LordAndrew
Applying the color to p.color should work fine, though depending on what you are doing with the object, changing the icon itself might be a better choice. You do need to make sure your objects icon is mostly white in order for it to look the correct color.

EDIT: Yeah, what he said ^
I have a bandages icon which is mostly white, and it's colour doesn't change when I use this either. Are there any alternatives? (It'd also be preferable not to change the icons colour in the file)
In response to Kboy33
You can look at the icon procs which can change colours like icon.Blend() and icon.SwapColor()

There are also old demos/libraries from Lummox JR such as IconColor and IconProcs