Si Jacques (ou d'autre bien sur) passe par la je vais essayé d'exposer mon probleme.
Je continue de créer mes jauges pour mon Twin.
J'ai un soucis avec la jauge Attitude. Pour l'instant le dessin n'est pas finalisé.

Voici mon problème :
Pour la manœuvre du "Flag" Gyro. Au lancement le "Flag" descend lentement et s'efface quand le "ELECTRICAL MASTER BATTERY"est sur 1.
Si il y a un problème sur le Bus elect la variable "PARTIAL PANEL ELECTRICAL" la valeur est différente de 0 et le "Flag" redescend.
Tout ceci fonctionne. Lorsque je veux faire la même chose avec le "Flag" Steer , c'est la qu'il y a problème.
Au lancement ce Flag descend lentement comme celui du Gyro, mais si je veux rajouter une variable pour qu'il s'efface
genre "AUTOPILOT MASTER" les deux flags ne fonctionne pas.
Je soupconne un probleme avec "timer callback"
J'ai voulu separer les deux timer, un qui se nomme "tmr_gyroflag" et l'autre "tmr_steerflag" mais ...

le code. J'ai mis deux -- sur une partie du code (à la fin) c'est cette partie qui ne fonctionne pas
- Code: Tout sélectionner
---------------------------------------------
-- Load and display images --
---------------------------------------------
img_add_fullscreen("background.png")
img_bg = img_add_fullscreen("attbackground.png")
img_horizon = img_add_fullscreen("atthorizon.png")
img_fd_horizontal = img_add_fullscreen("fd_horizontal.png")
img_fd_vertical = img_add_fullscreen("fd_vertical.png")
img_ring = img_add_fullscreen("attbankind.png")
img_gyroflag = img_add("gyroflag.png",330,-84,500,500)
img_steerflag = img_add("steerflag.png",-358,-78,500,500)
img_add_fullscreen("attfront.png")
---------------
-- Functions --
---------------
gyroflag_rotation = 0
gyroflag_state = 0
steerflag_rotation = 0
steerflag_state = 0
hoop_height = 0
function PT_atitude(roll, pitch, APmode, FDpitch, FDroll)
-- roll outer ring
img_rotate(img_ring, roll *-1)
-- roll horizon
img_rotate(img_horizon , roll * -1)
img_rotate(img_bg, roll *-1)
-- move horizon pitch
pitch = var_cap(pitch,-30,30)
radial = math.rad(roll * -1)
x = -(math.sin(radial) * pitch * 4.0)
y = (math.cos(radial) * pitch * 4.0)
img_move(img_horizon, x, y, nil, nil)
-- Flight director
-- Horizontal (pitch):
if APmode < 1 then
move(img_fd_horizontal, nil, 120, nil, nil)
else
move(img_fd_horizontal, nil, (FDpitch - pitch) * -4, nil, nil)
end
-- Vertical (roll):
if APmode < 1 then
move(img_fd_vertical, -120, nil, nil, nil)
else
move(img_fd_vertical, (FDroll - roll) * 4, nil, nil, nil)
end
end
function timer_callback()
if gyroflag_state == 1 then
-- extend
gyroflag_rotation = gyroflag_rotation - 0.2
if gyroflag_rotation <= -20 then
gyroflag_rotation = -20
timer_stop(tmr_gyroflag)
end
else
-- retract
gyroflag_rotation = gyroflag_rotation + 0.2
if gyroflag_rotation >= 2 then
gyroflag_rotation = 2
timer_stop(tmr_gyroflag)
end
end
if steerflag_state == 1 then
-- extend
steerflag_rotation = steerflag_rotation - 0.4
if steerflag_rotation <= -5then
steerflag_rotation = -5
timer_stop(tmr_steerflag)
end
else
-- retract
steerflag_rotation = steerflag_rotation + 0.4
if steerflag_rotation >= 20 then
steerflag_rotation = 20
timer_stop(tmr_steerflag)
end
img_rotate(img_gyroflag, gyroflag_rotation)
img_rotate(img_steerflag, steerflag_rotation)
end
end
function new_gyroflag_fsx(gyrofail,gyro )
if gyrofail > 0 or gyro == false then
gyroflag_state = 1
else
gyroflag_state = 0
end
timer_stop(tmr_gyroflag)
tmr_gyroflag = timer_start(0, 150, timer_callback)
end
-- function new_steerflag_fsx(steer )
-- if steer == false then
-- steerflag_state = 1
-- else
-- steerflag_state = 0
-- end
-- timer_stop(tmr_steerflag)
-- tmr_steerflag = timer_start(0, 150, timer_callback)
-- end
function new_attitude_fsx(roll, pitch, APmode, FDpitch, FDroll)
-- Convert boolean to INT
APmode = fif(APmode, 1, 0)
PT_atitude(roll * -1, pitch * -1, APmode, FDpitch * -1, FDroll * -1)
end
fsx_variable_subscribe("ATTITUDE INDICATOR BANK DEGREES", "Degrees",
"ATTITUDE INDICATOR PITCH DEGREES", "Degrees",
"AUTOPILOT FLIGHT DIRECTOR ACTIVE", "Bool",
"AUTOPILOT FLIGHT DIRECTOR PITCH", "degrees",
"AUTOPILOT FLIGHT DIRECTOR BANK", "degrees", new_attitude_fsx)
fsx_variable_subscribe("PARTIAL PANEL ELECTRICAL", "Enum",
"ELECTRICAL MASTER BATTERY", "Bool", new_gyroflag_fsx)
-- fsx_variable_subscribe("AUTOPILOT HEADING LOCK", "Bool", new_steerflag_fsx)
Si vous voyez qq chose qui cloche.
A+
Christian