BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: Alreadythere on January 26, 2006, 11:31:31 am

Title: Colors module
Post by: Alreadythere on January 26, 2006, 11:31:31 am
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 (http://www.m8y.de/ao/bebot/Colors.phps), 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 (http://bebot.link/index.php/topic,312.msg2016.html#msg2016) 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
Title: Re: Colors module
Post by: Wolfbiter on January 27, 2006, 10:05:11 am
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: [Select]
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;
}

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

(wrote this on the fly, so it may not work)
Title: Re: Colors module
Post by: Alreadythere on January 27, 2006, 12:44:48 pm
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.
Title: Re: Colors module
Post by: Khalem on January 28, 2006, 03:36:42 am
Good one.

Will add to core when i find some more time.
Title: Re: Colors module
Post by: Alreadythere on March 22, 2006, 03:12:21 pm
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 (http://forums.ign-central.de/thread.php?threadid=137&sid=7a82fcf0ddf0976aca356e0d049633b3)

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.
Title: Re: Colors module
Post by: Alreadythere on March 22, 2006, 03:26:26 pm
Here a small example of how schemes could be used:

With
Code: [Select]
define_scheme("logon_message", "yellow");in the constructor of the logon module, just use
Code: [Select]
$logonstr = $this -> bot -> colors -> colorize("logon_message", "whatever should be shown here");to create the correctly colored logon string.

And if some user wants the message to be blue, he just changes logon_message to blue in the database (at least as long as I don't get around to add a GUI), and the logons are shown in blue, without any effect to modules using yellow for some coloring.
Title: Re: Colors module
Post by: phx49331 on March 28, 2006, 02:05:06 am
Looking for the _player.php file
Title: Re: Colors module
Post by: Alreadythere on March 28, 2006, 11:18:09 am
Looking for the _player.php file
??? ???
There is no line needing anything like in the module...
Title: Re: Colors module
Post by: Alreadythere on September 27, 2006, 02:42:48 pm
Added file modified for the 0.3 branch of bebot, got exactly the same functionality.
Title: Re: Colors module
Post by: Galdethi on December 13, 2006, 08:08:31 pm
Fatal error: Call to undefined method Bot::get_tablename() in D:\orgbot\modules\
Colors.php on line 11


Got this after trying to install, any idea why?
Title: Re: Colors module
Post by: Alreadythere on December 13, 2006, 08:45:55 pm
Added some code snippet in first post to solve your problem.

Add it into your bot class (Bot.php).

I'm right now reworking this module some to add it to the 0.3 version.
Title: Re: Colors module
Post by: Galdethi on December 13, 2006, 08:49:57 pm
Ah thanks very much :)
Title: Re: Colors module
Post by: Areteh on January 06, 2007, 12:20:26 pm
help file.  (yeah, I'm spamming them a bit, just figured since I'm writing them for my own bots, I may as well share.)
Title: Re: Colors module
Post by: Karsta on February 14, 2007, 02:16:55 pm
hmmm, i keep getting this error
Fatal error: Call to undefined method Bot::get_tablename() in D:\Program files\F
uncom\kbot\BeBot\core\colors.php on line 11

got   v.0.2.10 - PHP 5.1.4
Title: Re: Colors module
Post by: Alreadythere on February 14, 2007, 03:55:46 pm
Note: this module uses my get_tablenames function, and depends on my custom rights management to set access rights.
Just add the following lines somewhere inside your bot class:
Code: [Select]
function get_tablename($name)
{
return $name;
}

function define_tablename($name, $var1, $var2)
{
return $name;
}
Should help you.
Title: Re: Colors module
Post by: Karsta on February 14, 2007, 07:30:03 pm
doesnt help, same error still
Title: Re: Colors module
Post by: Alreadythere on February 14, 2007, 09:27:02 pm
Did you add those lines inside the Bot class?

That's were the module expects them.
Title: Re: Colors module
Post by: Karsta on February 15, 2007, 08:52:44 am
yep, inside bot.php
Title: Re: Colors module
Post by: Alreadythere on February 15, 2007, 12:09:08 pm
Hm.

Did a backport of the 0.3 version, it should run without any modifications to the bot class. Though it won't offer the advantages of global colors as 0.2 doesn't support table prefixes.
Title: Re: Colors module
Post by: Karsta on February 15, 2007, 03:50:37 pm
hmmm, now colors.php works, but get this from level.php


Fatal error: Call to a member function define_color() on a non-object in D:\Prog
ram files\Funcom\kbot\BeBot\modules\Level.php on line 40

http://bebot.link/index.php/topic,580.0.html using this one
Title: Re: Colors module
Post by: Alreadythere on February 21, 2007, 11:32:08 am
Did you put the colors module into the core/ directory? It has to be loaded before the level.php or it can't work.
Title: Re: Colors module
Post by: Karsta on February 22, 2007, 04:26:14 pm
hmmm, this is wierd

i did put in core as u can see in BeBot\core\colors.php on line 11

but, now i got orginal bot.php and edited it and redownloaded others, and it WORKS

:)

so thx for all the help, finally it works
time to get new modules and problems :D
Title: Re: Colors module
Post by: Hectares on March 16, 2007, 05:23:54 am
Ok I put the colors.php into the core directory but it doesn't seem to be loading. I get no new commands and when I startup my bot I get no errors. Any ideas?
Title: Re: Colors module
Post by: Alreadythere on March 16, 2007, 09:54:40 am
Actually that's right, the colors module itself only offers functions to other modules. It doesn't offer any commands.

I'll try to backport the ColorsInterface.php out of the SVN to 0.2 later today, that's the interface to change colors of schemes. Of course that only is any help if any module is using schemes.
Title: Re: Colors module
Post by: versatos on September 28, 2011, 07:51:49 pm
i know this is a very late reply

but can someone provide me this color.php
SimplePortal 2.3.7 © 2008-2024, SimplePortal