scrSetListFilter query

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

Thu Aug 10, 2017 5:51 am

Trying to remove items from a list display by adding item data to them.
Background info:
A station contains items which can be shipped to another station for the player.
The player selects a system which has the desired destination station and navigates to an itemPicker list.
Selecting items from the list to be transferred removes them from the display but not the station.
So the list appearing in the display area is items remaining that aren't selected for transfer.

Once items to transfer have been selected, the player navigates to the next pane which shows these items (still in the station) that have been selected for transfer.
So the list would be the items in the station inventory that have had the item data 'transfer added to it.

Sounds easy enough but it isn't working.
Either no items are removed from the display or all of them are.

Possible causes:
Using itmSetData incorrectly; the function seems to need a variable set to use it.
Items appearing in the display list aren't individual items but an item struct or some grouping of items; maybe enum is needed.
Restrictions in using scrSetListFilter that I'm not aware of.
Incorrect screen/pane navigation order.

Here's one lot of code (not working):

Code: Select all

	name="Freight Service"

	<Display type="itemPicker"
			dataFrom=	"station"
			list=		"*"
			(scrSetListFilter gScreen (lambda (theItem)
				(not (itmIsInstalled theItem))

		<Default showCounter="true">
				(block Nil
					(scrSetDesc gScreen "Select number of items to transfer.")
					(scrSetCounter gScreen (itmGetCount (scrGetItem gScreen)))

				<Action id="actionSelectItem" default="1">
					(block Nil
							;If item selected add itmData, filter list again, refresh, showPane, maintain cursor pos.
							;(itmGetData item attrib) = data
							;(itmSetData item attrib data [count]) = item

						(setq theItem (itmSetData (scrGetItem gScreen) 'transfer True))
						(scrSetListFilter gScreen (lambda (theItem)
							(and (not (itmIsInstalled theItem))
								(not (itmGetData theItem 'transfer))
						(scrShowPane gScreen "Default")

				<Action id="actionBack" cancel="1">
					(scrExitScreen gScreen)
Has anyone got any ideas what is needed?
dsRPGAnalyzeItem uses scrSetListFilter inside a dockscreen action but navigates to another pane.
scrAddListFilter might be better but examples are very rare and documentation non-existent.

Militia Captain
Militia Captain
Posts: 500
Joined: Tue Mar 05, 2013 8:26 am

Thu Aug 10, 2017 6:33 am

This is a case of lack of documentation really biting you... (itmSetData item attrib data [count]) does not change the item you pass it, it just returns a new item with the data set. You have to use (objSetItemData obj item attrib data [count]). You can also use (objAddItem obj (itmSetData item attrib data [count])), but in this case it would duplicate the item unless you also remove the old one.

Count seems to default to 1, so use (itmGetCount item) for the count to change all of them, or (scrGetCounter gScreen) if you're trying to affect only a specified number. I think this won't create additional items if the number is larger than the actual count, but you should probably check.

Also, it doesn't seem like good practice to use global variables called things like 'theItem, let alone then have a lambda with an argument that's called the same thing, even though it's a different variable.

Militia Captain
Militia Captain
Posts: 669
Joined: Tue Nov 05, 2013 9:56 am

Fri Aug 11, 2017 2:42 am

Thank you once again. That will help.

That explains why I could find the items in the debug screen but not in the game. The debug screen created another item with the data which I could find but it wasn't the item on the screen.

Now I'm thinking of using a tabbed display to show either the 'transfer items or the 'store items side by side. And with your info I think I can make it work. Cheers.

And, yeah, I use globals almost exclusively when writing mods because I have so much trouble getting code working. :oops: After everything is sorted I go back and sort them out with localized, unique and more descriptive names.

Post Reply