Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   waitfor bug? (https://forums.graalonline.com/forums/showthread.php?t=81273)

xXziroXx 08-16-2008 10:23 PM

waitfor bug?
 
Okay, so I was playing around with waitfor, and noticed this.


PHP Code:

function onCreated()
{
  
temp.foo timevar2;
  
  
scheduleevent(3"DebugEvent""");
  if (
waitfor(this"DebugEvent"5)) { 
    echo(
"test ==" SPC timevar2 temp.foo);
  } else echo(
"fail");
}

function 
onDebugEvent()
{
  echo(
"onDebugEvent() triggered!");


As you can see, I'm scheduling an event in 3 seconds and right after doing a waitfor that lasts 5 seconds, waiting for the scheduled event to be done. This is the result on RC:

PHP Code:

The script of NPC DEBUG has been updated by xXziroXx
test 
== 3.069610118 

As you can see, onDebugEvent() is triggered in 3 seconds... or is it? The waitfor seems to think so, but no matter what code I put inside the onDebugEvent() function, it's not executed. Is this a bug with waitfor/scheduleevent? If so, could it be fixed? If it's not, what am I doing wrong?

Note that this is just a test, I know of other perhaps more... accurate ways of using waitfor. Nonetheless, it'd be neat if this could work.

Inverness 08-16-2008 11:31 PM

waitfor() will steal the event, meaning onDebugEvent() never happens.

I had wanted a waitfor2() or so that returns event parameters instead of boolean.

Admins 08-21-2008 08:43 PM

An object can only catch an event one time, thats why you cannot add more than one MyButton.onAction() to the same script either.

Receiving the parameters of the event would be helpful in some cases yes. I think you can actually access them via params[] but have not tested it yet.


All times are GMT +2. The time now is 06:01 AM.

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