The current code returns a sorted cut-down unvFindObject list as appears in the image below. This format gets a bit cumbersome if there are many ships of the selected type in the galaxy. Some of the Ares Sentries can number up to 100 which makes the list too long.
Here's the list code. gData 'decType is a decimal ship UNID set in a previous screen.
What I would like to do is have a list like the second part of the image with the system name followed by the number of ships or stations in that system. Then the list could only ever contain (in SOTP) about 2 dozen entries. A much more manageable number although the list may need to be split for larger topologies. Note: the desired list format is a list of text entries, they're not generated by code.
Code: Select all
(block (shipsInGalaxy nameList) (setq shipsInGalaxy (filter (unvFindObject "s") unvEntry (eq (@ unvEntry 1) (@ gData 'decType)))) (setq sortedShipsInGalaxy (sortByLambda shipsInGalaxy (lambda (entry) (sysGetTopologyDistance (@ entry 2) "G2")) 'descending)) (setq nameList (map sortedShipsInGalaxy filteredUnvEntry (sysGetName (@ filteredUnvEntry 2)))) )
I'm not sure how to count the number of list entries for each system though. I can see a couple of ways to do this, either split the list according to system name and then count list entries to give the number of stations, or count the list until the system name changes and then use that value as the station number. Unfortunately I have no idea how to do any of this with code.
I also need to be able to create a list of system names that only has one entry for each system name. So somehow exclude repeating entries in the list.
Anyone got any ideas on how to do this? TIA.