BIS fnc nearestPosition: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "= <code>([^<{]+)<\/code>" to "= <sqf>$1</sqf>")
 
(35 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma2
____________________________________________________________________________________________
|version1= 1.00


| arma2 |= Game name
|game2= arma2oa
|version2= 1.50


|1.00|= Game version
|game3= tkoh
____________________________________________________________________________________________
|version3= 1.00


| <pre>
|game4= arma3
/*
|version4= 0.50
File: nearestPosition.sqf


Description:
|gr1= Positions
Function to find the nearest Object or position from a list,
when compared to a given Object or position.


Parameter(s):
|descr= Function to find the nearest Object or position from a list, when compared to a given reference.
_this select 0: Array of Objects, Locations, Groups, markers (String) and / or positions (Array)
_this select 1: Comparator Object, Location, Group, marker (String) or position (Array)
Notes:
[*] For type Group the position of its leader is used.
Returns:
Object / Location / Group / marker (String) or position (Array) which is nearest to the comparator
*/


//Valid parameter count
|s1= [items, origin] call [[BIS_fnc_nearestPosition]]
</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_nearestPosition]]; --> |= Syntax
|p1= items: [[Array]] of [[Object]], [[Location]], [[Group]], [[String]] (marker) '''and/or''' [[Position]] - note that for a group, '''leader's position''' is used


|p1= |= Parameter 1
|p2= origin: [[Object]], [[Location]], [[Group]], [[String]] (marker) or [[Position]]


| |= Return value
|r1= [[Object]], [[Location]], [[Group]], [[String]] (marker) or [[Position]] - the closest from ''items''
____________________________________________________________________________________________


|x1= <code>
|x1= <sqf>// Find the nearest marker from player
Define nearest marker to player
_nearestMarker = [allMapMarkers, player] call BIS_fnc_nearestPosition;</sqf>
_nearestMarker = [allMapMarkers, player] call BIS_fnc_nearestPosition;


Define nearest marker to trigger using trigger onactivation code
|x2= <sqf>// Find the nearest marker to trigger using trigger onActivation code
_nearestMarker = [allMapMarkers, thisTrigger] call BIS_fnc_nearestPosition;
_nearestMarker = [allMapMarkers, thisTrigger] call BIS_fnc_nearestPosition;</sqf>
</code> |=
____________________________________________________________________________________________
 
| |= See also


|seealso= [[nearObjects]] [[nearestObject]] [[nearestObjects]] [[BIS_fnc_nearestPoint]] [[BIS_fnc_nearestNum]] [[BIS_fnc_nearestRoad]] [[BIS_fnc_nearestHelipad]] [[BIS_fnc_isPosBlacklisted]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Misc|{{uc:nearestPosition}}]]
[[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