Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   scheduleevent (https://forums.graalonline.com/forums/showthread.php?t=134260706)

LordOfPi13 10-03-2010 08:09 AM

scheduleevent
 
Hey guys, been playing with scripting lately and noticed scheduleevent. I've read the descriptions on the wiki, but it doesn't seem to come to me. It would be awesome if someone could write a quick example using scheduleevent in action :D

MrOmega 10-03-2010 08:26 AM

Sure

PHP Code:

function onCreated()
{

  
this.var = "foo";
  
scheduleEvent3"change""bar");
  
onTimeout();

}

function 
onTimeout()
{

  
this.chat this.foo;

  
setTimer0.05);

}

function 
onChangetemp.var)
{

  
this.foo temp.var;

  if ( 
temp.var == "bar")
    
scheduleEvent3"change""baz");



When created it will show 'foo' for three seconds then 'bar', then after another three seconds 'baz'. ScheduleEvent does not interupt the current script, which can come in very handy when using a timeout loop.

MrDumbledore 10-03-2010 05:28 PM

scheduleEvent just waits x number of seconds to do something.

PHP Code:

function onCreated() {
  
this.scheduleEvent(5"onMyEvent"null); // the last parameter isn't needed on v6 and above, or on serverside
}

function 
onMyEvent() {
  echo(
"event!");


"event!" would be echoed 5 seconds after the script ran.

e: also, MrOmega, you should avoid using variables with the name 'var' as they don't work on clientside (might just be this.var, I don't remember) due to some stupid Flash thing Stefan implemented. Avoiding the use of it altogether is best to avoid confusion.

MrOmega 10-04-2010 05:35 AM

Quote:

Originally Posted by MrDumbledore (Post 1603847)
e: also, MrOmega, you should avoid using variables with the name 'var' as they don't work on clientside (might just be this.var, I don't remember) due to some stupid Flash thing Stefan implemented. Avoiding the use of it altogether is best to avoid confusion.

I know, just my bad, just using a random variable name in general, although that is good advice for beggining scripters.

Also, what are some past accounts? You're very wise and knowledgable about gScript2, so I assume you do.

MrDumbledore 10-04-2010 05:42 AM

Quote:

Originally Posted by MrOmega (Post 1604020)
Also, what are some past accounts? You're very wise and knowledgable about gScript2, so I assume you do.

I'm a wizard.

MrOmega 10-04-2010 05:46 AM

Well you act a lot like an old scripting teacher/friend of mine from AE. :rolleyes:

xXziroXx 10-04-2010 06:50 AM

Quote:

Originally Posted by MrOmega (Post 1604029)
Well you act a lot like an old scripting teacher/friend of mine from AE. :rolleyes:

Been starting to think more and more that he's Chris Vimes who magically stopped posting around the same time as this fellow showed up. :asleep:

MrOmega 10-04-2010 08:56 AM

I was thinking Invern, but I can see it being Chris too.

xXziroXx 10-04-2010 09:05 AM

Quote:

Originally Posted by MrOmega (Post 1604050)
I was thinking Invern, but I can see it being Chris too.

I'd say that THIS post proves that it's Chris, not to mention how he's using him as example in more or less every post. :asleep:

MrOmega 10-04-2010 09:15 AM

And the mystery is solved 8-)


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

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