nearestLocation: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " [ [[" to " [<nowiki/>[[")
m (Text replacement - "\{\{Feature *\| *Informative *\| ([^↵]+) *\}\}" to "{{Feature|informative|$1}}")
 
(54 intermediate revisions by 4 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


|gr1= Locations |GROUP1=
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| Return the closest location of specified class to a given position.<br>Checked range is unlimited (i.e. covers the whole map). |DESCRIPTION=
|game4= tkoh
____________________________________________________________________________________________
|version4= 1.00


| [[nearestLocation]] [position, locationClass] |SYNTAX=
|game5= arma3
|version5= 0.50


|p1= [position, locationClass]: [[Array]] |PARAMETER1=
|gr1= Locations


|p2= position: [[Object]] or [[Array]] in format [[PositionAGL]] or [[Position2D]] |PARAMETER2=
|descr= Return the closest location of specified class to a given position. Checked range is unlimited (i.e. covers the whole map).


|p3= locationClass: [[String]] of a location class name. If "" is supplied, any nearest location is returned. See [[Location#Location Types|Location Types]] |PARAMETER3=
{{Feature|informative|Although locations can be placed in 3D with [[setPosition]], [[nearestLocations]] search is conducted in 2D.}}


| [[Location]] |RETURNVALUE=
|s1= [[nearestLocation]] [position, locationType, maxDistance]
____________________________________________________________________________________________
 
|x1= <code>_nearestCity = [[nearestLocation]] [<nowiki/>[[getPos]] [[player]], "nameCity"];</code> |EXAMPLE1=


|x2= <code>_anyNearestLocation = [[nearestLocation]] [<nowiki/>[[player]], ""];</code> |EXAMPLE2=
|p1= position: [[Object]] or [[Array]] in format [[Position#PositionAGL|PositionAGL]] or [[Position#Introduction|Position2D]]
____________________________________________________________________________________________


| [[findNearestEnemy]], [[nearestBuilding]], [[nearestObject]], [[nearestObjects]], [[nearObjects]], [[nearEntities]], [[nearTargets]], [[nearSupplies]], [[nearestLocationWithDubbing]], [[nearObjectsReady]], [[nearRoads]], [[Location#Location Types|Location Types]], [[locationPosition]], [[nearestLocations]], [[createLocation]] |SEEALSO=
|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 Armed Assault|{{uc:{{PAGENAME}}}}]]
}}
[[Category:Command_Group:_Locations|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{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