Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-01-2007, 02:51 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
libnotice

PHP Code:
/***
*** Notification Centre (libnotice ) ***
+(void) addObsrver( object, recall, event );
+(void) remObserver( object );
-(void) postNotification( event, {params} );
***/

public function addObserverobjectrecallEventevent )
  {
  for ( 
temp.noticethis.notifications )
    {
    if ( 
temp.notice[0] != object )
      continue;
    if ( 
temp.notice[1] != recallEvent )
      continue;
    if ( 
temp.notice[2] != event )
      continue;
    
    return;
    }

  
this.notifications.add( {objectrecallEventevent } );
  return;
  }

public function 
remObserver( object )
  {
  for ( 
0this.notifications.size(); ++ )
    {
    if ( 
this.notifications[i][0] == object
      
|| this.notifications[i][0] == null // Shouldn't be here!
      
{
      
this.notifications.delete);
      
--;
      continue;
      }
    }

  return;
  }

function 
postNotificationeventparam )
  {
  
temp.eventParams = { this };
  
temp.eventParams.addarrayparam );

  for ( 
temp.noticethis.notifications )
    {
    if ( 
temp.notice[2] != event )
      continue;

    ( 
temp.notice[0] ).trigger(
        
temp.notice[1],
        
temp.eventParams );
    }
  return;
  } 
Reply With Quote
  #2  
Old 05-01-2007, 03:22 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
All of what exactly can this be used for, I had assumed for things like notices based on the time of the server.

But I wasn't really sure...was I right?
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #3  
Old 05-01-2007, 05:00 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by killerogue View Post
All of what exactly can this be used for, I had assumed for things like notices based on the time of the server.

But I wasn't really sure...was I right?
Example of use:

Putting it into a 'onDamage' clause in the player so that guild members can see other guild members health...
Reply With Quote
  #4  
Old 05-01-2007, 10:11 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
:O, awesome. I'll definitely be using it. Thanks Novo.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #5  
Old 05-01-2007, 10:47 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #6  
Old 05-01-2007, 11:02 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by cbkbud View Post
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.addObserverthis"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.addObserverthis"Incoming""got it" ); 
Reply With Quote
  #7  
Old 05-01-2007, 11:30 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Novo View Post
stuff
Thanks Novo again, GREAT script, didn't realize how nice that script is. I will DEFINATLY use it!
__________________
Reply With Quote
  #8  
Old 05-02-2007, 12:25 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by cbkbud View Post
Thanks Novo again, GREAT script, didn't realize how nice that script is. I will DEFINATLY use it!
That smells sarcasm so badly. Let me go in my room and write a suicide note.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.