Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I have made some little LUA and MACRO files for different aircrafts the last weeks and d'like to share them here.

LUA commands

To get acces to the single commands you have to do the following:

1) copy the code below

2) insert it into an empty editor or wordpad file and save it as e.g. J41.LUA

3) open FSUIPC menu and choose LUA J41 from the drop down

4) insert different parameter numbers depending on the action you want (green field)

fr6tcbg5.jpg

parameter numbers for the CAT:

-- 1 = floats down

-- 2 = floats up

-- 3 = Carb Heat L up

-- 4 = Carb heat L neutral

-- 5 = Carb Heat L down

-- 6 = Carb Heat L up

-- 7 = Carb heat L neutral

-- 8 = Carb Heat L down

-- 9 = Primer L toggle

-- 10 = Primer R toggle

-- 11 = Starter L toggle

-- 12 = Starter R toggle

-- 13 = Mixture Levers Full Rich

-- 14 = Mixture Levers Auto Rich

-- 15 = Mixture Levers Auto Lean

-- 16 = Mixture Levers Cutoff

-- 17 = Both Fuel selectors OFF

-- 18 = Both Fuel selectors ON - Both

-- 19 = Gyro Pilot (AP) toggle

-- 20 = Gyro Pilot (AP) ON

-- 21 = Gyro Pilot (AP) OFF

-- 24 = Sperry Gain Elevator ON/OFF (value 3.5)

-- 27 = Sperry Gain Aileron ON/OFF (value 3.5)

-- 30 = Sperry Gain Rudder ON/OFF (value 3.5)

-- 31 = Ignition ON and Magnetos both

-- 32 = toggle master battery

-- param nr
-- 1 = floats down
-- 2 = floats up
-- 3 = Carb Heat L up
-- 4 = Carb heat L neutral
-- 5 = Carb Heat L down
-- 6 = Carb Heat L up
-- 7 = Carb heat L neutral
-- 8 = Carb Heat L down
-- 9 = Primer L toggle
-- 10 = Primer R toggle
-- 11 = Starter L toggle
-- 12 = Starter R toggle
-- 13 = Mixture Levers Full Rich
-- 14 = Mixture Levers Auto Rich
-- 15 = Mixture Levers Auto Lean
-- 16 = Mixture Levers Cutoff
-- 17 = Both Fuel selectors OFF
-- 18 = Both Fuel selectors ON - Both
-- 19 = Gyro Pilot (AP) toggle
-- 20 = Gyro Pilot (AP) ON
-- 21 = Gyro Pilot (AP) OFF
-- 24 = Sperry Gain Elevator ON/OFF (value 3.5)
-- 27 = Sperry Gain Aileron ON/OFF (value 3.5)
-- 30 = Sperry Gain Rudder ON/OFF (value 3.5)
-- 31 = Ignition ON and Magnetos both
-- 32 = toggle master battery

-- Floats down
if ipcPARAM == 1 then   

	ipc.writeLvar("L:Cat_float", 2)
	ipc.sleep(3000)
	ipc.writeLvar("L:Cat_float", 0)



-- Floats up
elseif ipcPARAM == 2 then   

	ipc.writeLvar("L:Cat_float", 1)
	ipc.sleep(3000)
	ipc.writeLvar("L:Cat_float", 0)


-- Carb heat L up
elseif ipcPARAM == 3 then   

	ipc.writeLvar("Carbheat_pos_L", 1)

-- Carb heat L neutral
elseif ipcPARAM == 4 then   


	ipc.writeLvar("Carbheat_pos_L", 0)
	ipc.writeLvar("L:CAT_SWITCH_OFF", 1)

-- Carb heat L down
elseif ipcPARAM == 5 then   

	ipc.writeLvar("Carbheat_pos_L", 2)


-- Carb heat R up
elseif ipcPARAM == 6 then   

	ipc.writeLvar("Carbheat_pos_R", 1)


-- Carb heat R neutral
elseif ipcPARAM == 7 then   

	ipc.writeLvar("Carbheat_pos_R", 0)
	ipc.writeLvar("L:CAT_SWITCH_OFF", 1)


-- Carb heat R down
elseif ipcPARAM == 8 then   

	ipc.writeLvar("Carbheat_pos_R", 2)



