BIS fnc nearestPosition: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category\:Function Group\: Misc(\|\{\{[a-zA-Z0-9_:]+\}\})?\]\]" to "")
m (Text replacement - "= <code>([^<{]+)<\/code>" to "= <sqf>$1</sqf>")
 
(27 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Function|Comments=
{{RV|type=function
____________________________________________________________________________________________


| arma2 |Game name=
|game1= arma2
|version1= 1.00


|1.00|Game version=
|game2= arma2oa
____________________________________________________________________________________________
|version2= 1.50


| Function to find the nearest Object or position from a list, when compared to a given reference. |DESCRIPTION=
|game3= tkoh
____________________________________________________________________________________________
|version3= 1.00


| [items, origin] call [[BIS_fnc_nearestPosition]] |SYNTAX=
|game4= arma3
|version4= 0.50


|p1= items: [[Array]] of [[Object]], [[Location]], [[Group]], [[String]] (marker) '''and/or''' [[Position]] - note that for a group, '''leader's position''' is used |PARAMETER1=
|gr1= Positions


|p2= origin: [[Object]], [[Location]], [[Group]], [[String]] (marker) or [[Position]] |PARAMETER2=
|descr= Function to find the nearest Object or position from a list, when compared to a given reference.


| [[Object]], [[Location]], [[Group]], [[String]] (marker) or [[Position]] - the closest from ''items'' |RETURNVALUE=
|s1= [items, origin] call [[BIS_fnc_nearestPosition]]
____________________________________________________________________________________________


|x1= <code>{{codecomment|// Find the nearest marker from player}}
|p1= items: [[Array]] of [[Object]], [[Location]], [[Group]], [[String]] (marker) '''and/or''' [[Position]] - note that for a group, '''leader's position''' is used
_nearestMarker = [<nowiki/>[[allMapMarkers]], [[player]]] [[call]] [[BIS_fnc_nearestPosition]];</code> |EXAMPLE1=


|x2= <code>{{codecomment|// Find the nearest marker to trigger using trigger onActivation code}}
|p2= origin: [[Object]], [[Location]], [[Group]], [[String]] (marker) or [[Position]]
_nearestMarker = [<nowiki/>[[allMapMarkers]], [[thisTrigger]]] [[call]] [[BIS_fnc_nearestPosition]];</code> |EXAMPLE2=
____________________________________________________________________________________________


| [[nearObjects]], [[nearestObject]], [[nearestObjects]], [[BIS_fnc_nearestPoint]], [[BIS_fnc_nearestNum]], [[BIS_fnc_nearestRoad]], [[BIS_fnc_nearestHelipad]], [[BIS_fnc_isPosBlacklisted]] |SEEALSO=
|r1= [[Object]], [[Location]], [[Group]], [[String]] (marker) or [[Position]] - the closest from ''items''
}}


<h3 style="display:none">Notes</h3>
|x1= <sqf>// Find the nearest marker from player
<dl class="command_description">
_nearestMarker = [allMapMarkers, player] call BIS_fnc_nearestPosition;</sqf>
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|x2= <sqf>// Find the nearest marker to trigger using trigger onActivation code
</dl>
_nearestMarker = [allMapMarkers, thisTrigger] call BIS_fnc_nearestPosition;</sqf>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[nearObjects]] [[nearestObject]] [[nearestObjects]] [[BIS_fnc_nearestPoint]] [[BIS_fnc_nearestNum]] [[BIS_fnc_nearestRoad]] [[BIS_fnc_nearestHelipad]] [[BIS_fnc_isPosBlacklisted]]
 
}}
[[Category:Functions|{{uc:nearestPosition}}]]
[[Category:{{Name|arma2}}: Functions|{{uc:nearestPosition}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:nearestPosition}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:nearestPosition}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:nearestPosition}}]]

Latest revision as of 17:00, 13 July 2022

Hover & click on the images for description

Description

Description:
Function to find the nearest Object or position from a list, when compared to a given reference.
Execution:
call
Groups:
Positions

Syntax

Syntax:
[items, origin] call BIS_fnc_nearestPosition
Parameters:
items: Array of Object, Location, Group, String (marker) and/or Position - note that for a group, leader's position is used
origin: Object, Location, Group, String (marker) or Position
Return Value:
Object, Location, Group, String (marker) or Position - the closest from items

Examples

Example 1:
// Find the nearest marker from player _nearestMarker = [allMapMarkers, player] call BIS_fnc_nearestPosition;
Example 2:
// Find the nearest marker to trigger using trigger onActivation code _nearestMarker = [allMapMarkers, thisTrigger] call BIS_fnc_nearestPosition;

Additional Information

See also:
nearObjects nearestObject nearestObjects BIS_fnc_nearestPoint BIS_fnc_nearestNum BIS_fnc_nearestRoad BIS_fnc_nearestHelipad BIS_fnc_isPosBlacklisted

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