nearestLocation: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:[ _]?Scripting[ _]Commands[ _]Take[ _]On[ _]Helicopters(\|.*)?\]\]" to "{{GameCategory|tkoh|Scripting Commands}}")
m (Text replacement - "\{\{Feature *\| *Informative *\| ([^↵]+) *\}\}" to "{{Feature|informative|$1}}")
 
(48 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma1 |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]]
{{GameCategory|arma1|Scripting Commands}}
}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}

Latest revision as of 19: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