-- Primer L Toggle
elseif ipcPARAM == 9 then

    Cat_prime = "L:Cat_prime"
    val = 0

    if ipc.readLvar(Cat_prime) == 0  then
       val = 2

    end
    ipc.writeLvar(Cat_prime, val)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)



-- Primer R Toggle
elseif ipcPARAM == 10 then

    Cat_prime = "L:Cat_prime"
    val = 0

    if ipc.readLvar(Cat_prime) == 0  then
       val = 1

    end
    ipc.writeLvar(Cat_prime, val)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)




-- Starter L Toggle
elseif ipcPARAM == 11 then


    Cat_starter = "L:Cat_starter"
    val = 0

    if ipc.readLvar(Cat_starter) == 0  then
       val = 2

    end
    ipc.writeLvar(Cat_starter, val)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)



-- Starter R Toggle
elseif ipcPARAM == 12 then

    Cat_starter = "L:Cat_starter"
    val = 0

    if ipc.readLvar(Cat_starter) == 0  then
       val = 1

    end
    ipc.writeLvar(Cat_starter, val)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)




-- Both Mixture Lever Full Rich
elseif ipcPARAM == 13 then

	ipc.writeLvar("L:Cat_mixture_L_pos", 0)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:Cat_mixture_R_pos", 0)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_L", 0)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_R", 0)

-- Both Mixture Lever Auto Rich
elseif ipcPARAM == 14 then

	ipc.writeLvar("L:Cat_mixture_L_pos", 25)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:Cat_mixture_R_pos", 25)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_L", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_R", 1)

-- Both Mixture Lever Auto Lean
elseif ipcPARAM == 15 then

	ipc.writeLvar("L:Cat_mixture_L_pos", 50)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:Cat_mixture_R_pos", 50)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_L", 2)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_R", 2)

-- Both Mixture Lever Cutoff
elseif ipcPARAM == 16 then

	ipc.writeLvar("L:Cat_mixture_L_pos", 75)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:Cat_mixture_R_pos", 75)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_L", 3)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_R", 3)



-- Both Fuel selectors OFF
elseif ipcPARAM == 17 then

	ipc.control(66516)
	ipc.sleep(100)
	ipc.control(65955)

-- Both Fuel selectors ON - Both
elseif ipcPARAM == 18 then

	ipc.control(66517)
	ipc.sleep(100)
	ipc.control(65956)



-- Gyro Pilot (AP) toggle
elseif ipcPARAM == 19 then


    AP_Lever = "L:Cat_AP_Lever"

	val = 0
    if ipc.readLvar(AP_Lever) == 0 then
       val = 1
    end
    ipc.writeLvar(AP_Lever, val)
    ipc.writeLvar("L:CAT_LEVER", 1)


-- Gyro Pilot (AP) ON
elseif ipcPARAM == 20 then

	ipc.writeLvar("L:Cat_AP_Lever", 1)
	ipc.writeLvar("L:CAT_LEVER", 1)




-- Gyro Pilot (AP) OFF
elseif ipcPARAM == 21 then

	ipc.writeLvar("L:Cat_AP_Lever", 0)
	ipc.writeLvar("L:CAT_LEVER", 1)





-- Sperry Gain Elevator ON/OFF (value 3.5)
elseif ipcPARAM == 24 then

    gain_elev = "L:Sperry_gain_elevator"
    val = 0
    if ipc.readLvar(gain_elev)        val = 44
    end
    ipc.writeLvar(gain_elev, val)




-- Sperry Gain Aileron ON/OFF (value 3.5)
elseif ipcPARAM == 27 then


    gain_aileron = "L:Sperry_gain_aileron"
    val = 0
    if ipc.readLvar(gain_aileron)        val = 44
    end
    ipc.writeLvar(gain_aileron, val)



-- Sperry Gain Rudder ON/OFF (value 3.5)
elseif ipcPARAM == 30 then

    gain_rudder = "L:Sperry_gain_rudder"
    val = 0
    if ipc.readLvar(gain_rudder)        val = 44
    end
    ipc.writeLvar(gain_rudder, val)


