ID:1548094
 
Keywords: colors, text
You can use the code below to easily add colors to text in your games.

Worked example:
var/mytext = "Hello BYONDers"

I want Hello to be red and BYONDers to be blue.
var/mytext = "[fred]Hello[fend] [fblue]BYONDers[fend]"

End result:
src << mytext




This is the code you need to add to each dm file that uses colors. The colors you don't want to use can be missed out but fend is very important as it's what signals where a color stops.

// Colors
// Usage: var/mytext = "[fblue]hello[end]"

#define fblack "<font color=black>"
#define fsilver "<font color=silver>"
#define fgray "<font color=gray>"
#define fwhite "<font color=white>"
#define fmaroon "<font color=maroon>"
#define fred "<font color=red>"
#define fpurple "<font color=purple>"
#define ffuchsia "<font color=fuchsia>"
#define fmagenta "<font color=magenta>"
#define fgreen "<font color=green>"
#define flime "<font color=lime>"
#define folive "<font color=olive>"
#define fgold "<font color=gold>"
#define fyellow "<font color=yellow>"
#define fnavy "<font color=navy>"
#define fblue "<font color=blue>"
#define fteal "<font color=teal>"
#define faqua "<font color=aqua>"
#define fcyan "<font color=cyan>"
#define fend "</font>"
It's possible that the colors I've listed might not be all the colors you need, or aren't quite the colors you want. That leads to the question, how do I make my own colors?

It's very simple and all you need is a website that has a color picker on it. Like this one: http://www.thehtmlguide.com/color/

You'll find that it gives the color using a code starting with a # symbol. You don't need to know what that means, just that it's the color you chose.

Here's an example of me making my own color:



var/fskyblue    = "<font color=#7AAFDE>"


As you can see the only thing I changed was the name of color. Seeing as skyblue isn't on the list, I took the code I got from that website and put that in the place of the name. Also in front of the code was the # symbol to show I was choosing my own color.
You should be making those variables #defines, it would save on resources and be overall faster.
By far. Also, you might consider updating to CSS. You'll find that the <font> tag has largely been deprecated since the late 90s, and we should be using the <span> tag to define inline property changes.
I wouldn't worry too much about updating to CSS considering the only places this is gonna be visible is a richedit control and an IE7 control. =P
<span class="combat"></span>
<font color=#RRGGBB size="14pt"></font>

In the end, it's cleaner, and results in less communication whilst offering far more customization options.

In addition, we're in the leadup to an HTML5 client, so getting ourselves familiar with modern practices is going to be increasingly important in the coming year.

As it stands, maybe a dozen people in this community view browsers as anything other than useless, incompatible, ugly fluff, and of all the people that have stayed here, fewer yet understand javascript, much less are ready to transition to a webgl/dart enabled atmosphere.
In response to Ter13
Then make a tutorial on basic javascript/css use with the BYOND browser/outputs.
Due to the proximity of an HTML5 client, I'm going to be deferring that as a possibility until I can get my hands on the Dart API.

I would very much like to do a modern tutorial track for DM, though. I'd like to find an illustrator to get it into a more digestible format.
In response to Ter13
Don't forget finishing your 3D tutorial I've been waiting months for. That would be nice too.
It's not a huge difference, but using CSS is definitely the best choice. I've been using it for a while. Though I do need to update my chat system a bit, too.

Looking forward to seeing your tutorials and such as well, Ter13. I think it's great that you take the time to do so, and it could make a huge difference once the HTML5 client comes out.

On and off over the past year or two I considered doing tutorials and such for beginner programmers, since most of the existing ones are getting pretty old and might be missing a few things, but I've yet to feel skilled and confident enough to give that a whirl just yet. So, I'd definitely be interested in seeing a modern tutorial track come out.
In response to Nadrew
Nadrew wrote:
You should be making those variables #defines, it would save on resources and be overall faster.

Hey Nadrew I know it's been ages but I finally updated it to use #define.

Anyone still using variables won't really be put out at all but to keep tutorial code up to standard, it's now #defines.
Span classes would be ideal, for the reasons Ter stated. Cleaner, faster, etc. In fact you're more or less simulating span classes.