Searching multiple structs suggestions pelase.

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

The Commander's Log mod saves info on stations and systems so they can be accessed out of system. eg items in stations can be searched so you can find where to buy a specific item even if you are 10 systems away.
The mod currently uses a struct which uses the station objectID as a key with the items and their price added as values. Additional stations just get added on and the whole lot gets searched to look for items.

Code: Select all

	(setq logSetItem (lambda (value)
		(typSetData &evD789CommandersLog; 'itemsStruct value)
	))

	(logSetItem
		(set@ (logGetItem)
			(convertTo 'string (objGetID theObject))
			(map (objGetItems theObject '*U) theItem
				(itmSetData theItem 'price (objGetSellPrice theObject theItem))
			)
		)
	)

Unfortunately this gets so large it breaks the game.

I had an idea of using a separate struct for each station using the objectID as the struct name which would give many smaller structs.
Something like:

Code: Select all

(set@ (typeSetData &unidForItems; (objectID convereted to string) 'itemList)
Or maybe have a struct for all of the stations in each system. This would give bigger structs but not so large as to kil the game.
So use the nodeID as the key with the stations and items as values.

But I'm not sure how you could search these. I think a list of either objectIDs would be needed for the first idea or a list of nodeIDs for the second.
Then enum through the each struct somehow to search for an item.

Anyone know if this is possible?
Or got any other simpler ideas?
TIA.
Stupid code. Do what I want, not what I typed in!
Post Reply