BeBot - An Anarchy Online and Age Of Conan chat automaton

General => Feedback and Suggestions => Topic started by: Glarawyn on September 26, 2006, 09:49:24 pm

Title: Custom Function Library
Post by: Glarawyn on September 26, 2006, 09:49:24 pm
Experience seems to show that development of the official BeBot is likely to lag behind what module creaters are going to come up with. So to better support module coders, I think there should be a "official" place to store functions that can be used by mutiple modules.

The idea is that the distributed BeBot (.zip, .tar.gz, svn, etc.) should never contain a lib-custom.php. The bot should create the lib-custom.php below if it doesn't exisit, but if lib-custom.php already exisits nothing should ever happen to it.

Code: [Select]
<?
// lib-custom.php - Custom Functions.
$custom = new Custom($bot);
$bot -> custom = &$custom;
// The Class itself...
class Custom
{ // Start Class
var $bot;

// Constructor: Hands over a referance to the "Bot" class.
function Custom (&$bot)
{
$this -> bot = &$bot;
}

// Custom Functions Below this line.

} // End of Class
?>

Module developers can add functions they reuse often in their modules to lib-custom.php and call them like: $this -> bot -> custom -> functionname(); When a module is announced, the author would included "add this to lib-custom.php."

A good function may make it's way from lib-custom.php to an official BeBot core module in the next stable release.


Title: Re: Custom Function Library
Post by: Khalem on September 27, 2006, 10:10:13 pm
Would it not be simpler to just provide the $bot -> custom and then have custom core modules merely hook into it by doing
Code: [Select]
$somecustom = new SomeCustom($bot);
$bot -> custom -> somecustom = &$somecustom($bot);

I don't see monolithic custom functions file as much of an improvement over todays situation of modifying Bot.php directly aside from the fact of avoiding having to reapply changes, and in any case i think separate files would be a better option while still allowing the modules to be called trough bot -> custom ->
Title: Re: Custom Function Library
Post by: Naturalistic on September 27, 2006, 10:22:48 pm
Khalem: he likes to make things more complicating than they already are :P
Title: Re: Custom Function Library
Post by: Glarawyn on September 27, 2006, 10:23:31 pm
I take no responsiblity for the crap that falls out of my mind when I'm short on sleep.

Unless it's one of those rare gems. Those I'll take credit for.  ;D
SimplePortal 2.3.7 © 2008-2024, SimplePortal