L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 22, 2008, 01:46:53 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Modules for older versions > 0.2.x Custom/Unofficial Modules > Topic: Colors module
Pages: [1] 2   Go Down
« previous next »
Print
Author Topic: Colors module  (Read 2462 times)
0 Members and 1 Guest are viewing this topic.
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Colors module
« on: January 26, 2006, 05: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, 06:07:57 AM by Alreadythere » Logged
Wolfbiter
BeBot Contributor
Apprentice
*******
Offline Offline

Posts: 141



WWW
Re: Colors module
« Reply #1 on: January 27, 2006, 04: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:
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, 04:14:51 AM by Wolfbiter » Logged

220 Doctor | 220 Adventurer | 220 Shade
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Re: Colors module
« Reply #2 on: January 27, 2006, 06:44:48 AM »

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

Didn't test either, but I can't see a single reason why it shouldn't work.
Logged
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: Colors module
« Reply #3 on: January 27, 2006, 09:36:42 PM »

Good one.

Will add to core when i find some more time.
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Re: Colors module
« Reply #4 on: March 22, 2006, 09:12:21 AM »

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, 09:21:49 AM by Alreadythere » Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Re: Colors module
« Reply #5 on: March 22, 2006, 09:26:26 AM »

Here a small example of how schemes could be used:

With
Code:
define_scheme("logon_message", "yellow");
in the constructor of the logon module, just use
Code:
$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.
Logged
phx49331
Freshman
*
Offline Offline

Posts: 2


Re: Colors module
« Reply #6 on: March 27, 2006, 07:05:06 PM »

Looking for the _player.php file
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Re: Colors module
« Reply #7 on: March 28, 2006, 04:18:09 AM »

Quote from: phx49331 on March 27, 2006, 07:05:06 PM
Looking for the _player.php file
Huh Huh
There is no line needing anything like in the module...
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Re: Colors module
« Reply #8 on: September 27, 2006, 07:42:48 AM »

Added file modified for the 0.3 branch of bebot, got exactly the same functionality.
Logged
Galdethi
Freshman
*
Offline Offline

Posts: 9


Re: Colors module
« Reply #9 on: December 13, 2006, 02: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?
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Re: Colors module
« Reply #10 on: December 13, 2006, 02: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.
Logged
Galdethi
Freshman
*
Offline Offline

Posts: 9


Re: Colors module
« Reply #11 on: December 13, 2006, 02:49:57 PM »

Ah thanks very much Smiley
Logged
Areteh
Rookie
**
Offline Offline

Posts: 23


Re: Colors module
« Reply #12 on: January 06, 2007, 06:20:26 AM »

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.)
Logged
Karsta
Freshman
*
Offline Offline

Posts: 16


Re: Colors module
« Reply #13 on: February 14, 2007, 08:16:55 AM »

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
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Re: Colors module
« Reply #14 on: February 14, 2007, 09:55:46 AM »

Quote from: Alreadythere on January 26, 2006, 05:31:31 AM
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:
function get_tablename($name)
{
return $name;
}

function define_tablename($name, $var1, $var2)
{
return $name;
}
Should help you.
Logged
Pages: [1] 2   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Modules for older versions > 0.2.x Custom/Unofficial Modules > Topic: Colors module
« previous next »
 
Jump to:  

Recent
Change text in remember "...
by gerborg
[November 21, 2008, 05:14:57 PM]

Log playtime from buddys ...
by Temar
[November 20, 2008, 10:33:57 AM]

Vote Core module and Simp...
by Temar
[November 19, 2008, 09:26:52 AM]

Restrict access for one m...
by Organizer
[November 19, 2008, 03:21:19 AM]

Custom / Revised Modules ...
by Elesar1
[November 17, 2008, 03:51:46 PM]

TWC
by Temar
[November 16, 2008, 11:39:12 AM]

Are there any FUN modules...
by Elesar1
[November 15, 2008, 07:39:15 PM]

Call to a member function...
by exxie
[November 15, 2008, 09:29:31 AM]

Ported Modules
by Alreadythere
[November 14, 2008, 06:10:07 PM]

cURL and other non-defaul...
by Temar
[November 14, 2008, 04:11:44 PM]
Stats
Members
Total Members: 1235
Latest: DDDepressionnn
Stats
Total Posts: 11037
Total Topics: 1496
Online Today: 18
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 0
Guests: 24
Total: 24

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.26 seconds with 28 queries. (Pretty URLs adds 0.034s, 4q)
Loading...