Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-16-2008, 10:23 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
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.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #2  
Old 08-16-2008, 11:31 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
waitfor() will steal the event, meaning onDebugEvent() never happens.

I had wanted a waitfor2() or so that returns event parameters instead of boolean.
__________________
Reply With Quote
  #3  
Old 08-21-2008, 08:43 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
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 10:51 AM.


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