View Single Post
  #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