----------------------------------------------------------------------------------------
---
-- Name: Simple Fuel Check Script
-- Author: Michael Normandeau
-- ak: "Norman99"
--
-- Version: 1.0
-- Date Created: 03 April 2021
--
----------------------------------------------------------------------------------------
--using VIACOM and adding a "Fuel Check" voice command
------------------------------------------------------------------------------------------------------- 
-- last
if not versionDCE then versionDCE = {} end
versionDCE["Mission Scripts/Fuel_Check.lua"] = "0.1.4"
------------------------------------------------------------------------------------------------------- 
-- Reglage_c						(c: Player & Client)(b: test all plane(description.fuelMassMax))
------------------------------------------------------------------------------------------------------- 

local imperialMetric = "imperial"

function FuelCheck(data)														-- create fuel check function	
	local coef  = 1
	if imperialMetric == "imperial" then
		 coef  =  2.205
	end

	-- local pu = world.getPlayer()											-- get player unit
	-- local pg = Unit.getGroup(pu)											-- get player group		
	-- local wingman = pg:getUnits()

	for _, unit in pairs(data.groupObject:getUnits()) do
	-- for n = 2, #wingman do
		-- local Nwingman = pg:getUnit(n)
		local qty = unit:getFuel()
		local description = unit:getDesc()
		qty = qty * description.fuelMassMax * coef							--F14 7348 kg
		qty = math.floor(qty/100)/10
		-- trigger.action.outText(Unit.getName(Nwingman)..":  "..qty,10,false)
		trigger.action.outTextForGroup(data.gpGid, Unit.getName(unit)..":  "..qty, 10, false)
	end
end

-- missionCommands.addCommand("Fuel Check",nil,FuelCheck)						-- add fuel check item to F10 menu & call fuelcheck function

