Graal Forums  

Go Back   Graal Forums > Development Forums > Tech Support
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-11-2006, 09:18 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
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.
Reply With Quote
  #2  
Old 11-12-2006, 04:26 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
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.
Reply With Quote
  #3  
Old 11-13-2006, 05:24 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Stefan View Post
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.
Reply With Quote
  #4  
Old 11-16-2006, 02:36 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Novo View Post
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.
Reply With Quote
  #5  
Old 11-16-2006, 04:25 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
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.
Reply With Quote
  #6  
Old 11-17-2006, 09:31 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Stefan View Post
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?
Reply With Quote
  #7  
Old 11-17-2006, 03:40 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
Still return 0 i think
Reply With Quote
  #8  
Old 12-19-2006, 11:19 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
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");
__________________
Reply With Quote
  #9  
Old 12-20-2006, 06:23 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
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.
Reply With Quote
  #10  
Old 12-20-2006, 06:43 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Stefan View Post
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.

Last edited by Twinny; 12-20-2006 at 06:54 PM..
Reply With Quote
  #11  
Old 12-20-2006, 11:10 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
Right now it's only suspending the script until the event happens, you cannot access the parameters of the event.
Reply With Quote
  #12  
Old 12-21-2006, 08:29 AM
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
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.
__________________
Reply With Quote
  #13  
Old 12-21-2006, 11:25 AM
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
onCreated() in the player class? Is "this.clientr." working ?
Reply With Quote
  #14  
Old 12-22-2006, 12:27 AM
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
Quote:
Originally Posted by Stefan View Post
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.
__________________
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 12:01 PM.


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