BIS fnc nearestPosition: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Function|Comments=
____________________________________________________________________________________________


{{Function|= Comments
| arma2 |Game name=
 
|1.00|Game version=
 
|gr1 = Positions |GROUP1=
____________________________________________________________________________________________
____________________________________________________________________________________________


| arma2 |= Game name
| Function to find the nearest Object or position from a list, when compared to a given reference. |DESCRIPTION=
 
|1.00|= Game version
____________________________________________________________________________________________
____________________________________________________________________________________________


| <pre>
| [items, origin] call [[BIS_fnc_nearestPosition]] |SYNTAX=
/*
File: nearestPosition.sqf


Description:
|p1= items: [[Array]] of [[Object]], [[Location]], [[Group]], [[String]] (marker) '''and/or''' [[Position]] - note that for a group, '''leader's position''' is used |PARAMETER1=
Function to find the nearest Object or position from a list,  
when compared to a given Object or position.


Parameter(s):
|p2= origin: [[Object]], [[Location]], [[Group]], [[String]] (marker) or [[Position]] |PARAMETER2=
_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
| [[Object]], [[Location]], [[Group]], [[String]] (marker) or [[Position]] - the closest from ''items'' |RETURNVALUE=
</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_nearestPosition]]; --> |= Syntax
|x1= <code>{{codecomment|// Find the nearest marker from player}}
_nearestMarker = [<nowiki/>[[allMapMarkers]], [[player]]] [[call]] [[BIS_fnc_nearestPosition]];</code> |EXAMPLE1=


|p1= |= Parameter 1
|x2= <code>{{codecomment|// Find the nearest marker to trigger using trigger onActivation code}}
 
_nearestMarker = [<nowiki/>[[allMapMarkers]], [[thisTrigger]]] [[call]] [[BIS_fnc_nearestPosition]];</code> |EXAMPLE2=
| |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________


|x1= <code></code> |=
| [[nearObjects]], [[nearestObject]], [[nearestObjects]], [[BIS_fnc_nearestPoint]], [[BIS_fnc_nearestNum]], [[BIS_fnc_nearestRoad]], [[BIS_fnc_nearestHelipad]], [[BIS_fnc_isPosBlacklisted]] |SEEALSO=
____________________________________________________________________________________________
 
| |= See also
 
}}
}}


Line 53: Line 39:


<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Misc|{{uc:nearestPosition}}]]
 
[[Category:Functions|{{uc:nearestPosition}}]]
[[Category:Functions|{{uc:nearestPosition}}]]
[[Category:{{Name|arma2}}: Functions|{{uc:nearestPosition}}]]
[[Category:{{Name|arma2}}: Functions|{{uc:nearestPosition}}]]

Revision as of 15:54, 10 October 2020

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:
nearObjectsnearestObjectnearestObjectsBIS_fnc_nearestPointBIS_fnc_nearestNumBIS_fnc_nearestRoadBIS_fnc_nearestHelipadBIS_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

Notes

Bottom Section