fun with filter

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

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.
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Ok, I am thinking that filter is going to be one of my new favorite functions.

Cute exploit, Betel.
User avatar
evilbob
Militia Captain
Militia Captain
Posts: 555
Joined: Sun Mar 05, 2006 1:23 pm

woah, that's some awesome code, I'll have to try it sometime.

Time to ponder uses past selecting stuff...
User avatar
FAD
Militia Captain
Militia Captain
Posts: 732
Joined: Thu Aug 10, 2006 5:33 am
Location: Area 51

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.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

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...
User avatar
evilbob
Militia Captain
Militia Captain
Posts: 555
Joined: Sun Mar 05, 2006 1:23 pm

Sadly my imagination seems limited to selecting the closest enemy or friendly station
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

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.
Crying is not a proper retort!
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5526
Joined: Tue Feb 05, 2008 1:10 am
Location: At the VSS Shipyards in the frontier, designing new ships.

I know what I can use this for... :D
(shpOrder gPlayership 'barrelRoll)

<New tutorials, modding resources, and official extension stuff coming to this space soon!>
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

Wolfy wrote:I know what I can use this for... :D
...Out...of...loop...must...ask. What?
Petrus
Commonwealth Pilot
Commonwealth Pilot
Posts: 66
Joined: Sat May 06, 2006 10:01 pm

Can you bind a key that makes your targeting ROM make the current ship type the "preferred" target of your omni weapon or missiles?
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5526
Joined: Tue Feb 05, 2008 1:10 am
Location: At the VSS Shipyards in the frontier, designing new ships.

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
(shpOrder gPlayership 'barrelRoll)

<New tutorials, modding resources, and official extension stuff coming to this space soon!>
User avatar
FAD
Militia Captain
Militia Captain
Posts: 732
Joined: Thu Aug 10, 2006 5:33 am
Location: Area 51

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.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

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)
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

(filter (sysGetNodes) node (eq (sysGetLevel node) 2))

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

8)
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

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

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

:twisted:
Crying is not a proper retort!
Post Reply