sysFindMultiple lambda

Freeform discussion about anything related to modding Transcendence.
Post Reply
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

This may be of use somewhere.
The criteria for 'sysFindObject' don't stack very well.

This is a way of creating a list of objects that can vary widely in the selection criteria.

Code: Select all

	;Combines objects from multiple sysFindObject criteria into one list.
(setq rpgD789SysFindMultiple (lambda (source criteriaList)
	(apply append (map criteriaList theCriteria (sysFindObject source theCriteria)))
))
The 'source' is as per 'sysFindObject' and the 'criteriaList' is a list of valid 'sysFindObject' criteria.

An example from the Commander's Log mod.

Code: Select all

(setq activeFriendlyStations
	(rpgD789SysFindMultiple gPlayerShip
		(list "TAFM+populated; -arcology; +property:known; -property:abandoned"
			"*t+unid:&stTanRuDorem;; +property:known;"
			(if (eq nodeID "SK")
				"*V+unid:&stStKatsArcology;;"
			)
		)
	)
)
In this example 'gPlayerShip' is the 'source' because the stations are being filtered for 'F', friendly.
And there are 3 criteria in the list. I don't think the 'if' code is strictly necessary but I left it there to show that it can be used inside the list section.

This creates a list of all known, non-abandoned, populated, friendly stations in a system less arcology segments plus TanRuDorem if in Elysium plus the virtual Arcology if in St Kats.


Note that the use of entity UNIDs in the criteria requires a semi-colon after the UNID semi-colon or the code does not work.
The criteria list may contain only one entry but it must be a list.

Thanks to NMS and 0xABCDEF for info on using 'apply' and 'append'.

EDIT: Forgot to add. Using different criteria that return the same object twice will place the object in the resulting list twice. So best to be careful with the criteria or double check for duplicate objects afterwards.
Stupid code. Do what I want, not what I typed in!
Post Reply