;Many thanks to Arkheias for his tutorial on using the newer action code. Couldn't have done this without it.
(block ()
; Background
(rpgSetShipStatsDisplay gPlayerShip { })
)
(block (actionStatus)
;Refuel
(setq actionStatus (rpgD789RefuelLambda { }))
(scrShowAction gScreen 'actionRefuel (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionRefuel (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionRefuel (@ actionStatus 'desc))
)
(block (fuelNeeded amountOfFuel)
(setq fuelNeeded (shpGetFuelNeeded gPlayership (itmCreate &itHelium3FuelRod; 1)))
(setq amountOfFuel (itmCreate &itHelium3FuelRod; fuelNeeded))
(shpRefuelFromItem gPlayerShip amountOfFuel)
(scrRefreshScreen gScreen)
)
(scrShowScreen gScreen &dsD789GodArmorAndShieldsDockscreen;)
(scrShowScreen gScreen &dsD789GodWeaponsDockscreen;)
(scrShowScreen gScreen &dsD789GodMiscDevicesDockscreen;)
(scrShowScreen gScreen &dsD789GodArmorAndShieldsDockscreen;)
(scrShowScreen gScreen &dsD789GodFeaturesDockscreen;)
"[R]efuel"
"Your ship is fully fuelled."
"No onboard fuel required."
"[A]rmor and Shields".
"[W]eapons".
"[M]isc Devices".
"[PageDown] Armor and Shields".
"[Escape] Done"
(block (
(theItem (scrGetItem gScreen))
(theShip gPlayerShip)
)
(switch
;If no item is selected we assume that we have an empty shield generator slot.
(not theItem)
(block ((desc Nil))
(scrSetControlValue gScreen 'currentItem
{title: "Shield Generator Slot"
desc: "Your ship does not have a shield generator installed."
}
)
;Remember that we have the shield generator selected
(scrSetData gScreen 'armorSeg 'shields)
;Install action
(setq actionStatus (rpgD789DockServiceInstallActionLambda gSource theShip { category:'shields criteria:"sUN" }))
(scrShowAction gScreen 'actionInstall (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionInstall (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionInstall (@ actionStatus 'desc))
;Enable/disable various actions
(scrShowAction gScreen 'actionRepairArmor Nil)
(scrShowAction gScreen 'actionReplace Nil)
(scrShowAction gScreen 'actionDisable Nil)
(scrShowAction gScreen 'actionEnable Nil)
(scrShowAction gScreen 'actionRemove Nil)
)
;If this is the shield generator.
(eq (itmGetProperty theItem 'category) 'shields)
(block (
;Shield state
(isEnabled (objGetItemProperty gPlayership theItem 'enabled))
(desc Nil)
(canEnable Nil)
(canDisable Nil)
)
(setq desc (cat (itmGetName theItem 0x0021) " installed."))
;Set the description
(scrSetControlValue gScreen 'currentItem
{source: gPlayerShip
item: theItem
}
)
;Remember that we have the shield generator selected
(scrSetData gScreen 'armorSeg 'shields)
;Replace action
(setq actionStatus (rpgD789DockServiceReplaceActionLambda gSource gPlayership theItem { category:'shields criteria:"sUN" }))
(scrShowAction gScreen 'actionReplace (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionReplace (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionReplace (@ actionStatus 'desc))
(scrShowAction gScreen 'actionRepairArmor Nil)
(scrShowAction gScreen 'actionDisable isEnabled)
(scrShowAction gScreen 'actionEnable (not isEnabled))
(scrShowAction gScreen 'actionInstall Nil)
)
;Otherwise, we expect armor...
(block ()
; Remember the armor segment so that we can come back to
; this same selection (e.g., when we go to replace armor)
(scrSetData gScreen 'armorSeg (itmGetArmorInstalledLocation theItem))
;Repair armor action
(setq actionStatus (rpgD789DockServiceRepairActionLambda gSource theShip theItem { category:'armor }))
(scrShowAction gScreen 'actionRepairArmor (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionRepairArmor (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionRepairArmor (@ actionStatus 'desc))
;Do we have any armor segments in cargo hold that we can use
;to replace this armor?
(setq actionStatus (rpgD789DockServiceReplaceActionLambda gSource theShip theItem { category:'armor criteria:"aU" }))
(scrShowAction gScreen 'actionReplace (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionReplace (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionReplace (@ actionStatus 'desc))
;Set the description
(scrSetControlValue gScreen 'currentItem
{source: gPlayerShip
item: theItem
}
)
;Enable/disable various actions
(scrShowAction gScreen 'actionDisable Nil)
(scrShowAction gScreen 'actionEnable Nil)
(scrShowAction gScreen 'actionRemove Nil)
(scrShowAction gScreen 'actionInstall Nil)
)
)
)
(scrShowScreen gScreen &dsRPGManageArmor;)
(scrShowScreen gScreen &dsRPGInstallDevice; {criteria: "sUN"}
)
(switch
; If this is an armor item, then offer to replace it.
(itmMatches (scrGetItem gScreen) "a")
(scrShowScreen gScreen &dsRPGReplaceArmor; {armorSeg: (scrGetData gScreen 'armorSeg)})
; If shields, replace
(itmMatches (scrGetItem gScreen) "s")
(scrShowScreen gScreen &dsRPGInstallDevice; {criteria: "sUN"})
)
(block Nil
(objSetItemProperty gPlayerShip (scrGetItem gScreen) 'enabled 'silentEnabled)
(scrShowPane gScreen "Default")
)
(block Nil
(objSetItemProperty gPlayerShip (scrGetItem gScreen) 'enabled 'silentDisabled)
(scrShowPane gScreen "Default")
)
(scrShowPane gScreen "RemoveDevice")
(scrShowScreen gScreen &dsD789GodNewDockServicesDockscreen;)
(scrShowScreen gScreen &dsD789GodWeaponsDockscreen;)
(scrShowScreen gScreen &dsD789GodNewDockServicesDockscreen;)
"[Escape] Done"
"[PageUp] Dock Services"
"Disa[b]le"
"Ena[b]le"
"[I]nstall"
"You have items to install in your hold."
"[PageDown] Weapons"
"Remo[v]e"
"[R]epair"
"Re[p]lace"
(if (= (@ gData 'category) 'armor)
"There is nothing in your cargo hold to replace this armor segment with."
"There is nothing in your cargo hold to replace this device with."
)
"Shield replaced."
(cat "The ship's " (@ gData 'armorNoun) " is not damaged.")
(cat "The ship's " (@ gData 'armorNoun) " is damaged and can be repaired free of charge.")
(block (
(theItem (scrGetItem gScreen))
(theShip gPlayerShip)
(deviceTable {
weapon: {
category: 'weapon
criteria: "pUN"
ammoLabel: "actionBuyAmmo"
}
launcher: {
category: 'launcher
criteria: "lUN"
ammoLabel: "actionBuyMissiles"
}
})
(category (if theItem (itmGetProperty theItem 'category) (@ (scrGetListEntry gScreen) 'category)))
(categoryDesc (@ deviceTable category))
)
(scrSetData gScreen 'categoryCriteria (@ categoryDesc 'criteria))
; Figure out desc, etc.
(switch
; If we have an item then this is an installed device
theItem
(block (
(isEnabled (objGetItemProperty theShip theItem 'enabled))
(actionStatus Nil)
)
(scrSetControlValue gScreen 'currentItem {
source: theShip
item: theItem
})
; Remember selection
(scrSetData gScreen 'deviceSelected { installPos:(itmGetInstallPos theItem) })
; Buy ammo action
(setq actionStatus (rpgCalcDockServiceBuyAmmo gSource theShip theItem categoryDesc))
(scrShowAction gScreen 'actionBuyAmmo (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionBuyAmmo (@ actionStatus 'enabled))
(scrSetActionLabel gScreen 'actionBuyAmmo (scrTranslate gScreen (@ categoryDesc 'ammoLabel)))
(scrSetActionDesc gScreen 'actionBuyAmmo (@ actionStatus 'desc))
; Replace action
(setq actionStatus (rpgD789DockServiceReplaceActionLambda gSource theShip theItem categoryDesc))
(scrShowAction gScreen 'actionReplace (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionReplace (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionReplace (@ actionStatus 'desc))
; Enable disable?
(if (objGetItemProperty theShip theItem 'canBeDisabled)
(block Nil
(setq canDisable isEnabled)
(setq canEnable (not isEnabled))
)
)
(scrShowAction gScreen 'actionInstall Nil)
)
; Otherwise, this is an empty slot, so we display something
; based on the item category
(block (
)
; Set description
(scrSetControlValue gScreen 'currentItem {
title: (scrTranslate gScreen (cat "slotTitle:" category))
desc: (scrTranslate gScreen (cat "slotDesc:" category) {
slotsAvail: (objGetProperty theShip 'availableWeaponSlots)
})
})
; Remember selection
(scrSetData gScreen 'deviceSelected { slotPosIndex:(@ (scrGetListEntry gScreen) 'slotPosIndex) })
; Cannot buy ammo/missiles
(scrShowAction gScreen 'actionBuyAmmo Nil)
; Install action
(setq actionStatus (rpgD789DockServiceInstallActionLambda gSource theShip categoryDesc))
(scrShowAction gScreen 'actionInstall (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionInstall (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionInstall (@ actionStatus 'desc))
(scrShowAction gScreen 'actionRemove Nil)
(scrShowAction gScreen 'actionReplace Nil)
)
)
; Enable/disable various actions
(scrShowAction gScreen 'actionDisable canDisable)
(scrShowAction gScreen 'actionEnable canEnable)
)
(scrShowScreen gScreen &dsRPGCommoditiesExchangeBuy; {
criteria: (cat "m +launchedBy:" (itmGetType (scrGetItem gScreen)) ";")
})
(block Nil
; On return, select either the newly installed item
; or the original slot.
(scrSetData gScreen 'deviceSelected
{
oldSlots: (map (objGetItems gPlayerShip "Id") theItem (itmGetInstallPos theItem))
slotPosIndex: (@ (scrGetListEntry gScreen) 'slotPosIndex)
}
)
(scrShowScreen gScreen &dsRPGInstallDevice; {
criteria: (scrGetData gScreen 'categoryCriteria)
slotPosIndex: (@ (scrGetListEntry gScreen) 'slotPosIndex)
})
)
(scrShowScreen gScreen &dsRPGInstallDevice; {
criteria: (scrGetData gScreen 'categoryCriteria)
replaceItem: (scrGetItem gScreen)
})
(block Nil
(objSetItemProperty gPlayerShip (scrGetItem gScreen) 'enabled 'silentEnabled)
(scrShowPane gScreen "Default")
)
(block Nil
(objSetItemProperty gPlayerShip (scrGetItem gScreen) 'enabled 'silentDisabled)
(scrShowPane gScreen "Default")
)
(scrShowPane gScreen "RemoveDevice")
(scrShowScreen gScreen &dsD789GodArmorAndShieldsDockscreen;)
(scrShowScreen gScreen &dsD789GodMiscDevicesDockscreen;)
(scrShowScreen gScreen &dsD789GodNewDockServicesDockscreen;)
"Buy [A]mmo"
"Buy [M]issiles"
"Disa[b]le"
"[Escape] Done"
"Ena[b]le"
"[I]nstall"
"[PageUp] Armor and Shields"
"[PageDown] Miscellaneous Devices"
"Remo[v]e"
"Re[p]lace"
"Launcher Slot"
(switch
(eq (@ gData 'slotsAvail) 0)
(cat
"There are no free slots available for a launcher. "
"(However, some launchers do not require a free slot to be installed.)"
)
"Your ship does not have a missile launcher installed."
)
"Weapon Slot"
(switch
(eq (@ gData 'slotsAvail) 0)
(cat
"There are no free slots available for weapons. "
"(However, some weapons do not require a free slot to be installed.)"
)
(eq (@ gData 'slotsAvail) 1)
(cat
"Your ship has a free slot available for installing weapons."
)
(cat
"Your ship has " (@ gData 'slotsAvail) " free slots available for installing weapons."
)
)
(block (
(theItem (scrGetItem gScreen))
(theShip gPlayerShip)
(canDisable Nil)
(canEnable Nil)
(canInstall Nil)
(deviceTable {
cargoHold: {
category: 'cargoHold
criteria: "cUN"
}
device: {
category: 'device
criteria: "d~wscrv UN"
}
drive: {
category: 'drive
criteria: "vUN"
}
reactor: {
category: 'reactor
criteria: "rUN"
}
})
(category (if theItem (itmGetProperty theItem 'category) (@ (scrGetListEntry gScreen) 'category)))
(categoryDesc (@ deviceTable category))
(actionStatus Nil)
)
(scrSetData gScreen 'categoryCriteria (@ categoryDesc 'criteria))
; Figure out desc, etc.
(switch
; If we have an item then this is an installed device
theItem
(block (
(isEnabled (objGetItemProperty theShip theItem 'enabled))
)
(scrSetControlValue gScreen 'currentItem {
source: theShip
item: theItem
})
; Remember selection
(scrSetData gScreen 'deviceSelected { installPos:(itmGetInstallPos theItem) })
; Refuel action
(setq actionStatus (rpgD789ReactorRefuelActionLambda gSource theShip theItem categoryDesc))
(scrShowAction gScreen 'actionRefuel (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionRefuel (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionRefuel (@ actionStatus 'desc))
;Replace action
(setq actionStatus (rpgD789DockServiceReplaceActionLambda gSource theShip theItem categoryDesc))
(scrShowAction gScreen 'actionReplace (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionReplace (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionReplace (@ actionStatus 'desc))
; Enable disable?
(if (objGetItemProperty theShip theItem 'canBeDisabled)
(block Nil
(setq canDisable isEnabled)
(setq canEnable (not isEnabled))
)
)
(if
(not (itmMatches theItem "d~rI"))
(scrShowAction gScreen 'actionRemove 'nil)
)
(scrShowAction gScreen 'actionInstall Nil)
)
; Otherwise, this is an empty slot, so we display something
; based on the item category
(block (
)
; Set description
(scrSetControlValue gScreen 'currentItem {
title: (scrTranslate gScreen (cat "slotTitle:" category))
desc: (scrTranslate gScreen (cat "slotDesc:" category) {
slotsAvail: (objGetProperty theShip 'availableNonWeaponSlots)
})
})
; Remember selection
(scrSetData gScreen 'deviceSelected { slotPosIndex:(@ (scrGetListEntry gScreen) 'slotPosIndex) })
; Install action
(setq actionStatus (rpgD789DockServiceInstallActionLambda gSource theShip categoryDesc))
(scrShowAction gScreen 'actionInstall (@ actionStatus 'visible))
(scrEnableAction gScreen 'actionInstall (@ actionStatus 'enabled))
(scrSetActionDesc gScreen 'actionInstall (@ actionStatus 'desc))
(scrShowAction gScreen 'actionRemove Nil)
(scrShowAction gScreen 'actionRefuel Nil)
(scrShowAction gScreen 'actionReplace Nil)
)
)
; Enable/disable various actions
(scrShowAction gScreen 'actionDisable canDisable)
(scrShowAction gScreen 'actionEnable canEnable)
)
(block (fuelNeeded amountOfFuel)
(setq fuelNeeded (shpGetFuelNeeded gPlayership (itmCreate &itHelium3FuelRod; 1)))
(setq amountOfFuel (itmCreate &itHelium3FuelRod; fuelNeeded))
(shpRefuelFromItem gPlayerShip amountOfFuel)
(scrRefreshScreen gScreen)
)
(block Nil
; On return, select either the newly installed item
; or the original slot.
(scrSetData gScreen 'deviceSelected
{
oldSlots: (map (objGetItems gPlayerShip "Id") theItem (itmGetInstallPos theItem))
slotPosIndex: (@ (scrGetListEntry gScreen) 'slotPosIndex)
}
)
(scrShowScreen gScreen &dsRPGInstallDevice; {
criteria: (scrGetData gScreen 'categoryCriteria)
slotPosIndex: (@ (scrGetListEntry gScreen) 'slotPosIndex)
})
)
(scrShowScreen gScreen &dsRPGInstallDevice; {
criteria: (scrGetData gScreen 'categoryCriteria)
replaceItem: (scrGetItem gScreen)
})
(block Nil
(objSetItemProperty gPlayerShip (scrGetItem gScreen) 'enabled 'silentEnabled)
(scrShowPane gScreen "Default")
)
(block Nil
(objSetItemProperty gPlayerShip (scrGetItem gScreen) 'enabled 'silentDisabled)
(scrShowPane gScreen "Default")
)
(scrShowPane gScreen "RemoveDevice")
(scrShowScreen gScreen &dsD789GodWeaponsDockscreen;)
(scrShowScreen gScreen &dsD789GodNewDockServicesDockscreen;)
"Disa[b]le"
"[Escape] Done"
"Ena[b]le"
"[I]nstall"
"[PageUp] Armor and Shields"
"[PageUp] Weapons"
"Remo[v]e"
"[R]efuel"
"Your ship is fully fuelled."
"No onboard fuel required."
"Re[p]lace"
(cat
(itmGetName (@ gData 'item) 0x0021) " installed."
)
"Cargo Expansion Slot"
(switch
(eq (@ gData 'slotsAvail) 0)
(cat
"There are no free slots available for a cargo expansion. "
"(However, some devices do not require a free slot to be installed.)"
)
(cat
"Your ship does not have a cargo expansion installed.\n\n"
"Cargo expansions can be installed to increase the carrying "
"capacity of your ship."
)
)
"Device Slot"
(switch
(eq (@ gData 'slotsAvail) 0)
(cat
"There are no free slots available for miscellaneous devices. "
"(However, some devices do not require a free slot to be installed.)"
)
(eq (@ gData 'slotsAvail) 1)
(cat
"Your ship has a free slot available for installing miscellaneous "
"devices."
)
(cat
"Your ship has " (@ gData 'slotsAvail) " free slots available for installing miscellaneous "
"devices."
)
)
"Drive Upgrade Slot"
(switch
(eq (@ gData 'slotsAvail) 0)
(cat
"There are no free slots available for a drive upgrade. "
"(However, some devices do not require a free slot to be installed.)"
)
(cat
"Your ship does not have a drive upgrade installed.\n\n"
"Drive upgrades can be installed to increase the thrust and velocity "
"of your ship."
)
)
"Reactor Slot"
"Your ship does not have a reactor installed."