HI Ralf
yes it is what i made but i have an issue i don't understand
i create 2 canvas
one is a vertical bar for the fuel in Left & Right Tank which works (the bar color change from green to red when tank is near empty)
and i add another 2 text canvas-draw with the fuel quantity for left & right tank and i have a error message i don't understand the sense
see attached screenshot
here the code of the fuel gauge
no ressources needed excepted this code
it is the _txt(.....) line 71 & 76 that generate the error , variables have values (see the print in console) , so i dont understand the error message
71 is _txt(V_TEMP_001 , V_TEMP_002, 0, 0) -- V_TEMP_001 = Text left fuel Qty , V_TEMP_002 = text style
76 is _txt(V_TEMP_011 , V_TEMP_012, 0, 0) -- V_TEMP_011 = Text right fuel Qty , V_TEMP_012 = text style
if you have an idea to help me
best regards
Thierry
------------------------------------------ code -------------------------------------------------------------
-- Author --- Thierry Georgelin
-- Aircraft --- Falcon 2000
-- Simulator --- FSX
---------------------------- Init global parametres -----------------------
V_FONT_SIZE = 48
V_FONT_NAME = "arialbd.ttf" ------- or "Monda-bold.ttf"
V_GREEN_COLOR = "#00FF00"
V_WHITE_COLOR = "white"
V_RED_COLOR = "red"
V_BLACK_COLOR = "black"
V_GALLON_TO_LB = 6.703
V_FUEL_LEFT_QTY_HIGH_BAR = 0
V_FUEL_RIGHT_QTY_HIGH_BAR = 0
V_FUEL_LEFT_QUANTITY_LB = 0.0
V_FUEL_RIGHT_QUANTITY_LB = 0.0
--------------------------------- Init Various ID -----------------------------------
T_FUEL_MAX_CURRENT_QUANTITY_NAME = txt_add("", "font:"..V_FONT_NAME.."; size:".. V_FONT_SIZE .." ; color:" ..V_WHITE_COLOR .. "; halign:center;", 301 , 201 , 200 , 100)
CI_BAR_FUEL_QUANTITY_LEFT = canvas_add(221 , 176 , 60, 200 ) -- Canvas image left bar
CI_BAR_FUEL_QUANTITY_RIGHT = canvas_add(451 , 176 , 60, 200) -- Canvas image right bar
CT_BACK_FRONT_FUEL_QUANTITY_LEFT = canvas_add(21 , 201 , 160, 100 ) -- Canvas Text left Qty fuel
CT_BACK_FRONT_FUEL_QUANTITY_RIGHT = canvas_add(601 , 201 , 160, 100) -- Canvas Right left Qty fuel
-------------------------------- Function for Fuel Informattions ----------------------------------------------------------------
function F_FUEL_MAX_CURRENT_QUANTITY(V_FUEL_LEFT_CAPACITY ,V_FUEL_RIGHT_CAPACITY , V_FUEL_LEFT_QUANTITY , V_FUEL_RIGHT_QUANTITY)
V_Test = true
txt_set(T_FUEL_MAX_CURRENT_QUANTITY_NAME, "QTY LB")
V_FUEL_LEFT_QTY_HIGH_BAR = math.floor(100 * (V_FUEL_LEFT_QUANTITY / V_FUEL_LEFT_CAPACITY)) -- 100 pixels left fuel bar max x (% of Fuel)
V_FUEL_LEFT_QUANTITY_LB = math.floor(V_FUEL_LEFT_QUANTITY * V_GALLON_TO_LB / 5) * 5 -- convertion Fuel left qty in LB rounded at 5
V_TEMP_001 = tostring(math.floor(V_FUEL_LEFT_QUANTITY_LB)) -- convertion Fuel left Qty LB in Text
V_FUEL_RIGHT_QTY_HIGH_BAR = math.floor(100 * (V_FUEL_RIGHT_QUANTITY / V_FUEL_RIGHT_CAPACITY)) -- 100 pixels right fuel bar max x (% of Fuel)
V_FUEL_RIGHT_QUANTITY_LB = math.floor(V_FUEL_RIGHT_QUANTITY * V_GALLON_TO_LB / 5) * 5 -- convertion right Fuel qty in LB rounded at 5
V_TEMP_011 = tostring(math.floor(V_FUEL_RIGHT_QUANTITY_LB)) -- convertion Fuel right Qty LB in Text
if V_Test == true then
print("Max Capa L = "..V_FUEL_LEFT_CAPACITY .. " Current Qty L = ".. V_FUEL_LEFT_QUANTITY)
print("Current Qty L & in LB = ".. V_FUEL_LEFT_QUANTITY_LB .. " & converted txt = " .. V_TEMP_001)
print("Max Capa R = "..V_FUEL_RIGHT_CAPACITY .. " Current Qty R = ".. V_FUEL_RIGHT_QUANTITY)
print("Current Qty R & in LB = ".. V_FUEL_RIGHT_QUANTITY_LB .. " & converted txt = " .. V_TEMP_011)
end
if V_FUEL_LEFT_QUANTITY_LB > 900 then -- check fuel Left qty in LB (if >900 then Bar and quantity are green on black background else Bar is red and Text is white on red background)
V_TEMP_002 = "font: " .. V_FONT_NAME .. " ; size: " .. V_FONT_SIZE .. " ; color: ".. V_GREEN_COLOR .. " ; halign: center ;" -- Text Style of left Qty LB
V_TEMP_003 = V_BLACK_COLOR -- Background color of left text canvas
V_TEMP_004 = V_GREEN_COLOR -- Fuel Left Quantity Bar color
else
V_TEMP_002 = "font:" .. V_FONT_NAME .. " ; size: " .. V_FONT_SIZE .. " ; color: ".. V_WHITE_COLOR .. " ; halign: center;" -- Text Style of left Qty LB
V_TEMP_003 = V_RED_COLOR -- Background color of left text canvas
V_TEMP_004 = V_RED_COLOR -- Fuel left Quantity Bar color
end
if V_FUEL_RIGHT_QUANTITY_LB > 900 then -- check fuel Right Qty in LB (if >900 then Bar and quantity are green on black background else Bar is red and Text is white on red background)
V_TEMP_012 = "font: " .. V_FONT_NAME .. " ; size: " .. V_FONT_SIZE .. " ; color: ".. V_GREEN_COLOR .. " ; halign: center ;" -- Text Style of right Qty LB
V_TEMP_013 = V_BLACK_COLOR -- Background color of right text canvas
V_TEMP_014 = V_GREEN_COLOR -- Fuel right Quantity Bar color
else
V_TEMP_012 = "font:" .. V_FONT_NAME .. " ; size: " .. V_FONT_SIZE .. " ; color: ".. V_WHITE_COLOR .. " ; halign: center;" -- Text Style of right Qty LB
V_TEMP_013 = V_RED_COLOR -- Background color of right text canvas
V_TEMP_014 = V_RED_COLOR -- Fuel right Quantity Bar color
end
if V_Test == true then
print("Background Left text color = " .. V_TEMP_003 .. " / Text style = " .. V_TEMP_002)
print("Fuel Quantity Left bar color = " .. V_TEMP_004)
print("Background Right text color = " .. V_TEMP_013 .. " / Text style = " .. V_TEMP_012)
print("Fuel Quantity Right bar color = " .. V_TEMP_014)
end
canvas_draw(CI_BAR_FUEL_QUANTITY_LEFT ,function() -- Bar of Fuel Quantity
_rect(0 , 0 , 60 , V_FUEL_LEFT_QTY_HIGH_BAR)
_fill(V_TEMP_004)
end)
canvas_draw(CI_BAR_FUEL_QUANTITY_RIGHT ,function() -- Bar of Fuel Quantity
_rect(0 , 0 , 60 , V_FUEL_RIGHT_QTY_HIGH_BAR)
_fill(V_TEMP_014)
end)
canvas_draw(CT_BACK_FRONT_FUEL_QUANTITY_LEFT , function() -- Text of Left Fuel Quantity
_rect(21 , 201 , 160, 100)
_txt(V_TEMP_001 , V_TEMP_002, 0, 0) -- V_TEMP_001 = Text Full Qty , V_TEMP_002 = text style
_fill(V_TEMP_003) -- Background color
end)
canvas_draw(CT_BACK_FRONT_FUEL_QUANTITY_RIGHT , function() -- Text of Right Fuel Quantity
_rect(601 , 201 , 160, 100)
_txt(V_TEMP_011 , V_TEMP_012, 0, 0) -- V_TEMP_011 = Text Full Qty , V_TEMP_012 = text style
_fill(V_TEMP_013) -- Background color
end)
end
------------------------------------- variables Subscription -----------------------------------------------------------------
fsx_variable_subscribe("FUEL LEFT CAPACITY" , "Gallons" , "FUEL RIGHT CAPACITY" , "Gallons"
, "FUEL LEFT QUANTITY" , "Gallons" , "FUEL RIGHT QUANTITY" , "Gallons" , F_FUEL_MAX_CURRENT_QUANTITY)