sleep vs uiSleep: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Some wiki formatting)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
'''sleep vs. uiSleep'''
[[sleep]] pauses the waiting when the game is paused, where [[uiSleep]] does not.


The workings of sleep could be compared to:
{| class="wikitable"
<code>//[[sleep]] 5;
! [[sleep]]
t = [[time]] + 5;
! [[uiSleep]]
[[waitUntil]] {[[time]] >= t};</code>
|-
The workings of [[uiSleep]] could be compared to:
| <sqf>
<code>//[[uiSleep]] 5;
// sleep 5;
t = [[diag_tickTime]] + 5;
_t = time + 5;
[[waitUntil]] {[[diag_tickTime]] >= t};</code>
waitUntil { time >= _t };
When simulation is interrupted, [[time]] freezes, but not [[diag_tickTime]]. Also [[time]] at the start of in ''init.sqf'' is often reported as 0, even if the mission has already started.
</sqf>
| <sqf>
// uiSleep 5;
_t = diag_tickTime + 5;
waitUntil { diag_tickTime >= _t };
</sqf>
|}
 
When the simulation is interrupted, [[time]] freezes, but not [[diag_tickTime]]. Also [[time]] at the start of in ''init.sqf'' is often reported as 0, even if the mission has already started.

Latest revision as of 13:15, 15 July 2022

sleep pauses the waiting when the game is paused, where uiSleep does not.

sleep uiSleep
// sleep 5; _t = time + 5; waitUntil { time >= _t };
// uiSleep 5; _t = diag_tickTime + 5; waitUntil { diag_tickTime >= _t };

When the simulation is interrupted, time freezes, but not diag_tickTime. Also time at the start of in init.sqf is often reported as 0, even if the mission has already started.