API:PurchaseKeepUpgrade
From RoR Wiki
UI Lua API · RvR functions
Version: WAR 1.4.8
Asks the server to move a keep upgrade to a new level. The stock UI calls it from the keep upgrade interaction window.
PurchaseKeepUpgrade(upgradeId, targetLevel)
Arguments
- upgradeId
number– Id of the keep upgrade. Only the low 16 bits are used.- targetLevel
number– Level the upgrade should go to. The stock UI uses the same call for raising and for lowering a level.
Returns
Nothing.
Details
- The request is sent as an interaction with the object the player last interacted with. Nothing is sent if there is no such object or if the network connection is not ready.
- The client does not check the id, the level, or the cost; the server decides.
- The stock keep upgrade window first calls CancelKeepUpgrade when an upgrade is running in the opposite direction, then calls this function.
- The function needs at least two arguments and only reads the last two.
Errors
None besides the generic Invalid Parameters message when an argument is not a number.
Example
From default/ea_interactionwindow/source/interactionkeepupgrades.lua (EA_Window_InteractionKeepUpgrades.OnSave):
if (keepUpgrade.targetLevel < keepUpgrade.currentLevel) then
-- User is currently downgrading. We need to cancel the downgrade first.
CancelKeepUpgrade(keepUpgrade.id)
end
...
EA_Window_InteractionKeepUpgrades.AddUpgradeToActiveList(keepUpgrade.id)
PurchaseKeepUpgrade(keepUpgrade.id, keepUpgrade.localTargetLevel)
