GameMonkey Script

GameMonkey Script Forums
It is currently Mon Nov 20, 2017 3:37 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Jul 28, 2010 9:59 pm 
Offline

Joined: Tue Jul 27, 2010 5:52 pm
Posts: 5
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  
Reply with quote  
PostPosted: Thu Jul 29, 2010 8:34 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 698
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  
Reply with quote  
PostPosted: Thu Jul 29, 2010 6:27 pm 
Offline

Joined: Tue Jul 27, 2010 5:52 pm
Posts: 5
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  
Reply with quote  
PostPosted: Thu Jul 29, 2010 8:08 pm 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
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  
Reply with quote  
PostPosted: Sun Oct 24, 2010 2:22 am 
Offline

Joined: Tue Jul 27, 2010 5:52 pm
Posts: 5
The error was mine. GM wanted an unsigned int for gmMachine->Execute(dt), and I was doing a static_cast from double, which was resulting in dt = 0 for very small values of dt, and since sleep(2.0) resulted in a value of 2000 in the debugger, it looked like it was expecting the number of ms or maybe the ticks that had passed.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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® Forum Software © phpBB Group