Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   Function Call with Sleep in! (https://forums.graalonline.com/forums/showthread.php?t=70036)

Novo 11-11-2006 09:18 PM

Function Call with Sleep in!
 
When calling a function from another object (TStaticVar, in my case) which has a sleep(); function called in it... The function doesn't return AND the function doesn't resume after the sleep delay.

Admins 11-12-2006 04:26 PM

Normally it should work, but not necessary how you expect it.
When the called function is doing sleep(), it is suspending the script and returning 0 as result. The suspended script will continue to run once the specified time is over.

Novo 11-13-2006 05:24 AM

Quote:

Originally Posted by Stefan (Post 1242344)
Normally it should work, but not necessary how you expect it.
When the called function is doing sleep(), it is suspending the script and returning 0 as result. The suspended script will continue to run once the specified time is over.

That's what I wanted. That's not what I get though. :(

Novo 11-16-2006 02:36 PM

Quote:

Originally Posted by Novo (Post 1242812)
That's what I wanted. That's not what I get though. :(

I have done this another way, and it seems the problem is more clear:

I called the function TWICE, but only the LAST one actually finished.

Thus...

When a function is called TWICE within the interval of the sleep, the function does return 0 (as suppose to), but when the sleep stops, only the LAST function resumes.

Admins 11-16-2006 04:25 PM

There can be only one sleep per object, but in the next Graal version (and npcserver) you have a new command for suspending scripts waitfor(objectname,eventname,timeout) which can be used several times.

Novo 11-17-2006 09:31 AM

Quote:

Originally Posted by Stefan (Post 1244054)
There can be only one sleep per object, but in the next Graal version (and npcserver) you have a new command for suspending scripts waitfor(objectname,eventname,timeout) which can be used several times.

Nice. :)

Would that still return 0 on function-calls? Or it would suspend that as well?

Admins 11-17-2006 03:40 PM

Still return 0 i think

Inverness 12-19-2006 11:19 PM

So would this be able to suspend the advance of a script past a function until that function is completed?

Because I have a public function showInputWindow() and I want the executing function to stop there until you get a return from the input window.

Its like what there is in Java.
String s = JOptionPane.showInputDialog("Input a String");

Admins 12-20-2006 06:23 PM

Added that yesterday to the npcserver, will also try to add it to the client before the xmas release. Instead of sleep() you need to use the new waitfor() command though which is waiting for an event for an object. A sleep/waitfor will basicly suspend the current script and all callers and the callers will be woken up once the sleep/waitfor function returns regulary.

Twinny 12-20-2006 06:43 PM

Quote:

Originally Posted by Stefan (Post 1255689)
the new waitfor() command though which is waiting for an event for an object.

Sounds cool ^^.
Can you use remote objects or only local ones? It would be cool if bjects could catch another objects event and read parameters and such.

Admins 12-20-2006 11:10 PM

Right now it's only suspending the script until the event happens, you cannot access the parameters of the event.

Inverness 12-21-2006 08:29 AM

Nice, I eagerly await the update.
Oh btw, i'm having a problem.

When I do:
function onCreated() {
echo("keys: " @ getstringkeys("clientr."));
}

It returns null, this is only on the serverside and only when trying to get keys for any player or client stuff, everything else works fine.

Admins 12-21-2006 11:25 AM

onCreated() in the player class? Is "this.clientr." working ?

Inverness 12-22-2006 12:27 AM

Quote:

Originally Posted by Stefan (Post 1255886)
onCreated() in the player class? Is "this.clientr." working ?

No the script itself is in a weapon, what I mean is I can't get any data related to the player. If I execute the function using a trigger from the client then it works but not if its executed as soon as weapon is created. I guess this is because when the weapon is created there is no specific player that is executing the functions in the weapon so it doesn't know which player to get information from.


All times are GMT +2. The time now is 09:15 AM.

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