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
-
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
-
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...
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)
-
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.
-
Good one.
Will add to core when i find some more time.
-
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.
-
Here a small example of how schemes could be used:
With
define_scheme("logon_message", "yellow");
in the constructor of the logon module, just use
$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.
-
Looking for the _player.php file
-
Looking for the _player.php file
??? ???
There is no line needing anything like in the module...
-
Added file modified for the 0.3 branch of bebot, got exactly the same functionality.
-
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?
-
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.
-
Ah thanks very much :)
-
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.)
-
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
-
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:
function get_tablename($name)
{
return $name;
}
function define_tablename($name, $var1, $var2)
{
return $name;
}
Should help you.
-
doesnt help, same error still
-
Did you add those lines inside the Bot class?
That's were the module expects them.
-
yep, inside bot.php
-
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.
-
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
-
Did you put the colors module into the core/ directory? It has to be loaded before the level.php or it can't work.
-
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
-
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?
-
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.
-
i know this is a very late reply
but can someone provide me this color.php