BIS fnc loop: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "{{Function|= Comments ____________________________________________________________________________________________ | arma3 |= Game name |1.14|= Game version ________________...")
m (Text replacement - "\|seealso= ([^ ]+)(\]\]|\}\}), *(\[\[|\{\{)" to "|seealso= $1$2 $3")
(24 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Function|= Comments
{{RV|type=function
____________________________________________________________________________________________


| arma3 |= Game name
|game1= arma3
|version1= 1.16


|1.14|= Game version
|gr1= Program Flow
____________________________________________________________________________________________


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


| param call [[BIS_fnc_loop]]; |= Syntax
|s1= [action, parameters] call [[BIS_fnc_loop]]


|p1= Sub-Function: [[String]] |= Parameter 1
|p1= action: [[String]] - can be one of:
|p2= Parameters: [[Array]] |= Parameter 2
* "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"''


| [[Nothing]] |= Return value
|p2= 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
|x1= <code>["itemAdd", ["uniqueId", { hint str time; }, 5]] [[call]] [[BIS_fnc_loop]];</code> |=
* timer: [[Number]] - (Optional, default 0) delay between executions
* timerType: [[String]] - (Optional, default "seconds") can be "seconds" or "frames"
* conditionStart: [[Code]] - (Optional, default {{ic|{ [[true]] <nowiki>}</nowiki>}}) will ''wait'' until the condition is met to start the code
* conditionEnd:  [[Code]] - (Optional, default {{ic|{ [[false]] <nowiki>}</nowiki>}}) stops the loop as soon as the ending condition is met (after the end of ''code'')
* executeOnce: [[Boolean]] - (Optional, default [[false]])


|x2= <code>["itemRemove", ["uniqueId"]] [[call]] [[BIS_fnc_loop]];</code> |=
|r1= [[Nothing]]
_______________________________________________________________________________________


| |= See also
|x1= <code>{{cc|hints time every five seconds}}
["itemAdd", ["uniqueId", { hint str time; }, 5]] [[call]] [[BIS_fnc_loop]];</code>


}}
|x2= <code>{{cc|removes stacked loop with id of uniqueId}}
["itemRemove", ["uniqueId"]] [[call]] [[BIS_fnc_loop]];</code>
 
|x3= <code>{{cc|hints time every frame after BIS_variable is assigned}}
["itemAdd", ["uniqueId", { [[hint]] [[str]] [[time]]; }, [[nil]], [[nil]], { ![[isNil]] { BIS_variable } }]] [[call]] [[BIS_fnc_loop]];</code>


<h3 style="display:none">Notes</h3>
|x4= <code>{{cc|hints time every five seconds after BIS_variable is assigned}}
<dl class="command_description">
["itemAdd", ["uniqueId", { [[hint]] [[str]] [[time]]; }, 5, "seconds", { ![[isNil]] { BIS_variable } }]] [[call]] [[BIS_fnc_loop]];</code>
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|x5= <code>{{cc|hints time every frame}}
</dl>
["itemAdd", ["uniqueId", { [[hint]] [[str]] [[time]]; }]] [[call]] [[BIS_fnc_loop]];</code>


<h3 style="display:none">Bottom Section</h3>
|x6= <code>{{cc|remove item from loop with id "uniqueId"}}
["itemRemove", ["uniqueId"]] [[call]] [[BIS_fnc_loop]];</code>


[[Category:Arma 3:_Functions|log]]
|seealso= [[for]] [[forEach]] [[while]]
[[Category:Take_On_Helicopters:_Functions|log]]
}}
[[Category:Function Group: Debug|log]]

Revision as of 13:58, 1 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