Toujours dans ma recherche sur les vibrations d'aiguilles, voici le nouveau code avec des variables en debut de code pour jouer sur les 2 paramètres :
- gamme de rpm (ralenti, moyenne, et élevée) en %, dans notre cas de 0.0 (coupé) à 100 (plein pot) : vib
- écart de vibration des aiguilles en + ou en moins: val
En jouant sur ces paramètres on obtient de chouettes effets:
pour un tagazou genre Cessna ou Robin:
-- 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.15 -- range of max vibration values
vibmid=30 --beginning of medium vibrations in %power
valmid=0.35
viblow=0.25 -- low idle
vallow=0.22
pour un chasseur à hélice deuxième guerre
-- sample Values for a WWII 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
pour un avion de la première guerre
-- 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
- Code: Tout sélectionner
-- Airpeed indicator with vibrating needle
-------------------------------------------
-- CUSTOMIZATION VARIABLES ------
-- 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.15 -- range of max vibration values
vibmid=30 --beginning of medium vibrations in %power
valmid=0.35
viblow=0.25 -- low idle
vallow=0.22
-- sample Values for a WWII 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("airspeed_backdrop2.png")
img_neddle = img_add_fullscreen("neddle.png")
img_rotate(img_neddle, -38)
local needleairspeed=0
local rand=1
local val=0
local vibrationlvl=0
-------------- Varaition 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")
-- 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
img_rotate(img_neddle, needlepos*320/220 - 38)
end
function PT_airspeed(airspeed)
-- rotate the needle only if airspeed is above 25kts
needleairspeed = var_cap(airspeed, 25, 260)
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)
Jacques