-- Ignition ON and Magnetos both
elseif ipcPARAM == 31 then

	ipc.control(66026)
	ipc.writeLvar("L:CAT_SWITCH_OFF", 1)
ipc.sleep(300)
	ipc.control(66535)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)



elseif ipcPARAM == 32 then

	Cat_master = "L:Cat_master_batt_OFF"
	val = 0
	if ipc.readLvar(Cat_master) == 0 then
		val = 1
	end
	ipc.writeLvar(Cat_master, val)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)


end

upd 19th Dez 09

I have made a second file of commands, because I have made a new hardware switch panel and needed some new commands (e.g. On/Off instead of toggle)

also there are some new functions: APU and APU Generator toggle

Because the parameter numbers have changed I insert here a second code. If you want these new codes you have to copy them out or copy the hole file and change parameters

-- 1 = floats down

-- 2 = floats up

-- 3 = Carb Heat L up

-- 4 = Carb heat L neutral

-- 5 = Carb Heat L down

-- 6 = Carb Heat R up

-- 7 = Carb heat R neutral

-- 8 = Carb Heat R down

-- 9 = Primer L ON

-- 10 = Primer OFF

-- 11 = Primer R ON

-- 12 = Primer L Toggle

-- 13 = Primer R Toggle

-- 14 = Starter L ON

-- 15 = Starter OFF

-- 16 = Starter R ON

-- 17 = Mixture Levers Full Rich

-- 18 = Mixture Levers Auto Rich

-- 19 = Mixture Levers Auto Lean

-- 20 = Mixture Levers Cutoff

-- 21 = Both Fuel selectors OFF

-- 22 = Both Fuel selectors ON - Both

-- 23 = Left Fuel selectors OFF

-- 24 = Right Fuel selectors OFF

-- 25 = Left Fuel selector ON

-- 26 = Right Fuel selector ON

-- 27 = Gyro Pilot (AP) toggle

-- 28 = Gyro Pilot (AP) ON

-- 29 = Gyro Pilot (AP) OFF

-- 30 = Sperry Gain Elevator ON/OFF (value 3.5)

-- 31 = Sperry Gain Aileron ON/OFF (value 3.5)

-- 32 = Sperry Gain Rudder ON/OFF (value 3.5)

-- 33 = Ignition ON and Magnetos both

-- 34 = toggle master battery

-- 35 = Master Battery OFF

-- 36 = Master Battery ON

-- 37 = APU toggle

-- 38 = APU Gen toggle

-- param nr
-- 1 = floats down
-- 2 = floats up
-- 3 = Carb Heat L up
-- 4 = Carb heat L neutral
-- 5 = Carb Heat L down
-- 6 = Carb Heat R up
-- 7 = Carb heat R neutral
-- 8 = Carb Heat R down
-- 9 = Primer L ON
-- 10 = Primer OFF
-- 11 = Primer R ON

-- 12 = Primer L Toggle
-- 13 = Primer R Toggle

-- 14 = Starter L ON
-- 15 = Starter OFF
-- 16 = Starter R ON


-- 17 = Mixture Levers Full Rich
-- 18 = Mixture Levers Auto Rich
-- 19 = Mixture Levers Auto Lean
-- 20 = Mixture Levers Cutoff

-- 21 = Both Fuel selectors OFF
-- 22 = Both Fuel selectors ON - Both

-- 23 = Left Fuel selectors OFF
-- 24 = Right Fuel selectors OFF

-- 25 = Left Fuel selector ON
-- 26 = Right Fuel selector ON


-- 27 = Gyro Pilot (AP) toggle
-- 28 = Gyro Pilot (AP) ON
-- 29 = Gyro Pilot (AP) OFF
-- 30 = Sperry Gain Elevator ON/OFF (value 3.5)
-- 31 = Sperry Gain Aileron ON/OFF (value 3.5)
-- 32 = Sperry Gain Rudder ON/OFF (value 3.5)
-- 33 = Ignition ON and Magnetos both
-- 34 = toggle master battery
-- 35 = Master Battery OFF
-- 36 = Master Battery ON

-- 37 = APU toggle
-- 38 = APU Gen toggle

-- Floats down
if ipcPARAM == 1 then   

	ipc.writeLvar("L:Cat_float", 2)
	ipc.sleep(3000)
	ipc.writeLvar("L:Cat_float", 0)



