Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Coded by Sirius
- -- Check with other files
- dofile(LockOn_Options.script_path.."command_defs.lua")
- dofile(LockOn_Options.script_path.."devices.lua")
- dofile(LockOn_Options.script_path.."mainpanel_init.lua")
- -- Declare self variables
- local gear_system = GetSelf()
- local dev = GetSelf()
- -- 0.01 rep. 1000th of second, by 10 ms.
- local update_time_step = 0.01
- make_default_activity(update_time_step)
- local sensor_data = get_base_data()
- -- Landing Gear
- local Gear = 68 -- Keys.iCommandPlaneGear
- -- local GearParam = get_param_handle("GEAR_LEVER")
- -- Movement dependencies
- local GEAR_STATE = 1
- local GEAR_STATE_PARAM = 1
- local GEAR_COMMAND = 0
- local GEAR_TIME_IN = update_time_step / 5 -- 5 reps sec.
- local GEAR_TIME_OUT = update_time_step / 3 -- 3 reps sec.
- local GEAR_TIME_PARAM = update_time_step / 2 -- 2 reps sec.
- local GEAR_WEIGHT = sensor_data:getWOW_LeftMainLandingGear() -- checks if gear suspension is in place, needed for ground check
- -- Wheelbrakes
- local BrakesOn = 74 -- Keys.iCommandWheelBrakeOn
- local BrakesOff = 75 -- Keys.iCommandWheelBrakeOff
- -- local LeftBrakeParam = get_param_handle("LEFT_TOEBRAKE")
- -- local RightBrakeParam = get_param_handle("RIGHT_TOEBRAKE")
- -- Movement dependencies
- local BRAKE_COMMAND = 0
- local BRAKE_STATE_PARAM = 0
- local BRAKE_TIME_PARAM = update_time_step / 1 -- 1 reps sec.
- -- Begin listening to the iCommands
- gear_system:listen_command(Gear)
- gear_system:listen_command(BrakesOn)
- gear_system:listen_command(BrakesOff)
- -- Sets up list of command events (prior to iCommands listened)
- function SetCommand(command,value)
- -- If the landing gear was called
- if command == Gear then
- if GEAR_COMMAND == 1 then
- GEAR_COMMAND = 0
- elseif GEAR_COMMAND == 0 then
- GEAR_COMMAND = 1
- end
- end
- -- If the wheelbrakes are being applied
- if command == BrakesOn then
- BRAKE_COMMAND = 1
- end
- -- If the wheelbrakes are not being applied
- if command == BrakesOff then
- BRAKE_COMMAND = 0
- end
- end
- -- Defines how gear animations should work
- function animate_gear()
- -- Comfortably assuming we are off the ground...
- if GEAR_WEIGHT == 0 then
- -- If the gear is supposed to be up and is down
- if GEAR_COMMAND == 0 and GEAR_STATE > 0 then
- GEAR_STATE = GEAR_STATE - GEAR_TIME_IN
- end
- -- If the gear is supposed to be down and is up
- if GEAR_COMMAND == 1 and GEAR_STATE < 1 then
- GEAR_STATE = GEAR_STATE + GEAR_TIME_OUT
- end
- -- Limit the gear movement when fully out
- if GEAR_STATE > 1 then
- GEAR_STATE = 1
- end
- -- Limit the gear movement when fully in
- if GEAR_STATE < 0 then
- GEAR_STATE = 0
- end
- end
- end
- -- Defines how cockpit animations should work
- function animate_cockpit()
- -- Comfortably assuming we are off the ground...
- if GEAR_WEIGHT == 0 then
- -- If the gear is supposed to be up and is down
- if GEAR_COMMAND == 0 and GEAR_STATE_PARAM > 0 then
- GEAR_STATE_PARAM = GEAR_STATE_PARAM - GEAR_TIME_PARAM
- end
- -- If the gear is supposed to be down and is up
- if GEAR_COMMAND == 1 and GEAR_STATE_PARAM < 1 then
- GEAR_STATE_PARAM = GEAR_STATE_PARAM + GEAR_TIME_PARAM
- end
- end
- -- Limit the gear movement when fully out
- if GEAR_STATE_PARAM > 1 then
- GEAR_STATE_PARAM = 1
- end
- -- Limit the gear movement when fully in
- if GEAR_STATE_PARAM < 0 then
- GEAR_STATE_PARAM = 0
- end
- -- If the wheelbrakes are being applied
- if BRAKE_COMMAND == 1 and BRAKE_STATE_PARAM < 1 then
- BRAKE_STATE_PARAM = BRAKE_STATE_PARAM + BRAKE_TIME_PARAM
- end
- -- If the wheelbrakes are not being applied
- if BRAKE_COMMAND == 0 and BRAKE_STATE_PARAM > 0 then
- BRAKE_STATE_PARAM = BRAKE_STATE_PARAM - BRAKE_TIME_PARAM
- end
- -- Limit the wheelbrake movements when fully pushed down
- if BRAKE_STATE_PARAM > 1 then
- BRAKE_STATE_PARAM = 1
- end
- -- Limit the wheelbrake movements when fully released
- if BRAKE_STATE_PARAM < 0 then
- BRAKE_STATE_PARAM = 0
- end
- end
- -- Begins a loop function
- update = function()
- -- Runs gear animation function
- animate_gear()
- -- Runs cockpit animations function
- -- animate_cockpit()
- -- Animates the positions of the landing gears
- set_aircraft_draw_argument_value(0, GEAR_STATE)
- set_aircraft_draw_argument_value(3, GEAR_STATE)
- set_aircraft_draw_argument_value(5, GEAR_STATE)
- -- Animates the positions of the landing gear lever and Wheelbrakes
- --[[
- GearParam:set(GEAR_STATE_PARAM)
- LeftBrakeParam:set(BRAKE_STATE_PARAM)
- RightBrakeParam:set(BRAKE_STATE_PARAM)
- ]]--
- end
- need_to_be_closed = false
Add Comment
Please, Sign In to add comment