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: Custom Function Library  (Read 4776 times)

0 Members and 1 Guest are viewing this topic.

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Custom Function Library
« 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.



Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Custom Function Library
« Reply #1 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 ->
BeBot Founder and Fixer Kingpin

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Custom Function Library
« Reply #2 on: September 27, 2006, 10:22:48 pm »
Khalem: he likes to make things more complicating than they already are :P
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: Custom Function Library
« Reply #3 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

 

* 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: 288
  • 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