BIS fnc randomPos: Difference between revisions
Jump to navigation
Jump to search
m (Text replacement - "\[\[Category:Function Group: [a-zA-Z0-9_: ]+(\|\{\{[a-zA-Z0-9_: ]+\}\})?\]\]" to " ") |
Lou Montana (talk | contribs) m (Text replacement - "_{10,} " to "") |
||
Line 1: | Line 1: | ||
{{Function|Comments= | {{Function|Comments= | ||
| game2= arma3 |GAME2= | | game2= arma3 |GAME2= | ||
Line 9: | Line 8: | ||
|gr1 = Map and Markers |GROUP1= | |gr1 = Map and Markers |GROUP1= | ||
| Selects random position according to given params within given area |DESCRIPTION= | | Selects random position according to given params within given area |DESCRIPTION= | ||
| [whitelist, blacklist, code] call '''BIS_fnc_randomPos''' |SYNTAX= | | [whitelist, blacklist, code] call '''BIS_fnc_randomPos''' |SYNTAX= | ||
Line 30: | Line 27: | ||
|[[Array]] - position candidate in format [x,y,z] or [0,0] if position cannot be found |RETURNVALUE= | |[[Array]] - position candidate in format [x,y,z] or [0,0] if position cannot be found |RETURNVALUE= | ||
|x1= <code>_randomPosMapNoWater = [] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE1= | |x1= <code>_randomPosMapNoWater = [] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE1= | ||
Line 37: | Line 33: | ||
|x4= <code>_randomPosMap = [<nowiki/>[[nil]], []] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE4= | |x4= <code>_randomPosMap = [<nowiki/>[[nil]], []] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE4= | ||
|x5= <code>_randomPosAroundPlayer = <nowiki>[[[</nowiki>[[position]] [[player]], 50]],[]] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE5= | |x5= <code>_randomPosAroundPlayer = <nowiki>[[[</nowiki>[[position]] [[player]], 50]],[]] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE5= | ||
Revision as of 23:53, 16 January 2021
Description
- Description:
- Selects random position according to given params within given area
- Execution:
- call
- Groups:
- Map and Markers
Syntax
- Syntax:
- [whitelist, blacklist, code] call BIS_fnc_randomPos
- Parameters:
- [whitelist, blacklist, code]: Array
- whitelist (Optional): Array - whitelisted areas. If not given, whole map is used. Areas could be:
- blacklist (Optional): Array - blacklisted areas. If not given, water is blacklisted. Areas could be:
- code (Optional): Code - custom condition which should return true for current position candidate passed in _this variable to be accepted. If not specified all candidates are accepted
- Return Value:
- Array - position candidate in format [x,y,z] or [0,0] if position cannot be found
Examples
- Example 1:
_randomPosMapNoWater = [] call BIS_fnc_randomPos;
- Example 2:
_randomPosMapNoWater = [nil, ["water"]] call BIS_fnc_randomPos;
- Example 3:
_randomPosMapNoLand = [nil, ["ground"]] call BIS_fnc_randomPos;
- Example 4:
_randomPosMap = [nil, []] call BIS_fnc_randomPos;
- Example 5:
_randomPosAroundPlayer = [[[position player, 50]],[]] call BIS_fnc_randomPos;
Additional Information
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
Notes
Bottom Section
- Posted on March 30, 2020 - 21:33 (UTC)
- Tankbuster
-
The code parameter here can be quite powerful.
If using example 5 above, adding code as below will make the returned positions always be on a road.
randomRoadPosAroundPlayer = [[[position player,50]],[], {isOnRoad _this}] call BIS_fnc_randomPos;