nearestObject: Difference between revisions
Jump to navigation
Jump to search
Killzone Kid (talk | contribs) mNo edit summary |
Killzone Kid (talk | contribs) m (added more examples) |
||
Line 35: | Line 35: | ||
_nObject = [[nearestObject]] <nowiki>[</nowiki>[[player]], "StreetLamp"]; | _nObject = [[nearestObject]] <nowiki>[</nowiki>[[player]], "StreetLamp"]; | ||
</code> |= Example 1 | </code> |= Example 1 | ||
|x2= <code>_nObject = [ | |x2= Return the object with ID 123456:<code>_nObject = [0,0,0] [[nearestObject]] 123456; </code> |= Example 2 | ||
|x3= <code>_nObject = [[getPos]] [[player]] [[nearestObject]] "StreetLamp"; </code> |= Example 3 | |x3= <code>_nObject = [[getPos]] [[player]] [[nearestObject]] "StreetLamp"; </code> |= Example 3 | ||
|x4= Return the nearest object with ([[typeOf]] _nObject == "#XXXX") -> #mark, #slop, etc. Unlimited search range:<code>_nObject = _position [[nearestObject]] -1; </code> | |||
Return the nearest object with ([[typeOf]] _nObject != ""). Search range is 50m: | |||
<code>_nObject = [[nearestObject]] _position; </code> | |||
|= Example 4 | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
Revision as of 13:11, 6 October 2013
Description
- Description:
- Nearest object of given type to given position within a range of 50 meters. If object ID passed as an argument (as in example 2) the search range is unlimited. If class types are used in the filter, then in Arma any object derived from the type is found as well. In OFP, only objects with exactly the type given are found.
- Groups:
- Uncategorised
Syntax
- Syntax:
- nearestObject filter
- Parameters:
- filter: Array - Can be one of the following:
[x,y,z]: Any objects near position
[[x,y,z], "type"]: Objects of class "type" near position [x,y,z]
[object, "type"]: Objects of class "type" near position of "object" - Return Value:
- Object - Found object, or objNull if nothing in range.
Alternative Syntax
- Syntax:
- position nearestObject filter
- Parameters:
- position: Array - Position2D or Position3D.
- filter: Number or String - Either ID of object, or class type.
- Return Value:
- Object - Found object, or objNull if nothing in range.
Examples
- Example 1:
_nObject = nearestObject [2345,6789]; _nObject = nearestObject [player, "StreetLamp"];
- Example 2:
- Return the object with ID 123456:
_nObject = [0,0,0] nearestObject 123456;
- Example 3:
_nObject = getPos player nearestObject "StreetLamp";
- Example 4:
- Return the nearest object with (typeOf _nObject == "#XXXX") -> #mark, #slop, etc. Unlimited search range:
_nObject = _position nearestObject -1;
Return the nearest object with (typeOf _nObject != ""). Search range is 50m:_nObject = nearestObject _position;
Additional Information
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
Categories:
- Scripting Commands
- Introduced with Operation Flashpoint version 1.00
- Operation Flashpoint: New Scripting Commands
- Operation Flashpoint: Scripting Commands
- Command Group: Uncategorised
- Scripting Commands OFP 1.96
- Scripting Commands OFP 1.46
- Scripting Commands ArmA
- Command Group: Object Information
- Scripting Commands ArmA2
- Scripting Commands Arma 3
- Scripting Commands Take On Helicopters