ID:140628
 
Code:
        switch(input("What body shape?","Body Shape") in list ("oval","Cancel"))
if("oval")
usr<<"Cool..."
icon_state = "oval"
var/A = input("What red color? ( 0-255 or an error will occur )","Red")
icon += rgb(A,0,0)//problem here?


Problem description:
this is my first time using RGB and, rgb has no effect on my icon.
Gigimoi wrote:
Code:
>       switch(input("What body shape?","Body Shape") in list ("oval","Cancel"))
> if("oval")
> usr<<"Cool..."
> icon_state = "oval"
> var/A = input("What red color? ( 0-255 or an error will occur )","Red")
> icon += rgb(A,0,0)//problem here?
>

Problem description:
this is my first time using RGB and, rgb has no effect on my icon.

        switch(input("What body shape?","Body Shape") in list ("oval","Cancel"))
if("oval")
usr<<"Cool..."
icon_state = "oval"
var/A = input("What red color? ( 0-255 or an error will occur )","Red",0) as num //needs to have the "as num" on the end of it, otherwise it evaluates it as a string, not an integer.
if(A > 255){A = 255}
if(A < 0){A = 0}
icon += rgb(A,0,0)


Works for me!
In response to ArcaneDragonX
ahh, i see as num.... strings doubles intergers its all a big mess for me..

Question: is it possible to edit just a single overlay with rgb?
In response to Gigimoi
The problem was you did not have any arguments (which defined it as text input).

BTW, maybe you want to try the colour argument: "as color"

And no for the overlay ... you can always remove it, update the colour and add it back on though *shrugs*
In response to GhostAnime
quote:...you can remove it, update the colour...

how would i edit it if it does not exist?
In response to Gigimoi
You cannot modify an existing overlay. However, what you can do is remove the overlay you want to change, then immediately replace it with the altered version of the overlay; the one you want to display.

Gigimoi wrote:
how would i edit it if it does not exist?

Obviously we wouldn't tell you to edit the overlay itself, as it has been told that editing an overlay is impossible. Rather, you would edit the data used to represent the overlay's graphic, so it now represents the changed graphic which you desire. Then, while keeping all of the previous overlay's properties (except the icon/state, which you want to change) you add that to overlays.

You can combine this with the ability to loop through the overlays list and access (read-only) the overlay object's properties, in order to easily create quick overlay-altering effects.
//for the sake of this example, we'll add green to the color\
of every overlay.


atom/proc/Modify_Overlays()
var/image/img = new //we use this to add new overlays
for(var/image/X as anything in src.overlays)
//load the same graphical data used in the overlay \
into a new icon object, which we can manipulate.

var/icon/I = new(X.icon)
I.Blend(rgb(0,255,0)) //add green

/*now, we give our dummy image object (you can also use any atom)
the same visual properties as the current overlay has, except the icon, of course*/

img.icon = I
img.icon_state = X.icon_state
img.dir = X.dir
img.layer = X.layer
img.pixel_x = X.pixel_x
img.pixel_y = X.pixel_y

src.overlays -= X //remove the old, less-green overlay.
src.overlays += img //add in our new /image which has a green icon
//(you can repeat the same with underlays for a more complete effect)


EDIT: As for modifying only a single overlay, if you still have source datatype used to add it, it's only a matter of using it to remove the overlay from overlays, then add an overlay using the changed appearance you want. If you don't have the source datatype anymore, you can also loop through the overlays list like above, but of course you'll need to identify the specific overlay you want to replace in a safe way. An identification can be done by checking the overlay object's visual properties such as icon, icon_state etc, and you can also take advantage of the fact 'visual properties' includes vars such as name, suffix, desc.
mob/verb/add_overlay()
var/image/I = new('overlay.dmi',,"green_hat")
I.name = "overlayID_1234" //put some unique identifier here
src.overlays += I

mob/verb/replace_with_red_hat()
var/image/I = new('overlay.dmi',,"red_hat")
src.replace_overlay("1234",I)

atom/proc/replace_overlay(ID,replacement)
//I keep this one simple as there was already a complete example before
for(var/obj/X as anything in src.overlays)
if(X.name == "overlayID_[ID]")
src.overlays -= X
src.overlays += replacement