GameMonkey Script

GameMonkey Script Forums
It is currently Thu Sep 09, 2010 12:19 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: sleep() not functioning properly...
PostPosted: Wed Jul 28, 2010 9:59 pm 
Offline

Joined: Tue Jul 27, 2010 5:52 pm
Posts: 4
What is the correct usage for sleep?

If I do something like this:

Code:
global main= function()
{
    while(true)
    {
        print("something");
        sleep(2.0);
        print("something else");

        yield();
    }
};

main();


I would expect that "something" would print, then the script would wait for 2 seconds, then "something else" would print, and this would repeat indefinitely. I'm not seeing this. Am I mistaken that this is what should happen based on this code above?


Top
 Profile  
 
 Post subject: Re: sleep() not functioning properly...
PostPosted: Thu Jul 29, 2010 8:34 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 580
Welcome to the forum dood :) The behavior you expect is pretty much what I expect also. After the first line of text, you will see two new lines of text appearing every 2 seconds. Please try running this program with GME. What is the result that you do see? If you are running from GM compiled within your own program, are you calling gmMachine::Execute() regularly with delta time, to pump the script threads?


Top
 Profile  
 
 Post subject: Re: sleep() not functioning properly...
PostPosted: Thu Jul 29, 2010 6:27 pm 
Offline

Joined: Tue Jul 27, 2010 5:52 pm
Posts: 4
It works as expected when running through gme. I should mention that I'm running this on the xbox, and I have my own logging mechanism, so the only difference in script code is that the print statements are replaced with my own. I see that what is happening is that it is stalling on sleep.

I am calling gmMachine::Execute() every frame with the delta time. I will investigate more...


Top
 Profile  
 
 Post subject: Re: sleep() not functioning properly...
PostPosted: Thu Jul 29, 2010 8:08 pm 
Offline
User avatar

Joined: Fri Jan 14, 2005 2:28 am
Posts: 434
I assume you are seeing the first print but not the 2nd? If so it really points to the execute being called with the wrong params, unless there is just some pretty big bug with gm compiled on xbox


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group