BIS fnc selectRandomWeighted: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\| *(arg|eff|mp|serverExec|gr[0-9]) *= *(.*) * *\|([^=]{12})" to "|$1=$2 |descr=$3") |
Lou Montana (talk | contribs) m (Text replacement - "\| *arma2 * * *\| *([0-1]\.[0-9]{2}) * \|game2" to "|game1= arma2 |version1= $1 |game2") |
||
Line 1: | Line 1: | ||
{{RV|type=function | {{RV|type=function | ||
| arma2 | |game1= arma2 | ||
|1.00 | |version1= 1.00 | ||
|game2= arma2oa | |game2= arma2oa |
Revision as of 00:19, 14 June 2021
Description
- Description:
- 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
- Execution:
- call
- Groups:
- Arrays
Syntax
- Syntax:
- itemsAndWeights call BIS_fnc_selectRandomWeighted
- Parameters:
- itemsAndWeights: Array - array of items and weights [item, weight, item, weight...]
- Return Value:
- Anything
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:
- selectRandomWeighted
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