ID:178793
 
Whats wrong with that??

var/CurrentColor = rgb(0,0,0)

//Input Red
var/Red = input("Set Red (0-255)","Set Color", 0) as num

//Consider min/max (0/255)
if(Red < 0)
Red = 0
else if(Red > 255)
Red = 255

NewColor = rgb(Red,0,0)

//Set current Red to Color
SwapColor(CurrentColor, NewColor)
</0>
Sabertooth wrote:
Whats wrong with that??

var/CurrentColor = rgb(0,0,0)

//Input Red
var/Red = input("Set Red (0-255)","Set Color", 0) as num

//Consider min/max (0/255)
if(Red < 0)
Red = 0
else if(Red > 255)
Red = 255

NewColor = rgb(Red,0,0)

//Set current Red to Color
SwapColor(CurrentColor, NewColor)

SwapColor is a predefined proc for an icon object. You are calling it as if it were a global proc, which it is not.
In response to Skysaw
How would I call it in the proper way then?
In response to Sabertooth
Sabertooth wrote:
How would I call it in the proper way then?

It would help if you explained exactly what you want to do here. I couldn't tell from the example.
In response to Skysaw
I wanna let the players set thier Icon's color.
If you can't help with my code, can you give me a quick exemple that uses the SwapColor proc properly?
In response to Sabertooth
Try using the rgb() proc:

mob/verb/Red_icon()
usr.icon += rbg(255,0,0)
In response to Sabertooth
Sabertooth wrote:
I wanna let the players set thier Icon's color

The easiest way to do this is not with SwapColor. It would be like this:
var/icon/ic=new('player.dmi')
ic.Blend(rgb(r,g,b),ICON_MULTIPLY)
src.icon=ic // if src is the player

Lummox JR
In response to Nadrew
Nadrew wrote:
Try using the rgb() proc:

> mob/verb/Red_icon()
> usr.icon += rbg(255,0,0)
>


Wouldn't that change other colors on the Icon? Actually there's some colors that must remain as they are...
In response to Sabertooth
The post by Lummox shows you how to call icon procs use that as your guide.
In response to Sabertooth
Sabertooth wrote:
Wouldn't that change other colors on the Icon? Actually there's some colors that must remain as they are...

If you're looking to change just one color, then I guess SwapColor() would be the way to go. (However, a better way is to use two icon files, or two different states of an icon, and add the unchanged one to the colored one. That would let you use shading details.)
var/icon/ic=new('player.dmi')
ic.SwapColor(rgb(255,0,0),rgb(r,g,b))
src.icon=ic

To use a 2-icon format like I suggested, try something like this:
var/icon/ic=new('player.dmi')
var/icon/ic2=new('player_highlight.dmi')
ic.Blend(rgb(r,g,b),ICON_MULTIPLY)
ic.Blend(ic2,ICON_ADD)
src.icon=ic

The highlight icon can include colors you don't want to change (corresponding pixels in the other icon should be black), or effects like light reflecting from the surface where you might want to add a small amount of white (via a dark gray in the highlight) on top of a colored segment.

Lummox JR
In response to Nadrew
Hmm I get a runtime error: Cannot execute null.SwapColor() Though everything seems fine. I will mess with my code later to fix that. You were all of great help, thank you :)