mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Added Fisher-Yeats table shuffle and Helicopter door check
This commit is contained in:
parent
18b45c9621
commit
29210f670c
@ -1504,3 +1504,63 @@ function UTILS.GetOSTime()
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Shuffle a table accoring to Fisher Yeates algorithm
|
||||||
|
--@param #table table to be shuffled
|
||||||
|
--@return #table
|
||||||
|
function UTILS.ShuffleTable(t)
|
||||||
|
if t == nil or type(t) ~= "table" then
|
||||||
|
BASE:I("Error in ShuffleTable: Missing or wrong tyåe of Argument")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
math.random()
|
||||||
|
math.random()
|
||||||
|
math.random()
|
||||||
|
local TempTable = {}
|
||||||
|
for i = 1, #t do
|
||||||
|
local r = math.random(1,#t)
|
||||||
|
TempTable[i] = t[r]
|
||||||
|
table.remove(t,r)
|
||||||
|
end
|
||||||
|
return TempTable
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (Helicopter) Check if one loading door is open.
|
||||||
|
--@param #string unit_name Unit name to be checked
|
||||||
|
--@return #boolean Outcome - true if a (loading door) is open, false if not, nil if none exists.
|
||||||
|
function UTILS.IsLoadingDoorOpen( unit_name )
|
||||||
|
|
||||||
|
local ret_val = false
|
||||||
|
local unit = Unit.getByName(unit_name)
|
||||||
|
if unit ~= nil then
|
||||||
|
local type_name = unit:getTypeName()
|
||||||
|
|
||||||
|
if type_name == "Mi-8MT" and unit:getDrawArgumentValue(86) == 1 or unit:getDrawArgumentValue(250) == 1 then
|
||||||
|
BASE:T(unit_name .. " Cargo doors are open or cargo door not present")
|
||||||
|
ret_val = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if type_name == "Mi-24P" and unit:getDrawArgumentValue(38) == 1 or unit:getDrawArgumentValue(86) == 1 then
|
||||||
|
BASE:T(unit_name .. " a side door is open")
|
||||||
|
ret_val = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if type_name == "UH-1H" and unit:getDrawArgumentValue(43) == 1 or unit:getDrawArgumentValue(44) == 1 then
|
||||||
|
BASE:T(unit_name .. " a side door is open ")
|
||||||
|
ret_val = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if string.find(type_name, "SA342" ) and unit:getDrawArgumentValue(34) == 1 or unit:getDrawArgumentValue(38) == 1 then
|
||||||
|
BASE:T(unit_name .. " front door(s) are open")
|
||||||
|
ret_val = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if ret_val == false then
|
||||||
|
BASE:T(unit_name .. " all doors are closed")
|
||||||
|
end
|
||||||
|
return ret_val
|
||||||
|
|
||||||
|
end -- nil
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user