sleep – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Text replacement - "Killzone Kid" to "Killzone_Kid")
 
(27 intermediate revisions by 15 users not shown)
Line 1: Line 1:
== Sleep not working==
If you can't get sleep to work (like I couldn't for ages, tearing my hair out in the process!), check for the following:
* If you are using an SQF script, but have comments marked with ";" instead of "//", Arma will not give you an error message, but sleep statements will provide no delay - the engine seems to simply ignore them.
: ; are no comment identifiers in SQF. Most likely you use sleep in a context where it is not permitted.
: Post your example code in http://pastebin.jonasscholz.de. Without your post is of no use.
: Overall you are better of posting in BIF or OFPEC about your problem. --[[User:Kju|Kju]] 13:12, 10 May 2010 (CEST)
---
Does this command also work in functions? --[[User:T D|T_D]] 20:15, 21 July 2006 (CEST)
Does this command also work in functions? --[[User:T D|T_D]] 20:15, 21 July 2006 (CEST)


Line 9: Line 20:


[[User:Planck|Planck]] 20:25, 21 July 2006 (CEST)
[[User:Planck|Planck]] 20:25, 21 July 2006 (CEST)
== I think yes... ==
I think yes, functions are as piece of code as other piece of code.
[[User:Djura|Djura]] 20:30, 21 July 2006 (CEST)
-----
Djura, as the new Armed Assault script commands are still WIP, I don't think it is wise to add information to them other than that which we were supplied with by BI.
The description for sleep supplied was 'Suspend execution of script for given time.'
I won't remove what you added but it would be wiser to wait till BI finalise the command set and its operators.
[[User:Planck|Planck]] 13:10, 24 July 2006 (CEST)
:: I'll respect it. (For future: Write this kind of messages to my talk page please.) --[[User:Djura|Djura]] 19:45, 24 July 2006 (CEST)
------
For some insight, check my post here:
http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=10a67f0f44abe94275f48130af94f253;act=ST;f=71;t=55788;st=30
[[User:Igor Drukov|Igor Drukov]] 23:30, 16 December 2006 (GMT+1)
== Generic error in expression ==
When I use the sleep command in a script, the game says : |#|sleep 1; ... Generic error in expression.
Note that the |#| isn't in my code, it's just in the error message.
It says this however I use the command... I tried a workaround using waitUntil, but it throws the same error message.
I can't suspend scripts in Armed Assault...?
:You have to execute the script with execVM or spawn. --[[User:Raedor|raedor]] 15:19, 12 February 2007 (CET)
== Notes ==
Kronzky : Sleep durations between .0005 and .02 will cause the same delay (roughly .02 seconds).
Delays of .0005 and less have no effect.
:Isn't it directly related to FPS and therefore system dependant? 0.02 seconds = ~50fps. --[[User:Ceeeb|Ceeeb]]
::Yes, the absolute delay varies (that's why I put in "roughly"), but the main point is that it doesn't matter whether you use a delay of .01 or .001, as they end up being the same. --[[User:Kronzky|Kronzky]] 03:41, 13 February 2007 (CET)
:::Experimation shows that sleep granularity is measured in frames.  Sleep 0.001 is equivalent to 'wait for next frame' no matter how fast your PC. Sleep 0.02 = 0.02 seconds at 50fps or (not so obviously) 0.032 seconds at 60fps. Basically, you shouldn't try to use sleep for fine-grained timing.
::::For that sort of thing, looking at [[time]] or _time are better. You cannot have it continue after exactly n seconds, but you can find out exactly how much time did pass since last time. --[[User:MaHuJa|MaHuJa]] 11:04, 20 February 2007 (CET)
== Potential bug: ==
I have noticed that if I attempt to execute the following;
sleep _timeToWaitUntil-time;
Then a bug in the parser causes the machine to sleep for _timeToWaitUntil seconds.
Adding brackets solves the problem and it behaves as expected:
sleep (_timeToWaitUntil-time);
:That's how the scripting language was designed and not a bug. --[[User:T D|T_D]] 13:31, 10 May 2010 (CEST)
== sleep anomaly on jip ==
<dl class="command_description">
<dt></dt>
<dd class="notedate">Posted on May 29, 2015 - 02:59 (UTC)</dd>
<dt class="note">[[User:Waffle SS.|Waffle SS.]]</dt>
<dd class="note">
The '''sleep''' command will be ignored on JIP. This affects code/functions called from init.sqf or object initialization. It will simply ignore the command and continue through the code. Even if [[spawn]] is used to create a new process.
</dd>
</dl>
:Seems to be connected to [[time]] == 0 at the start of init.sqf.
<code style="display: block">waitUntil {time > 1};
...the rest of sqf...
</code>
Solve this, that is if one doesnt want to use [[uiSleep]] for some reason. [[User:Killzone_Kid|Killzone_Kid]] ([[User talk:Killzone_Kid|talk]]) 16:01, 29 May 2015 (CEST)

Latest revision as of 13:48, 12 March 2024

Sleep not working

If you can't get sleep to work (like I couldn't for ages, tearing my hair out in the process!), check for the following:

  • If you are using an SQF script, but have comments marked with ";" instead of "//", Arma will not give you an error message, but sleep statements will provide no delay - the engine seems to simply ignore them.
