In the next version of the Taipan GodShip there will be an action to "Get Ammo" from the Ship Dock Services Weapons screen, dsD789GodWeaponsDockscreen . It only shows if the cursor is placed on a weapon which uses ammo. On selecting this action we navigate to another dockscreen, dsD789GodGetItemsDockscreen, which shows a list of ammo which is fired by the selected weapon. You can then add ammo as desired.
(The code for both these screens is attached below as 'DockscreenCode NOT A MOD.xml')
The action works fine but on returning to the Weapons screen the cursor is always on the default slot '0' not the weapon which was selected.
The initial item code in the Weapons screen uses rpgSelectorInitialItem (the screen is a modified copy of the standard dock services weaponsSelector screen, dsRPGManageWeapons).
Here is rpgSelectorInitialItem from RPGCode.xml.
Code: Select all
(setq rpgSelectorInitialItem (lambda (criteria)
(block (
; deviceSelected is a struct with one of the following fields:
; slotPosIndex: This means we should select a slot of
; this index.
; installPos: This means we should select a device in this
; install position.
; installCategory: This means we should select a device
; with this category (or an empty slot with this
; category).
; oldSlots: This means that we select the item that was
; most recently installed (and thus is NOT on this list
; of old devices).
(deviceSelected (scrGetData gScreen 'deviceSelected))
; If none of the player's devices are installed in one of the
; oldSlots, then it means that we cancelled installation/upgrade
(cancelled
(and (@ deviceSelected 'oldSlots)
(not (filter (objGetItems gPlayerShip criteria) theItem
(not (find (@ deviceSelected 'oldSlots) (itmGetInstallPos theItem)))
))
)
)
)
(switch
(not deviceSelected)
True
(and (not cancelled) (@ deviceSelected 'oldSlots))
(and (scrGetItem gScreen)
(not (find (@ deviceSelected 'oldSlots) (itmGetInstallPos (scrGetItem gScreen))))
)
(@ deviceSelected 'slotPosIndex)
(eq (@ deviceSelected 'slotPosIndex) (if (not (scrGetItem gScreen)) (@ (scrGetListEntry gScreen) 'slotPosIndex)))
(@ deviceSelected 'installPos)
(eq (@ deviceSelected 'installPos) (if (scrGetItem gScreen) (itmGetInstallPos (scrGetItem gScreen))))
(@ deviceSelected 'installCategory)
(eq (@ deviceSelected 'installCategory) (if (scrGetItem gScreen) (itmGetProperty (scrGetItem gScreen) 'category) (@ (scrGetListEntry gScreen) 'category)))
True
)
)
))
<OnPaneInit> in the Weapons screen uses this code
Code: Select all
;Remember selection.
(scrSetData gScreen 'deviceSelected { installPos:(itmGetInstallPos theItem) })
And here's the "Get Ammo" action code.
Code: Select all
<Action id="actionGetAmmo">
(block Nil
(setq itemStation (sysCreateStation &vtD789GodItemsVirtualStation; Nil))
(setq itemList (itmGetTypes (cat "m +launchedBy:" (itmGetType (scrGetItem gScreen)) ";")))
(enum itemList theItem (objAddItem itemStation theItem 1))
(scrShowScreen gScreen &dsD789GodGetItemsDockscreen; {
shipObj: shipObj
station: itemStation
scrTitle: (cat "Ammunition for " (itmGetName (scrGetItem gScreen) 'short))
})
)
</Action>
Can anyone see what is needed to get the cursor to return to the selected device? The code in rpgSelectorInitialItem is way over my head.
Also attached is a development version of the Taipan.
To see the problem select
Ship's Interior
Ship Dock Services
Weapons
Place the cursor on the Akan 600
Select the "Get Ammo" action.
Select "Back" from the ammo screen.
The cursor will be on the archcannon, not the Akan as is desired.
TIA.