Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Sleep doing weird things?  (Read 4604 times)

0 Members and 1 Guest are viewing this topic.

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Sleep doing weird things?
« on: December 29, 2004, 03:02:51 PM »

Hi Mnemonic,

after update to version 1.3.x function sleep sleeps too much. If I put it away, my script works (it immediately jumps from one state to another) but when I put sleep(1) to slow down the motion a bit, it waits way too long. Is it a bug or a feature? :) In pre 1.3.x version it worked perfectly (the same script).

Thanks

Jan
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sleep doing weird things?
« Reply #1 on: December 29, 2004, 06:00:47 PM »

Hmmm? Can I see the script, please? Sleep seems to work ok for me...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Sleep doing weird things?
« Reply #2 on: December 29, 2004, 07:14:19 PM »

Well, the code is nothing to worry about.  NX && NY are destination tiles. aposx && aposy are Actual position and vcx  && vcy are direction vectors (-1,0,1).

Code: [Select]
while (aposx != NX || aposy != NY)
{
    aposx = aposx + vcx;
    aposy = aposy + vcy;
    this_tile.SkipTo(aposx,aposy);
    Sleep(1);
}

Thanks
Jan
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sleep doing weird things?
« Reply #3 on: December 29, 2004, 07:29:43 PM »

I suppose it comes from the "Dijkstra puzzle", right? I tested the project with both 1.2.44 and 1.3.x with the same results...
If you remove the Sleep() command, the entire while cycle is performed at once. The Sleep command, on the other hand, returns control to the engine and all the other scripts are executed and screen refresh is done before the while cycle is executed again. Could that be the difference?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Sleep doing weird things?
« Reply #4 on: December 29, 2004, 09:26:45 PM »

Well, it could be, but before it went relatively fast and now I have to wait about 20 seconds for each tile movement. Is there any better way how to do this apart from sleep?

Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sleep doing weird things?
« Reply #5 on: December 29, 2004, 09:46:42 PM »

Perhaps only call Sleep() like every ten steps or something like that?
It's really weird, though, I can't think of anything that should affect that...isn't there some other script running simultaneously which eats up too much time every time the sleep is called? Just a wild guess...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Sleep doing weird things?
« Reply #6 on: December 31, 2004, 12:12:44 AM »

Found it -> stupid me. :-[ My monitor dropped to 60hz and wme is waiting for retrace so it gets slower. Which get's me to a point -> how to make synchronization if people have different monitor refresh rates?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sleep doing weird things?
« Reply #7 on: December 31, 2004, 12:43:35 PM »

Found it -> stupid me. :-[ My monitor dropped to 60hz and wme is waiting for retrace so it gets slower. Which get's me to a point -> how to make synchronization if people have different monitor refresh rates?
I'm afraid there's no perfect solution to this except for not using too small time periods for timing...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.034 seconds with 24 queries.