collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Colors module  (Read 39582 times)

0 Members and 2 Guests are viewing this topic.

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Colors module
« 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, 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
« Last Edit: February 15, 2007, 12:07:57 pm by Alreadythere »

Offline Wolfbiter

  • Contributor
  • *******
  • Posts: 149
  • Karma: +0/-0
    • KAZE
Re: Colors module
« Reply #1 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)
« Last Edit: January 27, 2006, 10:14:51 am by Wolfbiter »
Too many toons.

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Colors module
« Reply #2 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.

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Colors module
« Reply #3 on: January 28, 2006, 03:36:42 am »
Good one.

Will add to core when i find some more time.
BeBot Founder and Fixer Kingpin

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Colors module
« Reply #4 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

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.
« Last Edit: March 22, 2006, 03:21:49 pm by Alreadythere »

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Colors module
« Reply #5 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.

Offline phx49331

  • BeBot Rookie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Colors module
« Reply #6 on: March 28, 2006, 02:05:06 am »
Looking for the _player.php file

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Colors module
« Reply #7 on: March 28, 2006, 11:18:09 am »
Looking for the _player.php file
??? ???
There is no line needing anything like in the module...

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Colors module
« Reply #8 on: September 27, 2006, 02:42:48 pm »
Added file modified for the 0.3 branch of bebot, got exactly the same functionality.

Offline Galdethi

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Colors module
« Reply #9 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?

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Colors module
« Reply #10 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.

Offline Galdethi

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Colors module
« Reply #11 on: December 13, 2006, 08:49:57 pm »
Ah thanks very much :)

Offline Areteh

  • BeBot User
  • **
  • Posts: 23
  • Karma: +0/-0
Re: Colors module
« Reply #12 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.)

Offline Karsta

  • BeBot User
  • **
  • Posts: 28
  • Karma: +0/-0
Re: Colors module
« Reply #13 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

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Colors module
« Reply #14 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.

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 279
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal