nearestLocation: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(accepts object as position)
m (Text replacement - "\{\{Feature *\| *Informative *\| ([^↵]+) *\}\}" to "{{Feature|informative|$1}}")
 
(68 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma |= Game name
|game1= arma1
|version1= 1.08


|1.08|= Game version
|game2= arma2
|version2= 1.00


|arg= |= Arguments in MP
|game3= arma2oa
|version3= 1.50


|eff= |= Effects in MP
|game4= tkoh
____________________________________________________________________________________________
|version4= 1.00


| Return the closest location of specified class to a given position.<br>Checked range is unlimited (i.e. covers the whole map). |= Description
|game5= arma3
____________________________________________________________________________________________
|version5= 0.50


| '''nearestLocation''' [position, locationClass] |= Syntax
|gr1= Locations


|p1= [position, locationClass]: [[Array]] |= Parameter 1
|descr= Return the closest location of specified class to a given position. Checked range is unlimited (i.e. covers the whole map).
|p2= position: [[Position2D]], [[Position3D]] or [[Object]] |= Parameter 2
|p3= locationClass: [[String]] of a location class name.|= Parameter 3


| [[Location]] |= Return value
{{Feature|informative|Although locations can be placed in 3D with [[setPosition]], [[nearestLocations]] search is conducted in 2D.}}
____________________________________________________________________________________________
 
|x1= <code>_nearestCity = [[nearestLocation]] [ [[getPos]] [[player]], "nameCity"];</code> |= Example 1
____________________________________________________________________________________________


| [[findNearestEnemy]], [[nearestBuilding]], [[nearestObject]], [[nearestObjects]], [[nearObjects]], [[nearEntities]], [[nearTargets]], [[nearSupplies]], [[nearestLocationWithDubbing]], [[nearObjectsReady]], [[nearRoads]], [[ArmA_2:_CfgLocationTypes]], [[locationPosition]], [[nearestLocations]], [[createLocation]] |= See also
|s1= [[nearestLocation]] [position, locationType, maxDistance]


}}
|p1= position: [[Object]] or [[Array]] in format [[Position#PositionAGL|PositionAGL]] or [[Position#Introduction|Position2D]]
 
|p2= locationType: [[String]] of a location class name. If "" is supplied, any nearest location is returned. Since Arma 3 2.14 locationType could be an [[Array]] of location types. See [[Location#Location Types|Location Types]]


<h3 style="display:none">Notes</h3>
|p3= maxDistance: [[Number]] - (Optional) max search radius. Default - unlimited range.
<dl class="command_description">
|p3since= arma3 2.14
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|r1= [[Location]]
</dl>


<h3 style="display:none">Bottom Section</h3>
|x1= <sqf>_nearestCity = nearestLocation [getPos player, "nameCity"];</sqf>


|x2= <sqf>_anyNearestLocation = nearestLocation [player, ""];</sqf>


[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
|seealso= [[findNearestEnemy]] [[nearestBuilding]] [[nearestObject]] [[nearestObjects]] [[nearObjects]] [[nearEntities]] [[nearTargets]] [[nearSupplies]] [[nearestLocationWithDubbing]] [[nearObjectsReady]] [[nearRoads]] [[Location#Location Types|Location Types]] [[locationPosition]] [[nearestLocations]] [[createLocation]] [[nearestMines]]
[[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]]
}}
[[Category:Command_Group:_Locations|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]

Latest revision as of 18:11, 15 March 2024

Hover & click on the images for description

Description

Description:
Return the closest location of specified class to a given position. Checked range is unlimited (i.e. covers the whole map).
Although locations can be placed in 3D with setPosition, nearestLocations search is conducted in 2D.
Groups:
Locations

Syntax

Syntax:
nearestLocation [position, locationType, maxDistance]
Parameters:
position: Object or Array in format PositionAGL or Position2D
locationType: String of a location class name. If "" is supplied, any nearest location is returned. Since Arma 3 2.14 locationType could be an Array of location types. See Location Types
since Arma 3 logo black.png2.14
maxDistance: Number - (Optional) max search radius. Default - unlimited range.
Return Value:
Location

Examples

Example 1:
_nearestCity = nearestLocation [getPos player, "nameCity"];
Example 2:
_anyNearestLocation = nearestLocation [player, ""];

Additional Information

See also:
findNearestEnemy nearestBuilding nearestObject nearestObjects nearObjects nearEntities nearTargets nearSupplies nearestLocationWithDubbing nearObjectsReady nearRoads Location Types locationPosition nearestLocations createLocation nearestMines

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