BIS fnc selectRandomWeighted: Difference between revisions
Jump to navigation
Jump to search
m (Text replacement - "|Game version=" to "|Game version= |gr1= Arrays |GROUP1") |
m (Text replacement - "\[\[Category\:Function Group\: Arrays(\|\{\{[a-zA-Z0-9_:]+\}\})?\]\]" to "") |
||
Line 49: | Line 49: | ||
<h3 style="display:none">Bottom Section</h3> | <h3 style="display:none">Bottom Section</h3> | ||
[[Category:{{Name|arma2oa}}: Functions|{{uc:selectRandomWeighted}}]] | [[Category:{{Name|arma2oa}}: Functions|{{uc:selectRandomWeighted}}]] | ||
[[Category:{{Name|arma3}}: Functions|{{uc:selectRandomWeighted}}]] | [[Category:{{Name|arma3}}: Functions|{{uc:selectRandomWeighted}}]] | ||
[[Category:{{Name|tkoh}}: Functions|{{uc:selectRandomWeighted}}]] | [[Category:{{Name|tkoh}}: Functions|{{uc:selectRandomWeighted}}]] |
Revision as of 11:50, 12 October 2020
Description
- Description:
- GROUP1 ____________________________________________________________________________________________
- Execution:
- call
- Groups:
- Arrays
Syntax
- Syntax:
- Selects a random item from an array, taking into account item weight. Note:
- The weights don't have to total to 1
- The length of weights and items arrays may not match, in which case the shortest array is used for length
- Parameters:
- itemsAndWeights: Array - array of items and weights [item, weight, item, weight...]
- Return Value:
- itemsAndWeights call BIS_fnc_selectRandomWeighted
Alternative Syntax
- Syntax:
- [items, weights] call BIS_fnc_selectRandomWeighted
- Parameters:
- [items, weights]: Array
- items: Array - items array of Anything
- weights: Array - weights array of Numbers
- Return Value:
- Anything
Examples
- Example 1:
["apples",.3,"pears",.2,"bananas",.4,"diamonds",.1,"unicorns",.00001] call BIS_fnc_selectRandomWeighted;
- Example 2:
[["apples","pears","bananas","diamonds"],[0.3,0.2,0.4,0.1]] call BIS_fnc_selectRandomWeighted;
Additional Information
- See also:
- Anything
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