From 3434ef47d913ea9a80c65bb4bb21e785e66616fd Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 12 Oct 2022 09:32:51 +0200 Subject: [PATCH 1/2] #STATIC * Add Life0 to STATIC Object * Added functions for STATIC:GetLife() and STATIC:GetLife0() --- Moose Development/Moose/Wrapper/Static.lua | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Moose Development/Moose/Wrapper/Static.lua b/Moose Development/Moose/Wrapper/Static.lua index 08c9a0bce..fef0b098d 100644 --- a/Moose Development/Moose/Wrapper/Static.lua +++ b/Moose Development/Moose/Wrapper/Static.lua @@ -55,9 +55,33 @@ STATIC = { function STATIC:Register( StaticName ) local self = BASE:Inherit( self, POSITIONABLE:New( StaticName ) ) self.StaticName = StaticName + + local DCSStatic = StaticObject.getByName( self.StaticName ) + if DCSStatic then + local Life0 = DCSStatic:getLife() or 1 + self.Life0 = Life0 + end + return self end +--- Get initial life points +-- @param #STATIC self +-- @return #number lifepoints +function STATIC:GetLife0() + return self.Life0 or 1 +end + +--- Get current life points +-- @param #STATIC self +-- @return #number lifepoints or nil +function STATIC:GetLife() + local DCSStatic = StaticObject.getByName( self.StaticName ) + if DCSStatic then + return DCSStatic:getLife() or 1 + end + return nil +end --- Finds a STATIC from the _DATABASE using a DCSStatic object. -- @param #STATIC self From cd99c053df03023a076b102aefcfae6a0b4550a9 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 12 Oct 2022 16:21:55 +0200 Subject: [PATCH 2/2] #SCENERY * Clarification in docu for :FindByName() --- Moose Development/Moose/Wrapper/Scenery.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Scenery.lua b/Moose Development/Moose/Wrapper/Scenery.lua index 445154037..0902bc269 100644 --- a/Moose Development/Moose/Wrapper/Scenery.lua +++ b/Moose Development/Moose/Wrapper/Scenery.lua @@ -27,7 +27,7 @@ -- -- @field #SCENERY SCENERY = { - ClassName = "SCENERY", + ClassName = "SCENERY", } @@ -58,10 +58,10 @@ function SCENERY:GetThreatLevel() return 0, "Scenery" end ---- Find a SCENERY object by it's name/id. +--- Create a SCENERY object from it's name/id. --@param #SCENERY self --@param #string name The name/id of the scenery object as taken from the ME. Ex. '595785449' ---@return #SCENERY Scenery Object or nil if not found. +--@return #SCENERY Scenery Object - **Note** this might not point to anything useful. Check with `myscenery:IsAlive()` if it is valid. function SCENERY:FindByName(name) local findAirbase = function () local airbases = AIRBASE.GetAllAirbases()