list splitting ship finding query

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

The GodPlayerships can find ships anywhere in the galaxy by using unvFindObject. But there are 173 ship types in SOTP. That's a bit long for a list.
So currently two options are offered. Ships with a disposition of "enemy" towards the playership (68 types) and ships with a disposition of neq "enemy" (so either friendly or neutral) (47) called "Friendly". Filtering for this requires the ship type to have a defined 'defaultSovereign'.

That leaves the 58 types that don't have a default sovereign which ATM can't be found. Adding these as a third option, "Other Ships", would be ideal but I don't know how to do it.

A couple of options I can see are:

1. Convert the type to an object and use (objGetProperty theObj 'sovereign). I think this would allow all ships to be split into neq enemy and enemy and so cover all 173 types.

2. Somehow filtering the list of 173 types to remove the 115 available types and having the remaining 58 as a separate list, "Other Ships".

I'm thinking the second option would be best as it would split the ships into 3 groups, friendly, enemy and other, and so have three lists of 68, 47 and 58 ships. But I have a hunch the 'Other' ships would be a strange and fairly unintuitive mix.
The first option would divide the list into two. So possibly about 85 each. Still a bit long IMO. Although they could be further split by ship mass; capital, medium and gunship. Not sure which would be best.

Anyone got any other ideas?

I don't know how to remove the 115 available types but think it would be some sort of arrangement of filter, lnkRemove, find or some combination like that. Anyone done something like that or can point me at an existing code example? TIA
Stupid code. Do what I want, not what I typed in!
JohnBWatson
Fleet Officer
Fleet Officer
Posts: 1452
Joined: Tue Aug 19, 2014 10:17 pm

I agree that sorting by sovereign would be unintuitive, especially for ships that appear as both friendlies and enemies. Setting up a standard alphabetically sorted list on ships' display names seems like the best way to handle this. If you want to reduce list size, splitting it into A-M and N-Z would accomplish this. It'd also be quite a bit easier to code than sorting on more ambiguous criteria.
User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

 I suppose part of the question here is, are you looking for specific ships or just ship types? It’s worth noting that there are mods which can override a shiptype’s default sovereign, and even vanilla Transcendence itself does so with the assorted Ronin variants and with Centurions — &svCommonwealthFleet; by default, but also &svCommonwealth; for Commonwealth traffic or guards, &svCorporate; for Corporate guards, and, of course, &svRogueFleet; — which could further muddle things on top of the possibility of there just not being a default sovereign at all. If you want specific ships, you’d be better off using objGetSovereign to sort things out.
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

I agree, an alphabetical list is probably more useful. This code gives a list of entries where each entry is a list consisting of a UNID and ship class name, sorted by name:

Code: Select all

(sort (map (typFind 's) 'excludeNil type
			(if (typGetProperty type 'name) (list type (typGetProperty type 'name)))
			)
		1
	)
Then you can use (loop) or (for) to split into multiple smaller lists, (map) to convert back to a list of just UNIDs, or convert to a list of structs you can give to a customPicker DockScreen, etc.
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Thanks. All very good points that I hadn't considered.
Having a friendly and enemy alphabetical list looks the way to go, split to A-M, N-Z if too long (I hadn't even thought of that...d'oh; plus I just checked that 'sort' handles alphabetical sorting, something I didn't realise before, I thought it was numerical).

The 'find' ability is just a copy of the 'create' ability ATM. Creating needs a sovereign so the create screens sort by sovereign/disposition and I'm not sure how to handle creating the non-defaultSov ships. That's another topic somewhen!
For 'find' I just cut and pasted the 'create' code and stuck unvFindObject in there as a short term solution.
AssumedPseudonym wrote:I suppose part of the question here is, are you looking for specific ships or just ship types?
I hadn't really worked that out yet. A bit of both I think. I need to play about a bit more and see which ships will realistically need to be found and cover them. ATM the named wingman/character ships (although you will mostly know where these are) and CSCs are at the top of the list, followed by the other ship types sorted by name and then sovereign. So as an example; Centurion - Comonwealth Fleet,, Centurion - Corporate (this is Rama, so bad example! oops, wrong), etc.
Adding "(sovGetName (typGetProperty type 'defaultSovereign))" to NMS's code has quite a few come up as Nil for the sovereign name and drops the list back to 168 types (5 missing) for some reason. Anything with the attribute battleArena could be deleted. They won't exist anyway. And so on.

All part of the fun. Thank you all for this.
Last edited by relanat on Sat Mar 24, 2018 9:29 am, edited 1 time in total.
Stupid code. Do what I want, not what I typed in!
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

OK, I've got a working version but have no idea how to split a list from A-M and N-Z or whatever. Is there an easy way to do this? The only way I can think of is to check the first entry of every list entry and stop the list at a certain letter. I'm not sure how to start from a point somewhere in the list (eg N) either.

Anyone got any tips or can point me to the function that does this? TIA.
Stupid code. Do what I want, not what I typed in!
User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

 Actually, good ol’ “gr” will do that; just feed it the names as strings and it can sort them:

Code: Select all

(if (gr (typGetProperty type 'name) "m")
  (setq listAM (append listAM (typGetProperty type 'name)))
  (setq listNZ (append listAM (typGetProperty type 'name)))
)
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Yep. That's easy :D .

Thank you very much.
Stupid code. Do what I want, not what I typed in!
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Just wanted to add a second 'thanks to everyone'. It has worked out better than I could ever have hoped.
Having the entity UNID displayed has solved the problem of the no-Default-Sovereign ships. It clearly shows they are character or player ships or special mission ships. Many thanks to George for the descriptive type names.
The odd splitting of the list is because there are a huge number of ships starting with 'C'.

And I can use this info in a lot of the other screens too.

Yay! Thanks again.

Working code:

Code: Select all

	<Dockscreen UNID="&dsD789GodFindShipDockscreen;"
			name=			"Find Ships"
			type=			"customPicker"
			nestedScreen=	"true"
			>

		<List
			rowHeight="48"
			initialItem="=(or (isError shipTextAndCursorPlacer) (not shipTextAndCursorPlacer) (eq (scrGetListCursor gScreen) shipListPos))"
			>
				;CustomPicker screens need a specific format for the lists that appear in the display area.
				;The list format is as follows: (from RPGShipScreens.xml)
				; 0.	The main large name that appears first, here the type name followed by the sovereign name.
				; 1.	The icon (or in this case Nil as no icon is used).
				; 2.	The subheading, here the UNIDs in entity, hex and decimal format.

			(block (nonAutonBAShipUNIDList nameList)
					;We create a list of all ship types but exclude autons and Battle Arena ships.
				(setq nonAutonBAShipUNIDList (filter (typFind 's) theShipType (not (or (typHasAttribute theShipType 'battleArena) (typHasAttribute theShipType 'auton)))))
					;We set what we want to appear in the list entries. Here the type name and sovereign name, with a sub-text
					;	of all the formats of the UNID, entity, hex and decimal.
				(setq nameList 
					(map nonAutonBAShipUNIDList 'excludeNil
						theType
						(list 
							(cat (typGetProperty theType 'name) " - " (sovGetName (typGetProperty theType 'defaultSovereign)))
							Nil
							(cat (unvEntity theType) " - " (mathDecToHex theType) " -- " theType)
						)
					)
				)
					;Now we sort the list alphabetically by type name as that is the first entry.
				(setq sortedList (sort nameList))
				(switch
					(eq (scrGetData gScreen 'alpha) Nil)
						(filter sortedList theEntry (ls (subset (@ theEntry 0) 0) "d"))

					(eq (scrGetData gScreen 'alpha) "D")
						(filter sortedList theEntry (and (gr (subset (@ theEntry 0) 0) "d") (ls (subset (@ theEntry 0) 0) "n")))

					(eq (scrGetData gScreen 'alpha) "N")
						(filter sortedList theEntry (gr (subset (@ theEntry 0) 0) "n"))

					(eq (scrGetData gScreen 'alpha) "All")
						sortedList
				)
			)
		</List>
Is there a way of counting the list so the number of entries in each list could be displayed in the scrDesc? Something like scrGetListCount? I tried (count gList) but it always comes up as 29. Not sure why. Same with aList.
Previously I have recreated the list in <OnPaneInit> and counted it there but I hope there is an easier way I'm not familiar with.
Attachments
ship find.JPG
ship find.JPG (90.94 KiB) Viewed 4547 times
Stupid code. Do what I want, not what I typed in!
Post Reply