I'm trying to do some modest modding. I want to uninstall a device ('itStarCannon') and replace it by some other device ('itAlternatingStarCannons') when the install event for the 'itStarCannon' fires.
Code: Select all
<OnInstall>
(block (starCannons)
(dbgLog "onInstall event triggered")
(setq starCannons (list))
; Enumerate all installed weapons
(objEnumItems gPlayerShip "wI" aWeapon
(if
(and
(eq (itmGetName aWeapon 0) "Katana star cannon")
(not (itmIsDamaged aWeapon))
(not (itmIsEnhanced aWeapon))
(ls (count starCannons) 2)
)
(setq starCannons (lnkAppend starCannons aWeapon))
)
)
(dbgLog (cat "starCannons list is " (count starCannons) " elements long"))
(if (eq (count starCannons) 2)
(block (alternatingStarCannons)
; Uninstall and remove the two original star cannons
; (enum starCannons aStarCannon
; (block Nil
; (shpRemoveDevice gPlayerShip aStarCannon)
; )
; )
; (objRemoveItem gPlayerShip (itmCreate &itStarCannon; 2))
; Create and install the alternating star cannons
(setq alternatingStarCannons (itmCreate &itAlternatingStarCannons; 1))
(objAddItem gPlayerShip alternatingStarCannons)
(shpInstallDevice gPlayerShip alternatingStarCannons)
(dbgLog "Replaced 2 Katana star cannons by 1 Fire linked star cannons?"))
)
)
)
</OnInstall>
Code: Select all
Exception in shpInstallDevice; arg = (gPlayerShip (scrGetItem gScreen))
Exception in shpInstallDevice; arg = (gPlayerShip (scrGetItem gScreen)) [(gPlayerShip (scrGetItem gScreen))] ### (shpInstallDevice gPlayerShip (scrGetItem gScreen)) ###