; are no comment identifiers in SQF. Most likely you use sleep in a context where it is not permitted.
Post your example code in http://pastebin.jonasscholz.de. Without your post is of no use.
Overall you are better of posting in BIF or OFPEC about your problem. --Kju 13:12, 10 May 2010 (CEST)

---

Does this command also work in functions? --T_D 20:15, 21 July 2006 (CEST)


I don't think functions ever sleep. They must start and finish, returning the result somewhere, even if it is to null.

They don't pause,,,,thats my understanding anyway.

Planck 20:25, 21 July 2006 (CEST)

I think yes...

I think yes, functions are as piece of code as other piece of code.

Djura 20:30, 21 July 2006 (CEST)


Djura, as the new Armed Assault script commands are still WIP, I don't think it is wise to add information to them other than that which we were supplied with by BI.

The description for sleep supplied was 'Suspend execution of script for given time.'

I won't remove what you added but it would be wiser to wait till BI finalise the command set and its operators.

Planck 13:10, 24 July 2006 (CEST)

I'll respect it. (For future: Write this kind of messages to my talk page please.) --Djura 19:45, 24 July 2006 (CEST)

For some insight, check my post here: http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=10a67f0f44abe94275f48130af94f253;act=ST;f=71;t=55788;st=30

Igor Drukov 23:30, 16 December 2006 (GMT+1)

Generic error in expression

When I use the sleep command in a script, the game says : |#|sleep 1; ... Generic error in expression. Note that the |#| isn't in my code, it's just in the error message. It says this however I use the command... I tried a workaround using waitUntil, but it throws the same error message. I can't suspend scripts in Armed Assault...?

You have to execute the script with execVM or spawn. --raedor 15:19, 12 February 2007 (CET)


Notes

Kronzky : Sleep durations between .0005 and .02 will cause the same delay (roughly .02 seconds). Delays of .0005 and less have no effect.

Isn't it directly related to FPS and therefore system dependant? 0.02 seconds = ~50fps. --Ceeeb
Yes, the absolute delay varies (that's why I put in "roughly"), but the main point is that it doesn't matter whether you use a delay of .01 or .001, as they end up being the same. --Kronzky 03:41, 13 February 2007 (CET)
Experimation shows that sleep granularity is measured in frames. Sleep 0.001 is equivalent to 'wait for next frame' no matter how fast your PC. Sleep 0.02 = 0.02 seconds at 50fps or (not so obviously) 0.032 seconds at 60fps. Basically, you shouldn't try to use sleep for fine-grained timing.
For that sort of thing, looking at time or _time are better. You cannot have it continue after exactly n seconds, but you can find out exactly how much time did pass since last time. --MaHuJa 11:04, 20 February 2007 (CET)

Potential bug:

I have noticed that if I attempt to execute the following;

sleep _timeToWaitUntil-time;

Then a bug in the parser causes the machine to sleep for _timeToWaitUntil seconds.

Adding brackets solves the problem and it behaves as expected:

sleep (_timeToWaitUntil-time);

That's how the scripting language was designed and not a bug. --T_D 13:31, 10 May 2010 (CEST)

sleep anomaly on jip

Posted on May 29, 2015 - 02:59 (UTC)
Waffle SS.
The sleep command will be ignored on JIP. This affects code/functions called from init.sqf or object initialization. It will simply ignore the command and continue through the code. Even if spawn is used to create a new process.
Seems to be connected to time == 0 at the start of init.sqf.

waitUntil {time > 1}; ...the rest of sqf... Solve this, that is if one doesnt want to use uiSleep for some reason. Killzone_Kid (talk) 16:01, 29 May 2015 (CEST)