-- Floats up
elseif ipcPARAM == 2 then   

	ipc.writeLvar("L:Cat_float", 1)
	ipc.sleep(3000)
	ipc.writeLvar("L:Cat_float", 0)


-- Carb heat L up
elseif ipcPARAM == 3 then   

	ipc.sleep(2)
	ipc.writeLvar("Carbheat_pos_L", 1)

-- Carb heat L neutral
elseif ipcPARAM == 4 then   


	ipc.writeLvar("Carbheat_pos_L", 0)
	ipc.writeLvar("L:CAT_SWITCH_OFF", 1)

-- Carb heat L down
elseif ipcPARAM == 5 then   

	ipc.sleep(2)
	ipc.writeLvar("Carbheat_pos_L", 2)


-- Carb heat R up
elseif ipcPARAM == 6 then   

	ipc.sleep(2)
	ipc.writeLvar("Carbheat_pos_R", 1)


-- Carb heat R neutral
elseif ipcPARAM == 7 then   

	ipc.writeLvar("Carbheat_pos_R", 0)
	ipc.writeLvar("L:CAT_SWITCH_OFF", 1)


-- Carb heat R down
elseif ipcPARAM == 8 then   

	ipc.sleep(2)
	ipc.writeLvar("Carbheat_pos_R", 2)



-- Primer L ON
elseif ipcPARAM == 9 then

	ipc.writeLvar("L:Cat_prime", 2)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)

-- Primer OFF
elseif ipcPARAM == 10 then

	ipc.writeLvar("L:Cat_prime", 0)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)

-- Primer R ON
elseif ipcPARAM == 11 then

	ipc.writeLvar("L:Cat_prime", 1)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)



-- Primer L Toggle
elseif ipcPARAM == 12 then

    Cat_prime = "L:Cat_prime"
    val = 0

    if ipc.readLvar(Cat_prime) == 0  then
       val = 2

    end
    ipc.writeLvar(Cat_prime, val)
   ipc.writeLvar("L:CAT_SWITCH_ON", 1)



-- Primer R Toggle
elseif ipcPARAM == 13 then

    Cat_prime = "L:Cat_prime"
    val = 0

    if ipc.readLvar(Cat_prime) == 0  then
       val = 1

    end
    ipc.writeLvar(Cat_prime, val)
   ipc.writeLvar("L:CAT_SWITCH_ON", 1)





-- Starter L ON
elseif ipcPARAM == 14 then


    ipc.writeLvar("L:Cat_starter", 2)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)



-- Starter OFF
elseif ipcPARAM == 15 then

   ipc.writeLvar("L:Cat_starter", 0)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)


-- Starter OFF
elseif ipcPARAM == 16 then

   ipc.writeLvar("L:Cat_starter", 1)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)



-- Both Mixture Lever Full Rich
elseif ipcPARAM == 17 then

	ipc.writeLvar("L:Cat_mixture_L_pos", 0)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:Cat_mixture_R_pos", 0)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_L", 0)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_R", 0)

-- Both Mixture Lever Auto Rich
elseif ipcPARAM == 18 then

	ipc.writeLvar("L:Cat_mixture_L_pos", 25)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:Cat_mixture_R_pos", 25)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_L", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_R", 1)

-- Both Mixture Lever Auto Lean
elseif ipcPARAM == 19 then

	ipc.writeLvar("L:Cat_mixture_L_pos", 50)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:Cat_mixture_R_pos", 50)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_L", 2)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_R", 2)

-- Both Mixture Lever Cutoff
elseif ipcPARAM == 20 then

	ipc.writeLvar("L:Cat_mixture_L_pos", 75)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:Cat_mixture_R_pos", 75)
	ipc.writeLvar("L:CAT_LEVER", 1)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_L", 3)
	ipc.sleep(50)
	ipc.writeLvar("L:A_MIX_MODE_R", 3)





-- Both Fuel selectors OFF
elseif ipcPARAM == 21 then

	ipc.control(66516)
	ipc.sleep(100)
	ipc.control(65955)



-- Both Fuel selectors ON - Both
elseif ipcPARAM == 22 then

	ipc.control(66517)
	ipc.sleep(100)
	ipc.control(65956)




