Archive > 0.2.x Custom/Unofficial Modules

Colors module

(1/5) > >>

Alreadythere:
As I've grown tired of updating colors in the code and then needing to restart bots, I moved them into a table. And added some functions for getting the colors, setting them during runtime, and listing all existing colors.

I've made this to a core module, as almost all of my own modules depend on the colors -> get() function now.

If you want to add your own colors - just use the get() function with the new name, and then use !colors set newcolor code to set it, the get() function adds entries for new unknown colors defaulting to #000000 as color code (black).

File, save as .php

Note: this is a backported version of the 0.3 colors module. This version won't be supported any further as standalone module.

Update 2006-01-27:
- added colorize() function by Wolfbiter

Update 2006-03-11:
- added color schemes, see the post for more details
- get() no longer adds unknown colors as black, but still returns them as black
- get() and colorize() use either a defined color, or a defined scheme. If there is a scheme and a color of the same name, the color is used
- added functions define_color(), define_scheme() and define_color_scheme()
- added lot's of new predefined colors

Update 2006-09-27:
- added bebot 0.3 version to downloads

Update 2006-12-28:
- removed bebot 0.3 version as SVN contains a more advanced one

Update 2007-02-15:
- backport of SVN version

Wolfbiter:
I really like this idea.. I was beginning to look into coding wth _Colors.php.. but this is better.
But I'll suggest another function...


--- Code: ---function colorize($color,$text) {
$col = $this->bot->db->select("SELECT code FROM ".$this->bot->get_tablename("colors")." where name='".$color."'");
if (!empty($col))
return "<font color=".$col[0][0].">".$text."</font>";
else
return $text;
}

--- End code ---

To add color in a different way than with get()

(wrote this on the fly, so it may not work)

Alreadythere:
Nice idea, added and updated.
Just modified the layout to my liking (more spaces basically :) )

Didn't test either, but I can't see a single reason why it shouldn't work.

Khalem:
Good one.

Will add to core when i find some more time.

Alreadythere:
Vastly updated.

Main change: added support for color schemes.
Schemes are saved in it's own table, and point to a color name. The idea is to use the schemes for color settings in modules, and let them point to a general table with color names. The color table should stay static, if the bot user wants to change a color, he just changes the scheme entry.

The main goal is to seperate used colors shown in the bot from color definitions. The color definitions can always stay the same (colors don't change after all), if someone doesn't like the color of a setting, he can just edit the scheme used for that setting. Only the modules using that scheme are affected.

For the color schemes I propose as naming convention modulename_schemename, so names are unique, and it's easy to see which module uses which schemes.

There are 6 basic schemes defined, 3 color aliases (so grey = gray), and schemes for highlight, tell and group messages.

I plan on adding a GUI to change the colors of schemes.

New/changed functions:
- get() doesn't add unknown colors anymore, it just returns a setting for black
- get() and colorize() use either a defined color, or a defined scheme. If there is a scheme and a color of the same name, the color is used
- define_color(colorname, colorcode) adds a new color
- define_scheme(schemename, colorname) adds a new scheme, with colorname pointing to an entry in the color table
- define_color_scheme(schemename, colorname, colorcode) adds a new scheme and a new color at once

Lot's of predefined colors added, stolen here

For existing user of this module: Except for some changed color definitions, there is no need to change any code, the function calls are all the same still.

Navigation

[0] Message Index

[#] Next page

Go to full version