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: Tranferring data between modules  (Read 7783 times)

0 Members and 1 Guest are viewing this topic.

Offline onekman

  • BeBot Rookie
  • *
  • Posts: 15
  • Karma: +0/-0
Tranferring data between modules
« on: April 23, 2008, 05:04:30 pm »
Since I'm not the world biggest PHP genious, I need help with following :

I got a own developed class, let's call it ClassA. From this class I set a Flag(true/false), and I need this value to be accessable from ClassB.

How is it doable in a propper way ?

regards
1k

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Tranferring data between modules
« Reply #1 on: April 23, 2008, 06:10:49 pm »
You have to register a link in the Bot class, either directly with a line like below in 0.4
Code: [Select]
$classvar = new ClassA(&$bot);
$bot -> linktoa = &$classvar;

class ClassA {}
Then you can simple do $this -> bot -> linktoa -> variablename to access the field.

In SVN we got a dedicated function to register those links.

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: Tranferring data between modules
« Reply #2 on: April 24, 2008, 12:25:25 am »
You could also use the settings interface if that makes sense for you.

See the BeBot Developer's Handbook

Offline onekman

  • BeBot Rookie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: Tranferring data between modules
« Reply #3 on: April 24, 2008, 04:49:54 pm »
Alreadythere : You wrote I had to register a link in the Bot class. When you says Botclass you mean the class I made or in the Bot main module ?


Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Tranferring data between modules
« Reply #4 on: April 24, 2008, 05:03:47 pm »
put

Code: [Select]
$bot -> linktoa = &$classvar;

renameing linktoa to wateva u want
and classvar to the class name

and put this in your module before the class so its outside the class but after the line

Code: [Select]
$classvar = new ClassA(&$bot);

then u can call function in the class from other classes useing $this -> bot -> linktoa

Offline Blueeagle

  • Omnipotent
  • BeBot Hero
  • ******
  • Posts: 323
  • Karma: +0/-0
Re: Tranferring data between modules
« Reply #5 on: May 17, 2008, 06:52:07 pm »
It is my opinion that values that more than one module need access to should have this stored in a core module and export the value via the regular api $this->bot->core('module')

The prefered method is to use settings or preferences. If the flag is of a global nature it should use settings and if it's a flag that's set on a per user basis it should use a preference.

You can create your own database table to hold the value ofcourse, but the framework for settings and preferences are in place so we think they should be used.
The only problem that can't be solved by adding another wrapper is having too many wrappers.

 

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