Avec des jauges non linéaires, c'est un peu plus complexe à régler.
C'est corrigé normalement, voici le nouveau code, à remplacer directement dans la jauge, désolé...

- Code: Tout sélectionner
-------------------------------------------
-- DR400 Airpeed indicator with vibrating needle
-- Jacques ZAHAR 08/2017
-- sur une idée de CGOA Benoît (Aircockpit)
---------------------------------------------------
-- CUSTOMIZATION VARIABLES ------
display_bezel=true
-- sample Values for a modern single engine (Cessna, Piper, Robin)
frequency=40 -- increase the 40 value to slow down the overall vibrations for "slow running" engines (up to 100 max)
vibmax=80 --beginning of max vibrations in %power
valmax=0.05 -- range of max vibration values
vibmid=30 --beginning of medium vibrations in %power
valmid=0.07
viblow=0.5 -- low idle
vallow=0.09
-- sample Values for a WWI Fighter
-- frequency=60 -- increase the 40 value to slow down the overall vibrations for "slow running" engines (up to 100 max)
-- vibmax=90 --beginning of max vibrations in %power
-- valmax=0.5 -- range of max vibration values
-- vibmid=30 --beginning of medium vibrations in %power
-- valmid=1
-- viblow=0.25 -- low idle
-- vallow=2
-- sample values for a WW1 Fighter
-- frequency=70 -- increase the 40 value to slow down the overall vibrations for "slow running" engines (up to 100 max)
-- vibmax=75 --beginning of max vibrations in %power
-- valmax=4 -- range of max vibration values
-- vibmid=40 --beginning of medium vibrations in %power
-- valmid=2.5
-- viblow=0.1 --low idle
-- vallow=3.5
----------------------------------------------
img_add_fullscreen("fond.png")
img_neddle = img_add_fullscreen("aiguille.png")
if display_bezel==true then
img_add_fullscreen("bezel.png")
end
img_rotate(img_neddle, 0)
local needleairspeed=0
local rand=1
local val=0
local vibrationlvl=0
-------------- Variation de luminosité en fonction de l'éclairage---------
D_mask = img_add_fullscreen("masque_Day.png")
K_mask = img_add_fullscreen("masque_Dusk.png")
N_mask = img_add_fullscreen("masque_Night.png")
------------- le code commenté est en cas d'ajout de dial (non utile ici)
-- function callback(turn)
-- print("turn:"..turn)
-- end
-- dial_id = dial_add("airknobjour.png", 100,100,100,100,callback)
-- dial_iddusk = dial_add("airknobdusk.png", 100,100,100,100,callback)
-- dial_idnuit = dial_add("airknobnuit.png", 100,100,100,100,callback)
-- dial_idjour = dial_add("airknobjour.png", 100,100,100,100,callback)
function new_light_FSX(tension,light,ambiance)
local panel_lighted= nil
panel_lighted= tension>14 and light
img_visible(D_mask,panel_lighted == false and ambiance==1)
img_visible(K_mask,panel_lighted == false and ambiance==2)
img_visible(N_mask,panel_lighted == false and ambiance==3)
-- visible(dial_idnuit,panel_lighted == false and ambiance==3)
-- visible(dial_iddusk,panel_lighted == false and ambiance==2)
-- visible(dial_idjour,panel_lighted == false and ambiance==1)
end
fsx_variable_subscribe("ELECTRICAL MAIN BUS VOLTAGE","Volts","LIGHT PANEL","Bool" ,"TIME OF DAY","Enum",new_light_FSX)
--]]
---------- Gestion des vibrations aiguille
function vibrate(soundrpm)
if soundrpm<0.1 then
vibrationlvl=0
else vibrationlvl=soundrpm
end
end
function vibrate_xp(rpm)
if rpm<0.1 then
vibrationlvl=0
else vibrationlvl=rpm
end
end
function timer_callback() -- function called every 40 mseconds,
rand=-rand -- offset value of the needle, alternatively to the left or to the right
--setting up of the amplitude of vibrations depending of the % of sound produced, since engien vibration is not reliable (Change val values to taste!)
if vibrationlvl>vibmax then -- high rpm, small amplitude
val=valmax
elseif vibrationlvl>vibmid then -- medium range rpm, larger amplitude of needle movements
val=valmid
elseif vibrationlvl>viblow then --slow rpm, smaller amplitude of needle movements
val=vallow
else -- engine stopped, no needle movements
val=0
end
needlepos=needleairspeed+(rand*val) -- calculation of the needle movement
if needleairspeed>=150 then
img_rotate(img_neddle, (needlepos-150)*2.15+287)
elseif needleairspeed>=130 then
img_rotate(img_neddle, (needlepos-130)*2.55+236)
elseif needleairspeed>80 then
img_rotate(img_neddle, (needlepos-80)*2.436+114)
elseif needleairspeed>=40 then
img_rotate(img_neddle, (needlepos-40)*2.25+23)
elseif needleairspeed>=30 then
img_rotate(img_neddle, (needlepos-30)*1.6+7)
else
img_rotate(img_neddle, (needlepos))
end
end
-- 30-->-173
-- 40-->-157
function PT_airspeed(airspeed)
-- rotate the needle only if airspeed is above 25kts
needleairspeed = var_cap(airspeed,0, 170)
if needleairspeed<30 then needleairspeed=0 end
end
xpl_dataref_subscribe("sim/cockpit2/gauges/indicators/airspeed_kts_pilot", "FLOAT", PT_airspeed)
fsx_variable_subscribe("AIRSPEED INDICATED", "knots", PT_airspeed)
-- init the needle
fsx_variable_subscribe("GENERAL ENG COMBUSTION SOUND PERCENT:1","percent",vibrate)
-- init the needle
PT_airspeed(0)
timer_start(0,frequency,timer_callback)
PS/ la version XPlane ne fonctionne pas pour l'instant.
Sinon c'est purement cosmétique, mais j'ai légèrement modifié le fond de jauge pour que les arcs cachent les graduations qui dépassent, mais c'est une affaire de goût.

Image à dezipper et à copier dans le dossier ressources et écraser l'existant.
j'arrête là, sinon je vais y passer la nuit

Jacques