From 064e082a1221cbc5ae275bc3a33ec254b120d238 Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 3 Oct 2022 19:12:19 +0200 Subject: [PATCH] Airwing - Added `:IncreasePayloadAmount` function --- Moose Development/Moose/Ops/AirWing.lua | 38 +++++++++++++++++++++++++ Moose Development/Moose/Ops/Legion.lua | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index c8fbb1524..0dae8cb06 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -422,6 +422,44 @@ function AIRWING:SetPayloadAmount(Payload, Navailable) return self end +--- Increase or decrease the amount of available payloads. Unlimited playloads first need to be set to a limited number with the `SetPayloadAmount` function. +-- @param #AIRWING self +-- @param #AIRWING.Payload Payload The payload table created by the `:NewPayload` function. +-- @param #number N Number of payloads to be added. Use negative number to decrease amount. Default 1. +-- @return #AIRWING self +function AIRWING:IncreasePayloadAmount(Payload, N) + + N=N or 1 + + if Payload and Payload.navail>=0 then + + -- Increase/decrease amount. + Payload.navail=Payload.navail+N + + -- Ensure playload does not drop below 0. + Payload.navail=math.max(Payload.navail, 0) + + end + + return self +end + +--- Get amount of payloads available for a given playload. +-- @param #AIRWING self +-- @param #AIRWING.Payload Payload The payload table created by the `:NewPayload` function. +-- @return #number Number of payloads available. Unlimited payloads will return -1. +function AIRWING:GetPayloadAmount(Payload) + return Payload.navail +end + +--- Get capabilities of a given playload. +-- @param #AIRWING self +-- @param #AIRWING.Payload Payload The payload data table. +-- @return #table Capabilities. +function AIRWING:GetPayloadCapabilities(Payload) + return Payload.capabilities +end + --- Add a mission capability to an existing payload. -- @param #AIRWING self -- @param #AIRWING.Payload Payload The payload table to which the capability should be added. diff --git a/Moose Development/Moose/Ops/Legion.lua b/Moose Development/Moose/Ops/Legion.lua index 366d6a7d5..d2e0574e9 100644 --- a/Moose Development/Moose/Ops/Legion.lua +++ b/Moose Development/Moose/Ops/Legion.lua @@ -1854,7 +1854,7 @@ end --- Count total number of assets of the legion. -- @param #LEGION self --- @param #boolean InStock If true, only assets that are in the warehouse stock/inventory are counted. +-- @param #boolean InStock If `true`, only assets that are in the warehouse stock/inventory are counted. -- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types. -- @param #table Attributes (Optional) Count only assest that have a certain attribute(s), e.g. `WAREHOUSE.Attribute.AIR_BOMBER`. -- @return #number Amount of asset groups in stock.