nearestLocation: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|= Game name" to "|Game name=")
m (Text replacement - "\{\{Feature *\| *Informative *\| ([^↵]+) *\}\}" to "{{Feature|informative|$1}}")
 
(62 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


|arg= |Multiplayer Arguments=
|game3= arma2oa
|version3= 1.50


|eff= |Multiplayer Effects=
|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]] |PARAMETER1=
|descr= Return the closest location of specified class to a given position. Checked range is unlimited (i.e. covers the whole map).
|p2= position: [[Object]] or [[Array]] in format [[PositionAGL]] or [[Position2D]] |PARAMETER2=
|p3= locationClass: [[String]] of a location class name. If "" is supplied, any nearest location is returned.|PARAMETER3=


| [[Location]] |RETURNVALUE=
{{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> |EXAMPLE1=
|x2= <code>_anyNearestLocation = [[nearestLocation]] <nowiki>[</nowiki>[[player]], ""];</code> |EXAMPLE1=
____________________________________________________________________________________________


| [[findNearestEnemy]], [[nearestBuilding]], [[nearestObject]], [[nearestObjects]], [[nearObjects]], [[nearEntities]], [[nearTargets]], [[nearSupplies]], [[nearestLocationWithDubbing]], [[nearObjectsReady]], [[nearRoads]], [[ArmA_2:_CfgLocationTypes]], [[locationPosition]], [[nearestLocations]], [[createLocation]] |SEEALSO=
|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