look at this bit of code
Code: Select all
;first let's get all the asteroids
(setq miningAsteroids (sysFindObject gSource "t:asteroid"))
;then filter out all the ones without ore
(setq miningAsteroids (filter miningAsteroids asteroid (objGetItems asteroid "*U +Ore")))
;find the closest one
(loop miningAsteroids
(block nil
;make a guess that the first one on the list is the closest
(setq guessAsteroid (item miningAsteroids 0))
;filter out any asteroids that are farther away or the same distance
(setq miningAsteroids (filter miningAsteroids asteroid
(ls (objGetDistance asteroid gSource) (objGetDistance guessAsteroid gSource))))
)
)