finding lists in lists code help please

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

Mon Sep 03, 2018 4:22 am

The inventory mod I'm working on has a "Find" feature as seen in the Captain's Log mod. Items are listed on the screen in the system where they are so players can find them again if they aren't in that system.
It use screen input text to search for matches in the item name.

But the code is a little too much for me.
The data is stored in list form.
objID, name, nodeID, 'visited status' and a list of uninstalled items in the station.

Code: Select all

matchingStations
((18565 "Pergium Fuel & Supplies" SE Visited ((16444 -16777078) (16458 -16777215) (16788 -16777185) (16422 -16777194))) (18609 "Sisters of Domina" SE Visited ((16523 -16777213) (16572 -16777215) (16560 -16777215) (16447 -16777213) (16431 -16777210))))
The items to be searched for are also a list, in this case items containing "h" in their name.

Code: Select all

sortedMatchingItemList
((16431 -16777210) (16444 -16777078) (16788 -16777185))
I can sort of get it working.

Code: Select all

(enum sortedMatchingItemList theItem
	(enum matchingStations theStationEntry
		(block Nil
			(if (find (@ theStationEntry 4) theItem)
				(lnkAppend entryToAdd
					(cat
						(itmGetName theItem) " "
						(itmGetCount theItem) " - "
						(@ theStationEntry 1)
					)
				)
			)
		)
	)
)
produces the right format but way too many times.

Code: Select all

entryToAdd
("roll of hyperfiber 6 - Sisters of Domina" "helium³ fuel rod 138 - Pergium Fuel & Supplies" "tank of hydrogen gas 31 - Pergium Fuel & Supplies" "roll of hyperfiber 6 - Sisters of Domina" "helium³ fuel rod 138 - Pergium Fuel & Supplies" "tank of hydrogen gas 31 - Pergium Fuel & Supplies" "roll of hyperfiber 6 - Sisters of Domina" "helium³ fuel rod 138 - Pergium Fuel & Supplies" "tank of hydrogen gas 31 - Pergium Fuel & Supplies" "roll of hyperfiber 6 - Sisters of Domina" "helium³ fuel rod 138 - Pergium Fuel & Supplies" "tank of hydrogen gas 31 - Pergium Fuel & Supplies" "roll of hyperfiber 6 - Sisters of Domina" "helium³ fuel rod 138 - Pergium Fuel & Supplies" "tank of hydrogen gas 31 - Pergium Fuel & Supplies" "roll of hyperfiber 6 - Sisters of Domina" "helium³ fuel rod 138 - Pergium Fuel & Supplies" "tank of hydrogen gas 31 - Pergium Fuel & Supplies" "roll of hyperfiber 6 - Sisters of Domina" "helium³ fuel rod 138 - Pergium Fuel & Supplies" "tank of hydrogen gas 31 - Pergium Fuel & Supplies")
Any tips on generating just the one lot of entries?
I guess it may need 'for' or 'loop' instead of one of the 'enum's but I don't want to waste even more time on it.

Post Reply