BIS fnc loop: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Generated by BIS_fnc_exportFunctionsToWiki)
 
m (Some wiki formatting)
 
(37 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 1.16


| arma3 |= Game name
|gr1= Program Flow


|1.00|= Game version
|descr= Loop stacked code/function with timing and conditional control. Code and conditions are executed in [[Scheduler#Unscheduled_Environment|non-scheduled environment]].
____________________________________________________________________________________________


| <pre>/*
|s1= [action, parameters] call [[BIS_fnc_loop]]
Description:
Loop stacked code/function with timing and conditional control
Code and conditions are executed in non-scheduled environment
Parameters:
_this select 0: Action
_this select 1: Parameters
Returns:
NOTHING
Examples:
["initialize"] call BIS_fnc_loop; //Initializes game loop (not required if AUTO_INITIALIZE is set to true)
["terminate"] call BIS_fnc_loop; //Terminates game loop (not required if AUTO_TERMINATE is set to true)
["itemAdd", ["uniqueId", { hint str time; }, 5]] call BIS_fnc_loop; //Hints time every five seconds
["itemAdd", ["uniqueId", { hint str time; }, 120, "frames"]] call BIS_fnc_loop; //Hints time every 120 frames
["itemAdd", ["uniqueId", { hint str time; }, nil, nil, { !isNil { BIS_variable } }]] call BIS_fnc_loop; //Hints time every frame after BIS_variable is assigned
["itemAdd", ["uniqueId", { hint str time; }, 5, "seconds", { !isNil { BIS_variable } }]] call BIS_fnc_loop; //Hints time every five seconds after BIS_variable is assigned
["itemAdd", ["uniqueId", { hint str time; }]] call BIS_fnc_loop; //Hints time every frame
["itemRemove", ["uniqueId"]] call BIS_fnc_loop; //Remove item from loop with id "uniqueId"
*/


//Defines
|p1= action: [[String]] - can be one of:
#define AUTO_INITIALIZE true
* "initialize" - Initializes game loop (not required as internal AUTO_INITIALIZE variable is set to true)
#define AUTO_TERMINATE true
* "terminate" - Terminates game loop (required as internal AUTO_TERMINATE variable is ''not'' set to true)
* "itemAdd" - Adds an item to loop
* "itemRemove" - Remove item from loop with id "uniqueId"
* ''"onEachFrame" - internally used by "initialize"''
* ''"itemExecute" - internally used by "onEachFrame"''


//Parameters
|p2= parameters: [[Array]] - used with "itemAdd" and "itemRemove" ''action'' ("itemRemove" only takes id):
</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
* id: [[String]] - loop unique id
____________________________________________________________________________________________
* code: [[Code]] or [[String]] - code to be executed
* timer: [[Number]] - (Optional, default 0) delay between executions
* timerType: [[String]] - (Optional, default "seconds") can be "seconds" or "frames"
* conditionStart: [[Code]] - (Optional, default <sqf inline>{ true }</sqf>) will ''wait'' until the condition is met to start the code
* conditionEnd:  [[Code]] - (Optional, default <sqf inline>{ false }</sqf>) stops the loop as soon as the ending condition is met (after the end of ''code'')
* executeOnce: [[Boolean]] - (Optional, default [[false]])


| <!-- [] call [[BIS_fnc_loop]]; --> |= Syntax
|r1= [[Nothing]]


|p1= |= Parameter 1
|x1= <sqf>// hints time every five seconds
["itemAdd", ["uniqueId", { hint str time; }, 5]] call BIS_fnc_loop;</sqf>


| |= Return value
|x2= <sqf>// removes stacked loop with id of uniqueId
____________________________________________________________________________________________
["itemRemove", ["uniqueId"]] call BIS_fnc_loop;</sqf>


|x1= <code></code> |=
|x3= <sqf>// hints time every frame after BIS_variable is assigned
____________________________________________________________________________________________
["itemAdd", ["uniqueId", { hint str time; }, nil, nil, { !isNil { BIS_variable } }]] call BIS_fnc_loop;</sqf>


| |= See also
|x4= <sqf>// hints time every five seconds after BIS_variable is assigned
["itemAdd", ["uniqueId", { hint str time; }, 5, "seconds", { !isNil { BIS_variable } }]] call BIS_fnc_loop;</sqf>


}}
|x5= <sqf>// hints time every frame
["itemAdd", ["uniqueId", { hint str time; }]] call BIS_fnc_loop;</sqf>


<h3 style="display:none">Notes</h3>
|x6= <sqf>// remove item from loop with id "uniqueId"
<dl class="command_description">
["itemRemove", ["uniqueId"]] call BIS_fnc_loop;</sqf>
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|seealso= [[for]] [[forEach]] [[while]]
</dl>
}}
 
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Misc|{{uc:loop}}]]
[[Category:Functions|{{uc:loop}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:loop}}]]

Latest revision as of 12:58, 18 July 2022

Hover & click on the images for description

Description

Description:
Loop stacked code/function with timing and conditional control. Code and conditions are executed in non-scheduled environment.
Execution:
call
Groups:
Program Flow

Syntax

Syntax:
[action, parameters] call BIS_fnc_loop
Parameters:
action: String - can be one of:
  • "initialize" - Initializes game loop (not required as internal AUTO_INITIALIZE variable is set to true)
  • "terminate" - Terminates game loop (required as internal AUTO_TERMINATE variable is not set to true)
  • "itemAdd" - Adds an item to loop
  • "itemRemove" - Remove item from loop with id "uniqueId"
  • "onEachFrame" - internally used by "initialize"
  • "itemExecute" - internally used by "onEachFrame"
parameters: Array - used with "itemAdd" and "itemRemove" action ("itemRemove" only takes id):
  • id: String - loop unique id
  • code: Code or String - code to be executed
  • timer: Number - (Optional, default 0) delay between executions
  • timerType: String - (Optional, default "seconds") can be "seconds" or "frames"
  • conditionStart: Code - (Optional, default { true }) will wait until the condition is met to start the code
  • conditionEnd: Code - (Optional, default { false }) stops the loop as soon as the ending condition is met (after the end of code)
  • executeOnce: Boolean - (Optional, default false)
Return Value:
Nothing

Examples

Example 1:
// hints time every five seconds ["itemAdd", ["uniqueId", { hint str time; }, 5]] call BIS_fnc_loop;
Example 2:
// removes stacked loop with id of uniqueId ["itemRemove", ["uniqueId"]] call BIS_fnc_loop;
Example 3:
// hints time every frame after BIS_variable is assigned ["itemAdd", ["uniqueId", { hint str time; }, nil, nil, { !isNil { BIS_variable } }]] call BIS_fnc_loop;
Example 4:
// hints time every five seconds after BIS_variable is assigned ["itemAdd", ["uniqueId", { hint str time; }, 5, "seconds", { !isNil { BIS_variable } }]] call BIS_fnc_loop;
Example 5:
// hints time every frame ["itemAdd", ["uniqueId", { hint str time; }]] call BIS_fnc_loop;
Example 6:
// remove item from loop with id "uniqueId" ["itemRemove", ["uniqueId"]] call BIS_fnc_loop;

Additional Information

See also:
for forEach while

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note