-- Left Fuel selector OFF
elseif ipcPARAM == 23 then


	ipc.control(65955)

-- Right Fuel selector OFF
elseif ipcPARAM == 24 then

	ipc.control(66516)



-- Left Fuel selector ON

elseif ipcPARAM == 25 then


	ipc.control(65956)

-- Right Fuel selector ON

elseif ipcPARAM == 26 then

	ipc.control(66517)






-- Gyro Pilot (AP) toggle
elseif ipcPARAM == 27 then


    AP_Lever = "L:Cat_AP_Lever"

	val = 0
    if ipc.readLvar(AP_Lever) == 0 then
       val = 1
    end
    ipc.writeLvar(AP_Lever, val)
    ipc.writeLvar("L:CAT_LEVER", 1)




-- Gyro Pilot (AP) ON
elseif ipcPARAM == 28 then

	ipc.writeLvar("L:Cat_AP_Lever", 1)
	ipc.writeLvar("L:CAT_LEVER", 1)




-- Gyro Pilot (AP) OFF
elseif ipcPARAM == 29 then

	ipc.writeLvar("L:Cat_AP_Lever", 0)
	ipc.writeLvar("L:CAT_LEVER", 1)





-- Sperry Gain Elevator ON/OFF (value 3.5)
elseif ipcPARAM == 30 then

    gain_elev = "L:Sperry_gain_elevator"
    val = 0
    if ipc.readLvar(gain_elev)        val = 44
    end
    ipc.writeLvar(gain_elev, val)




-- Sperry Gain Aileron ON/OFF (value 3.5)
elseif ipcPARAM == 31 then


    gain_aileron = "L:Sperry_gain_aileron"
    val = 0
    if ipc.readLvar(gain_aileron)        val = 44
    end
    ipc.writeLvar(gain_aileron, val)



-- Sperry Gain Rudder ON/OFF (value 3.5)
elseif ipcPARAM == 32 then

    gain_rudder = "L:Sperry_gain_rudder"
    val = 0
    if ipc.readLvar(gain_rudder)        val = 44
    end
    ipc.writeLvar(gain_rudder, val)


-- Ignition ON and Magnetos both
elseif ipcPARAM == 33 then

	ipc.control(66026)
	ipc.writeLvar("L:CAT_SWITCH_OFF", 1)
ipc.sleep(300)
	ipc.control(66535)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)



-- Master Battery
elseif ipcPARAM == 34 then

	Cat_master = "L:Cat_master_batt_OFF"
	val = 0
	if ipc.readLvar(Cat_master) == 0 then
		val = 1
	end
	ipc.writeLvar(Cat_master, val)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)

-- Master Battery OFF
elseif ipcPARAM == 35 then

	ipc.writeLvar("L:Cat_master_batt_OFF", 0)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)

-- Master Battery ON

elseif ipcPARAM == 36 then

	ipc.writeLvar("L:Cat_master_batt_OFF", 1)
	ipc.writeLvar("L:CAT_SWITCH_ON", 1)



-- APU toggle

elseif ipcPARAM == 37 then

	Cat_APU_run = "L:Cat_APU_run"
    val = 0

    if ipc.readLvar(Cat_APU_run) == 0  then
       val = 2


	elseif ipc.readLvar(Cat_APU_run) == 1  then
       val = 0

    end

    	ipc.writeLvar("L:CAT_SWITCH_ON", 1)
	ipc.writeLvar("L:Cat_apu_control", val)


-- APU Gen toggle
elseif ipcPARAM == 38 then

	Cat_APU_gen = "L:Cat_APU_gen"
    val = 0

    if ipc.readLvar(Cat_APU_gen) == 0  then
       val = 1


    end

    	ipc.writeLvar("L:CAT_SWITCH_ON", 1)
	ipc.writeLvar("L:Cat_APU_Gen", val)



end

All files work at my system with latest FSUIPC version.

no guarantee that they will work for you (but they should, I'm sure - tested only at FSX Acceleration)

Do any codings at your own risk and just do things if you know what you do...

Be patient that I could not support any question. Please inform yourself how to handle MACROS and LUA files and the power of FSUIPC.

Have fun!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.