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: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

I know what I can use this for... :D
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
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: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on 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)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
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