ID:169643
 
mob/proc/SwapColor()
if(!client) return
var/cc,ac
cc = input(src, "What clothing color do you want?","Clothes Color") as null|anything in colorlist
if(!cc || !client) return
usr<<"<b>Your Clothes are <font color =[cc]><u>[cc]</u></b></font>"
ac = input(src, "What accessory color do you want?","Accessory Color") as null|anything in colorlist
usr<<"<b>Your Accessories are <font color =[ac]><u>[ac]</u></b></font>"
if(!ac || !client) return
clothes_color = colorlist[cc]
accessory_color = colorlist[ac]
BuildIcon()

mob/proc/BuildIcon()
var/icon/I = new('sage.dmi')
I.SwapColor("#00ab47",clothes_color)
I.SwapColor("#fff",accessory_color)
icon = I
var
clothes_color = rgb(0,171,71)
accessory_color = rgb(255,255,255)


how can i use more than 1 icon with icon states?
SwapColor() will affect all icon_states in the icon, so that shouldn't be a problem.

However what is a problem is your HTML. You must never ever do this:

<font color =[cc]>


Totally wrong. Never put a space between the attribute and the value. It should look like this:

<font color=[cc]>


You also shouldn't be closing the <b> tag until after the <font> tag closes, because <b> was opened first. This is an illegal overlap.

Lummox JR
can i plase have an example, I'm not that great of a coder but this is the last thing i need on my login() code. Im guessing when i login i have to set rgb vars to each icon state then call buildicon but im still confused.
In response to Thedarkavenger
I'm not sure what you mean about the icon_states, since using SwapColor() on an icon will affect all states in the icon. It looks like you copied and pasted this code from an example I posted elsewhere, but added the screwed-up HTML later. This is fairly self-explanatory code, except it does make certain assumptions about which colors will be swapped for which purposes. Since that part is easy to change I'm guessing that's not the problem you're having--but what is?

Lummox JR
In response to Lummox JR
thats my other key.
i just want when i login choose a class(with the icon) then choose the icon_state of the icon then a switch(input to change the colors, im having trouble with using it on more than 1 icon.
In response to Thedarkavenger
nevermind about icon states i just realized swapcolor swaps all states. Can you show me how to use it with multiple icons at login. I changed the icon states into individual icons.
In response to Thedarkavenger
Thedarkavenger wrote:
nevermind about icon states i just realized swapcolor swaps all states. Can you show me how to use it with multiple icons at login. I changed the icon states into individual icons.

I still don't get what you mean when you're asking how to do this with multiple icons. The example you're working from already handles multiple icons; it handles two.

Lummox JR
In response to Lummox JR
(bump)
I meant how can you apply that when i make a login code that lets you choose multiple icons like warrior,wizard stuff like that. So when i choose the class icon it lets me use it on different icons.
In response to Thedarkavenger
Thedarkavenger wrote:
(bump)
I meant how can you apply that when i make a login code that lets you choose multiple icons like warrior,wizard stuff like that. So when i choose the class icon it lets me use it on different icons.

I don't see why this should be throwing you. Just add a var that says what the default icon for this particular character is, and use that as the base in BuildIcon(). It's a pretty quick adjustment, really.

Lummox JR
In response to Lummox JR
example?
In response to Thedarkavenger
No, no example. You need to actually try to figure this out at some point. What you're asking is so simple that it should have been a breeze to handle in the first place if you'd only bothered to think it through. And what I just told you is more than adequate for you to know what to do next.

Look, I'm not just gonna hand you more code. It's no good handing somebody code if they can't figure out how to modify it when they need to later on. This is a very simple tweak, and I already told you exactly what you need to do. In fact, let's deconstruct it.
Just add a var that says what the default icon for this particular character is...
Now I'm pretty sure that means you have to do something like create a new var, and give it a value of some sort. And I'm guessing you might have to use that var later on. Let's find out where.
...and use that as the base in BuildIcon().
Hrm. The base. That would mean the icon we start with in BuildIcon() before swapping colors, wouldn't it? So then, the icon in that var will be used as a starting point.

So let's review:

  • Create a new var.
  • Give it a starting value, the default icon for this character.
  • Use that value as the base icon in BuildIcon().

    Lummox JR
In response to Lummox JR
thanks, I have it set to 22 diferent icons and my character selection works.