Quote:
Originally Posted by cbkbud
(Post 1304927)
This seems like something nice, I will probably end up using it. Novo-can you please leave an explanation of what your code is, and what it does when you post? Thanks.
|
I thought I did! It is a broadcast system. Basically, you have Observers... And Events. Observers check to see if an event happened. They are interested when something happens. They may be anyone -- Jews, Russians, and even Christians at times. When the object does something, they signal a broadcast using 'postNotification( event )'. This sends an event to all the objects interested in THAT event. This allows them to do coordinate their efforts.
NPC1:
PHP Code:
function onCreated()
{
join("libnotice");
scheduleevent(5, "Incoming", null);
}
function onIncoming()
{
echo("Got it!");
postNotification("got it");
}
NPC2:
PHP Code:
function onCreated()
{
NPC1.addObserver( this, "GotIt", "got it" );
}
function onGotIt()
{
echo("Do you get it too?");
}
Of course -- Try not to make an event post an event that makes the initial event be posted... Such as adding this line to NPC1:
PHP Code:
this.addObserver( this, "Incoming", "got it" );
|