Jump to content

HOTAS Warthog mit FlyWithLua nutzen / Beispiel


ifredn

Recommended Posts

require("bit")

if (PLANE_ICAO == "A320") or (PLANE_ICAO == "A330") then

--- load sound files into table
snd_battery = load_WAV_file(SCRIPT_DIRECTORY .. "sounds/batteries.wav")
snd_radio = load_WAV_file(SCRIPT_DIRECTORY .. "sounds/atcchatter.wav")
let_sound_loop(snd_battery, true)
let_sound_loop(snd_radio, true)
set_sound_gain(snd_radio, 0.30)
set_sound_gain(snd_battery, 0.30)


create_switch(664, "sim/cockpit/switches/no_smoking")
create_switch(663, "sim/cockpit/switches/fasten_seat_belts")
create_switch(666, "sim/custom/xap/extlight/strobe_sw")
create_switch(655, "sim/custom/xap/engines/eng1msw")
create_switch(656, "sim/custom/xap/engines/eng2msw")
create_switch(652, "sim/custom/xap/radio/on")

--- Batteries
create_switch(657, "sim/custom/xap/elec/bat1_on")
create_switch(658, "sim/custom/xap/elec/bat2_on")
--- Dataref for Battery_Sound_Check
dataref ("a320battery1", "sim/custom/xap/elec/bat1_on")
dataref ("a320battery2", "sim/custom/xap/elec/bat2_on")
dataref ("a320radio", "sim/custom/xap/radio/on")
---BatSoundPlayed = false

---play_sound(snd_battery)

battery_sound_playing = 0
radiochatter_playing = 0

do_every_frame("check_for_battery_state()")
do_every_frame("check_for_radio()")


function check_for_battery_state()
	if a320battery1 == 0 and battery_sound_playing == 1 then stop_battery_sound() end
	if a320battery1 == 1 and a320battery2 == 1 and battery_sound_playing == 0 then start_battery_sound() end

end


function check_for_radio()
	if a320radio == 0 and radiochatter_playing == 1 then stop_radio_sound() end
	if a320radio == 1 and radiochatter_playing == 0 then start_radio_sound() end

end



function start_radio_sound()
play_sound(snd_radio)
radiochatter_playing = 1
end

function stop_radio_sound()
stop_sound(snd_radio)
radiochatter_playing = 0
end




function start_battery_sound()
play_sound(snd_battery)
battery_sound_playing = 1
end

function stop_battery_sound()
stop_sound(snd_battery)
battery_sound_playing = 0
end





-- APU BLEED checked OK
--create_switch(657, "sim/custom/xap/bleed/apu_blvlv")

-- APU_MASTER
--create_switch(658, "sim/cockpit/engine/APU_switch")
--create_switch(658, "sim/cockpit2/electrical/APU_starter_switch")


-- APU_START - check button status every frame
-- overriding JARs temperatureplaythingie 

set ("sim/custom/xap/cond/fwd_knob", 24)
set ("sim/custom/xap/cond/ckpt_knob", 24)
set ("sim/custom/xap/cond/aft_knob", 24)



do_every_frame ( [[

--if button(659) == true then logMsg(string.format('659 an')) end


	if button(659) == true then apuvariable = 1
	apurunning = 0
 	end
	--if button(659) == true and apurunning == 1 then apuvariable = 0 end
	if button(659) == false and apurunning == 1 then stop_apu() end

	if apuvariable == 1 and apurunning == 0 then start_apu() end
	


]])
-- 658 f�r AVAIL
function start_apu()
	--set ("sim/cockpit2/electrical/APU_N1_percent", 100.0)
	--set ("sim/custom/xap/apu/flap", 100)
	--set ("sim/cockpit2/electrical/APU_starter_switch", 1)
	--set ("sim/custom/xap/bleed/mode_sw", 1)
	--set ("sim/custom/xap/apu/start_pb", 1)
	--set ("sim/custom/xap/bleed/apu_blvlv", 1)
	--set ("sim/cockpit2/electrical/APU_running", 1)

	
	--set ("sim/cockpit2/pressurization/actuators/bleed_air_mode", 4)
	apurunning = 1
	apuvariable = 0
end

function stop_apu()
	-- set ("sim/cockpit2/electrical/APU_starter_switch", 0)
	-- set ("sim/custom/xap/apu/start_pb", 0)
	-- set ("sim/cockpit2/electrical/APU_N1_percent", 0)
	-- set ("sim/custom/xap/bleed/apu_blvlv", 0)
	apurunning = 0
	
end


end

Moin,

ich habe ein kleines Script gemacht, welches meinen Warthog (speziell die Kippschalter) für den A320-Neo von Jar (und in der Beta auch den kommenden A330... aber pscht :)) nutzbar macht, wer Spaß dran hat, kann sich ja hier mal speziell die Switch-Geschichten anschauen und es verbessern / weiterverwenden.

Prost

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...