Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   GS2: watch variable? (https://forums.graalonline.com/forums/showthread.php?t=66824)

JustBreathe 06-22-2006 11:04 AM

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

Loriel 06-22-2006 12:05 PM

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;




All times are GMT +2. The time now is 04:14 AM.

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