;I copied and modified this code from somewhere else. Thanks to the anonymous donor, I can't remember where it was from.
;It generates a list of all the active, friendly large stations that are populated in a system and this list appears in
;the left-hand side of the dockscreen. See below for more info.
(block (friendlyStationList stationTravelList stationTravelNames)
(setq friendlyStationList (sysFindObject gSource "AFT +populated"))
(enum friendlyStationList stationTravelNames (setq stationTravelList (lnkAppend stationTravelList (objGetName stationTravelNames 0x100))))
)
;TODO Add CSCs probably using lnkAppend again.
(block Nil
(scrSetDesc gScreen "Select a destination station.")
);block
;Here we jump to another station inside the system.
;'scrGetListEntry' gets the text of the entry under the cursor and we call that 'stationAtCursor'
;We then convert that to an actual station name that the game can recognise and call it 'actualStationNameInList'.
;First we generate a list of all the stations in the system that are 'AFT +populated'. 'A' is any station that
; is active, ie can attack, 'F' is friendly stations, 'T' is structure-scale stations and '+populated' is an
; attribute in the StationTypeUNID code. So any live, large, friendly station that isn't a turret (they aren't
; populated) will appear in the list.
;Here 'filter' runs through that list and makes a list of all stations in the list which have the same name
; as 'stationAtCursor'. In most cases this will be a list with only one station but multiple Commonwealth
; Residentials or other stations with the same name (eg I've seen two Port Harcourts in Eridani recently) will
; give a list of more than one station. Unfortunately this code will only ever take you to the first station on
; the list. This is a bug and I'll fix it sooner or later.
;We then use '@' to turn the station name from a single entry list into a single station name and call it
; 'newShipPosition'. Note that a station name also contains the position of that station as well. (Thanks to NMS
; for that info).
;We then use 'objJumpTo' to move the playership to a position 10ls away from the destination station at an angle
; of 45 degrees up from east and we undock back to the cockpit by using ''forceUndock' after 'scrExitScreen'.
(block (stationAtCursor actualStationNameInList newShipPosition)
(setq stationAtCursor (scrGetListEntry gScreen))
(setq actualStationNameInList (filter (sysFindObject gSource "AFT +populated;") objList (eq (objGetName objList) stationAtCursor)))
(setq newShipPosition (@ actualStationNameInList 0))
(objJumpTo gPlayership (sysVectorPolarOffset newShipPosition 45 10))
(scrExitScreen gScreen 'forceUndock)
)
;need to get list cursor position of station selected and use that position to select the station when multiples.
;so get list pos of first entry somehow and then set that to first entry so @ can select the correct station down the list
;maybe match stationAtCursor to scrGetListCursor to select different stations with the same name.
;BUG if you jump to within LOS you get both jump effects playing simultaneously maybe objSetPos with an effect.
; Possibly add effect stargateout??
;TODO get station size so ship appears 5 or 10ls outside perimeter
;OPTIONAL give a readout of numbers of enemy and friendly stations
;Because 'nestedScreen="true"' was placed in the Dockscreen UNID= block of code (see above) this code will take us
; back to the "God Features" screen because that is the screen we came from. Without 'nestedScreen' we would
; undock back to the cockpit. To undock straight from a 'nestedScreen' use (scrExitScreen gScreen 'forceUndock).
(scrExitScreen gScreen)
;This lot of code creates a list of the names of all of the star systems in the galaxy.
;Because it is inside the 'List' area it puts them into the left hand side of the dockscreen.
;rowHeight="32" makes the rows smaller so we can display the systems more compactly and fit more on the screen at any one time.
;Firstly we make a list of all the nodeIDs in the galaxy using 'sysGetNodes' and call that list 'systemList'.
;A nodeID is a shortcut used by the game to identify systems. It is usually two or three letters long and has
; a text name as well, eg the first system has a nodeID of SE and its name is Eridani.
;'sysGetNodes' makes a list of all the nodeIDs in the galaxy whether they appear on the Galactic Map or not.
;We then convert that list into a list of system names for display in the dockscreen by using 'enum', 'lnkAppend'
; and 'sysGetProperty'.
;I don't understand how but this code runs through the nodeIDs in 'systemList' and generates a list of system names using
; 'sysGetProperty 'name'.
;The 'map' function could probably also be used and is simpler to understand but it's beyond my coding knowledge ATM.
(block (systemList nameList galaxyTravelList)
(setq systemList (sysGetNodes))
(enum systemList nameList (setq galaxyTravelList (lnkAppend galaxyTravelList (sysGetProperty nameList 'name))))
)
(block Nil
(scrSetDesc gScreen "Select a destination system.")
;Here we disable the 'Travel To This System' action if the cursor is on the system we are in.
; Not very useful travelling to where you already are!
(if (eq (sysGetName) (scrGetListEntry gScreen))
(scrEnableAction gScreen 0 Nil)
)
;Here we use the switch function to disable the outbound travel action if there isn't an outbound gate.
; And the same with the inbound travel action.
(switch
(scrEnableAction gScreen 1 (sysFindObject Nil "G:Outbound")))
(scrEnableAction gScreen 2 (sysFindObject Nil "G:Inbound")))
)
);block
;This code working thanks to the very helpful NMS (tips hat, gratefully).
;The code in the 'List' section above generates a list of all the star systems in the galaxy.
;We then select from the list by placing the cursor over the system we want to travel to.
;'scrGetListEntry' gets the entry that is at the cursor and we call that 'listEntry'.
;But this is only the text that appears in the list. It isn't something that the game can recognise as a star system.
;So we convert it to a nodeID by using 'filter' and 'sysGetName'.
;A nodeID is a shortcut used by the game to identify systems. It is usually two or three letters long and has
; a text name as well, eg the first system has a nodeID of SE and its name is Eridani.
;'sysGetNodes' gives us a list of all the nodeIDs in the galaxy. We then 'filter' that list and separate
; all the nodes that have a name that match 'listEntry' using 'eq'.
;If a nodeID in the list has a name the same as 'listEntry' then that nodeID gets placed in the list called 'nodeList'.
;Because all the system names are different this will give us a list of one nodeID (called 'nodeList').
;But functions like 'sysGetStargates' and 'objGateTo' don't work with lists, even lists containing only one nodeID.
;So we extract the list entry and convert it into a nodeID by using '@' on 'nodeList'. Thanks again, NMS.
;The 'setq destinationNode' line of code gets the first entry from the list by using the value '0'.
;The numbering in a list is 0 is the first entry, 1 the second, 2 the third entry and so on.
;Weird, but you get used to it.
;The 'setq destinationGate' line of code gets the name of a stargate in the system we want to travel to.
;It uses '@' again to separate the first entry (because we use '0' again) from a list of stargates
; in 'destinationNode' which is the system we want to travel to.
;'sysGetStargates' gives us a list of all the stargates in a system. If you don't include a nodeID after the function
; it will give a list of all the stargates in the current system.
;So now we have a nodeID of a system to travel to and a destination in that system which in this case is a stargate.
;Note that you can also travel to other points in a system, such as "Start" so long as that point is defined in the
; star system code.
;Now we use 'objGateTo' to gate the playership to 'destinationNode' system and arrive at the 'destinationGate' stargate.
;And because it looks and sounds really cool, we use 'efStargateOut' which makes the sound and visual gating effects.
(block (listEntry nodeList destinationNode destinationGate)
(setq listEntry (scrGetListEntry gScreen))
(setq nodeList (filter (sysGetNodes) listSystem (eq (sysGetName listSystem) listEntry)))
(setq destinationNode (@ nodeList 0))
(setq destinationGate (@ (sysGetStargates destinationNode) 0))
(objGateTo gPlayership destinationNode destinationGate &efStargateOut;)
(scrExitScreen gScreen 'forceUndock)
)
;TODO put the cursor over the current system
;Here we find the outbound stargate using 'sysFindObject' and call it 'nextGate'.
;Using 'objGetProperty'we get the nodeID of the system that the stargate goes to and call it 'destNode'.
;Similarly we get the ID of the stargate at the other end of the outbound stargate using 'objGetProperty'.
;The we gate to the 'destNode' system and arrive at the stargate which has the 'destGate' ID.
(block (nextGate destNode destGate)
(setq nextGate (@ (sysFindObject Nil "G:Outbound") 0))
(setq destNode (objGetProperty nextGate 'destNodeID))
(setq destGate (objGetProperty nextGate 'destStargateID))
(objGateTo gPlayership destNode destGate &efStargateOut;)
)
(block (prevGate destNode destGate)
(setq prevGate (@ (sysFindObject Nil "G:Inbound") 0))
(setq destNode (objGetProperty prevGate 'destNodeID))
(setq destGate (objGetProperty prevGate 'destStargateID))
(objGateTo gPlayership destNode destGate &efStargateOut;)
)
;Because 'nestedScreen="true"' was placed in the Dockscreen UNID= block of code (see above) this code will take us
; back to the "God Features" screen because that is the screen we came from. Without 'nestedScreen' we would
; undock back to the cockpit. To undock straight from a 'nestedScreen' use (scrExitScreen gScreen 'forceUndock).
(scrExitScreen gScreen)