User Tools

Site Tools


prpl:getnearestshipinrange

<- PRPL reference <- Everything Else 2

GetNearestShipInRange

ArgumentsResultNotation
x y radius sqaure sid [ int int float bool - int ]

Description

  • x: The x coordinate of the center of the search, in cells
  • y: The y coordinate of the center of the search, in cells
  • radius: The radius of the search area, in cells
  • sqaure: If set to true, the search area will be square with side length 2xradius, otherwise it will be a cirlce with radius radius

Find the nearest ship to the target coordinates and returns it's ship id on stack. If no ship is found in the range, -1 is pushed on the stack instead.

The center of the command module needs to be in range in order for the ship to register (you could even have a ship collide with the search cencer and still not be found if the command center is too far away, for example).

All 3 of player ship, friendly ships (the blue uncontrollable ones) and enemy ships count. Dopplers and friendly dopplers don't count.

Examples

50 50 20 1 GetNearestShipInRange Trace

Screenshot:

This is a visual representation of the code in the example. The energy source in the middle has the same range as the search would have, if it was in circle mode, giving you a good idea of the search area.

prpl/getnearestshipinrange.txt · Last modified: 2017/10/28 14:34 by kajacx