;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))))
)
)
It finds the closest asteroid with ore in it. You can put this in a device or a consumable item and have the player ship target it but that wasn't the point. The point is to show off what filter can do.
hmm FAD that could be an interesting idea but instead of exploding after you loot them they explode after a certain amount of time. (after they are checked so many times make them explode)
It would solve the wrecks problem and make an interesting problem, you see a wreck sitting there do you risk looting knowing that it might explode.
Betelgeuse wrote:hmm FAD that could be an interesting idea but instead of exploding after you loot them they explode after a certain amount of time. (after they are checked so many times make them explode)
It would solve the wrecks problem and make an interesting problem, you see a wreck sitting there do you risk looting knowing that it might explode.
That sounds even better. And having each one set at random timers to make it even more interesting.
well having one random event per system to check that would save cpu. You can still make it that it is random (just have each wreck store a random number when first checked and decrement it each time you check it and when it reaches zero boom)