Page 1 of 2

fun with filter

Posted: Fri Aug 01, 2008 6:52 am
by Betelgeuse
filter is a nice and fun function that can make things that seemed slow and painful before easy.

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))))
	)
)
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.

Posted: Fri Aug 01, 2008 9:17 am
by Periculi
Ok, I am thinking that filter is going to be one of my new favorite functions.

Cute exploit, Betel.

Posted: Fri Aug 01, 2008 10:58 am
by evilbob
woah, that's some awesome code, I'll have to try it sometime.

Time to ponder uses past selecting stuff...

Posted: Sat Aug 02, 2008 9:13 am
by FAD
evilbob wrote:Time to ponder uses past selecting stuff...
Yeah, like targeting all wrecks within the system and make them go boom!
...after looting them, of course.

Posted: Sat Aug 02, 2008 9:16 am
by Periculi
Yeah, like targeting all wrecks within the system and make them go boom!
...after looting them, of course.
That's an interesting idea!

I wonder...

Posted: Sat Aug 02, 2008 9:25 am
by evilbob
Sadly my imagination seems limited to selecting the closest enemy or friendly station

Posted: Sat Aug 02, 2008 11:37 am
by Betelgeuse
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.

Posted: Sat Aug 02, 2008 3:43 pm
by Aury
I know what I can use this for... :D

Posted: Sat Aug 02, 2008 11:20 pm
by F50
Wolfy wrote:I know what I can use this for... :D
...Out...of...loop...must...ask. What?

Posted: Mon Aug 04, 2008 3:31 pm
by Petrus
Can you bind a key that makes your targeting ROM make the current ship type the "preferred" target of your omni weapon or missiles?

Posted: Mon Aug 04, 2008 3:39 pm
by Aury
F50 wrote:
Wolfy wrote:I know what I can use this for... :D
...Out...of...loop...must...ask. What?
(with modifications to it)
1) CSC mission fix
2) delivery transport code
3) missile targeting system
4) ship control codes

Posted: Tue Aug 05, 2008 11:27 am
by FAD
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.

Posted: Tue Aug 05, 2008 2:04 pm
by Betelgeuse
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)

Posted: Mon Aug 11, 2008 2:11 am
by Periculi
(filter (sysGetNodes) node (eq (sysGetLevel node) 2))

(filter (sysGetNodes) node (eq (sysHasAttribute node "outerRealm") True))

8)

Posted: Mon Aug 11, 2008 2:22 am
by Betelgeuse
(filter (sysGetNodes) node (sysHasAttribute node "outerRealm"))

(filter (sysGetNodes) node (sysGetStarGates node))
(filter (sysGetNodes) node (not (sysGetStarGates node)))
(filter (sysGetNodes) node (sysGetData node "Visited"))

:twisted: