Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-22-2006, 11:04 AM
JustBreathe JustBreathe is offline
Registered User
Join Date: Jun 2006
Posts: 59
JustBreathe is on a distinguished road
GS2: watch variable?

as in Javascript

example?:

PHP Code:
function onCreated()
  {
  
this.var = 0;
  
watchthis.name ".var" );
  
this.var = 3// echos: this.var changed from 0 to 3
  
}

function 
onVarChangedstrNameoldVarnewVar )
  {
  echo( 
strName SPC "changed from" SPC oldVar SPC "to" SPC newVar );
  } 
Usage:

PHP Code:
function onCreated()
  {
  
watch"clientr.health" );
  }

function 
onVarChangedstrNameoldVarnewVar )
  {
  if ( 
strName == "clientr.health" )
    {
    
Health_Bar.width newVar;
    
// Effects, such as (newVar - oldVar) popping over the head to indicate damage
    
}
  } 
Outcome: Reduces Lag ( due to not requiring timeout's to check the change )

More Event-Driven systems
Reply With Quote
  #2  
Old 06-22-2006, 12:05 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Not sure, but I would prefer a more generic "events" system.
PHP Code:
function onCreated() {
  
event(player"UpdateHealth").connect(this);
}

function 
onUpdateHealth(newVal) {
  
Health_Bar.width newVal;

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 08:46 AM.


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