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?
December 01, 2008, 01:31:23 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: Tranferring data between modules
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Tranferring data between modules  (Read 499 times)
0 Members and 1 Guest are viewing this topic.
onekman
Freshman
*
Offline Offline

Posts: 8


Tranferring data between modules
« on: April 23, 2008, 10:04:30 AM »

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

Posts: 1085


Re: Tranferring data between modules
« Reply #1 on: April 23, 2008, 11:10:49 AM »

You have to register a link in the Bot class, either directly with a line like below in 0.4
Code:
$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.
Logged
Glarawyn
BeBot Developer
Champion
********
Offline Offline

Posts: 414



Re: Tranferring data between modules
« Reply #2 on: April 23, 2008, 05:25:25 PM »

You could also use the settings interface if that makes sense for you.

See the BeBot Developer's Handbook
Logged
onekman
Freshman
*
Offline Offline

Posts: 8


Re: Tranferring data between modules
« Reply #3 on: April 24, 2008, 09:49:54 AM »

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 ?

Logged
Temar
BeBot Developer
Grandmaster
********
Offline Offline

Gender: Male
Posts: 877



WWW
Re: Tranferring data between modules
« Reply #4 on: April 24, 2008, 10:03:47 AM »

put

Code:
$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:
$classvar = new ClassA(&$bot);

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

MSN messenger: chris_smith96 at hotmain dot com
Xfire: chriss96
Blueeagle
Omnipotent
BeBot Developer
Expert
********
Offline Offline

Gender: Male
Posts: 313



Re: Tranferring data between modules
« Reply #5 on: May 17, 2008, 11:52:07 AM »

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.
Logged

The only problem that can't be solved by adding another wrapper is having too many wrappers.
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: Tranferring data between modules
« previous next »
 
Jump to:  

Recent
[request] Raid timers
by Alreadythere
[Today at 11:42:32 AM]

Shared DB online list
by Temar
[Today at 01:55:47 AM]

relay colors
by Temar
[Today at 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]

Starting Bot
by Allisande
[November 28, 2008, 07:08:21 AM]
Stats
Members
Total Members: 1243
Latest: Whackoeng
Stats
Total Posts: 11143
Total Topics: 1505
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 0
Guests: 12
Total: 12

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.914 seconds with 29 queries. (Pretty URLs adds 0.05s, 4q)
Loading...