Home   Help Search Login Register  

Author Topic: sqs seconds, sqf seconds and real seconds  (Read 1399 times)

0 Members and 1 Guest are viewing this topic.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
sqs seconds, sqf seconds and real seconds
« on: 24 Oct 2007, 18:36:16 »
i noticed while making an sqf script, that by using "sleep" for delays, that the seconds are not real seconds.

i then noticed that in sqf through tests, that 1 sqf second is equal to 2.5 seconds.

is this something only in sqf, or has it been in sqs the whole time with ~delay?

Campaigns are hard, I'll stick with scripting for now!

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: sqs seconds, sqf seconds and real seconds
« Reply #1 on: 31 Oct 2007, 13:08:50 »
I've not noticed that sleep times are significantly inaccurate. Realise though, that they aren't supposed to be accurate since all they are guaranteeing is that they will wait for at least N seconds, resuming on the following frame. Because frames occur at absolute times which are unlikely to correspond exactly with the time you desire the script to resume, each sleep's delay, regardless of requested delay size, will be 0 to (1 / FPS) seconds longer than the time requested.

Of course, this doesn't explain why you are getting 2.5 seconds delay for "sleep 1" (I'd expect it to be an actual delay of 1 to 1.05 seconds, assuming a minimum of 20 FPS). I don't know what you are using to test that sleep delays are not correct, but if you are doing "sleep 0.01" 100 times then you will definitely be getting a lot more than a one-second delay, since each sleep will in fact be waiting (1 / FPS) seconds which will likely be a lot longer than the requested 0.01 seconds.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: sqs seconds, sqf seconds and real seconds
« Reply #2 on: 31 Oct 2007, 13:47:29 »
Do the following tests:
Code: [Select]
// timetest.sqf
_tini = dayTime;
Sleep 1;
_tend = dayTime;
hint format["Delta: %1", (_tend - _tini)*3600];

Code: [Select]
;timetest.sqs
_tini = dayTime
~1
_tend = dayTime
hint format["Delta: %1", (_tend - _tini)*3600]