Colors

From Bebot Wiki 2
Revision as of 21:50, 16 September 2020 by B3b0tUzR (talk | contribs) (Created page with 'Introduction: The Colors module allows easy handling of colors in all bot parts, either by using pre-defined colors directly or by using color schemes which can be customized du…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Introduction:

The Colors module allows easy handling of colors in all bot parts, either by using pre-defined colors directly or by using color schemes which can be customized during runtime. To add a color to any bot output only a color tag needs to be added. Color tags:

Color tags are string of the format ##name##. name can be either the name of a pre-defined color or the name of a color scheme. All legal color tags will be replaced with the tags required by AO before sending the output. Unknown tags won't be touched though. In addition to the tags for colors and schemes the special tag ##end## allows to end a colored substring. Pre-defined colors:

The colors module comes with a large selection of pre-defined colors which can be used either directly or in color schemes. Those colors are global over all bots in the default setting of the module. If any additional colors are needed, they can be added by using the function $this → bot → colors → define_color($name, $code). $name is the name give to the new color, $code is the hexcode for the color as used by the font tag, together with the leading #. The color red is defined by define_color(“red”, “#FF0000”) for example. Color schemes:

To support customization by the users without changing the source code of modules the Colors module supports color schemes. A color scheme is an alias for a color, pointing to one of the pre-defined colors. Instead of using the color directly the alias is entered into the text. A scheme is either module dependant or global. Schemes are saved per bot in the default setting of the module, so changes of schemes in one bot won't influence the schemes of another bot. Defining schemes:

To define a scheme the function $this → bot → colors → define_scheme($module, $scheme, $color_name) is used. $module is either global or the name of the module defining the scheme. $scheme the name of the scheme, $color_name the name of the pre-defined color to use for this scheme. The combination of module and scheme has to be unique. To access the scheme in the output it's only required to add a tag of the format ##module_scheme## to the output. This gets replaced like any other color tag too. Global schemes:

Global schemes can be accessed in two ways. Either by ##global_name## or just by ##name##. Naming rule:

The color GUI assumes that all names for modules, schemes and colors only contain the letters A to Z in upper or lower case.