Hello pilots,
Being new to DCS I wanted to practice my carrier landings in the FA-18C. I was looking for scripts to automate the cockpit configuration, e.g. gear down, flaps full, hook down, TCN and ILS channels configured, etc. so that I could focus just on the landing part without manually having to repeat the landing configuration steps at each trial.
Using the Mission Editor with triggers and "X: COCKPIT PERFORM CLICKABLE ACTION" actions I got things working, but needed a lot of triggers because many UFC keyboard buttons require a delay between press and release. Anyway, I found various pieces of information on the web, explored the available DCS lua code, manuals, tutorials and combined my findings into a single script that automates cockpit configuration actions, including time delays between certain actions. Combining the steps into a single script also allows comments with explenations to be added, which helps for future reference.
The attached example mission file has one "Mission Start" trigger and one "DO SCRIPT" action. It first sets Active Pause on, goes through multiple time delayed configuration steps and ends with the message "Ready: unpause and good luck!" at which point the pilot can deactivate active pause and practice the carrier landing.
The code below is included in the mission and demonstrates the technique I used, which should be applicable for other cockpit configurations as well. Hope it's usefull. If there are better approaches, please let me know. It certainly helped me in improving my landing skills
-Orca57
--[[
Automated cockpit configuration for an F18 carrier landing training mission.
Some clickable cockpit actions in the F18 require a delay between press and release, for example various UFC keyboard buttons and the course select button.
In stead of creating multiple triggers with TIME MORE(1) conditions and X: COCKPIT PERFORM CLICKABLE ACTION actions in the mission editor,
this script does all the cockpit configuration actions in a single script, which is easier to edit, maintain and explain with comments.
The technique is to configure a LUA table with sequential steps to perform with some delay between them. The steps are implemented in anonymous functions, wich perform
cockpit clickable actions using the function call net.dostring_in('mission', "_G.a_cockpit_perform_clickable_action(<device id>, <button id>, <value>, ''))", which has the same functionality as X: COCKPIT PERFORM CLICKABLE ACTION()
At the end of each action the next action is triggered with a time delay using timer.scheduleFunction(steps[step], step + 1, timer.getTime() + 1)
The very last action must not trigger further actions.
The actions are:
- setup the TCN channel (73X)
- setup the ILS channel, default 1
- configure the course select (334)
- configere the left MDI as HSI with TCN and ILS boxed
When completed, the message "Ready: unpause and good luck!" is shown, at which point active pause can be released by the pilot.
author: Orca57
]]--
local steps = {} -- The table with actions, populated below.
-- local support functions, reducing syntax clutter.
local function cockpit_action(device_id, action_id, value)
-- identical to the mission editor action X: COCKPIT PERFORM CLICKABLE ACTION
net.dostring_in('mission', '_G.a_cockpit_perform_clickable_action('..device_id..', '..action_id..', '..value..', "")')
end
local function set_command(command_id)
-- identical to the mission editor action X: SET COMMAND
net.dostring_in('mission', '_G.a_set_command('..command_id..')')
end
local function message(txt, time)
-- Show message
trigger.action.outText(txt, time)
end
local function next_step(step, delay)
-- Schedule the next step
if (steps[step] ~= nil) then
timer.scheduleFunction(steps[step], step + 1, timer.getTime() + delay)
end
end
--[[
Each table index is automaticaly incremented, the actions are anomymous functions that take the current step index as argument, which is used to invoke the next step after a time delay.
Order is important. From first to last action. Which actions require a delay between them and the delay value takes some trial and error.
The arguments for the a_cockpit_perform_clickable_action function are the same as for X: COCKPIT PERFORM CLICKABLE ACTION(), which is rather obscure and cockpit specific, but can be found in various on-line resources.
or extracted from (for example) C:\Program Files\Eagle Dynamics\DCS World\Mods\aircraft\FA-18C\Cockpit\Scripts\clickabledata.lua
]]--
steps[#steps + 1] = function(step)
message("Setup TCN 73X", 2)
cockpit_action(25, 3003, 0) -- UFC, TCN (release)
cockpit_action(25, 3025, 1) -- UFC, 7 (press)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(25, 3025, 0) -- UFC Keyboard Pushbutton, 7 (release)
cockpit_action(25, 3021, 1) -- UFC Keyboard Pushbutton, 3 (press)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(25, 3012, 0) -- UFC Keyboard Pushbutton, 3 release
cockpit_action(25, 3029, 1) -- UFC Keyboard Pushbutton, ENT (press)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(25, 3029, 0) -- UFC, ENT (release)
cockpit_action(25, 3007, 1) -- UFC, ON/OFF (press)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
message("Setup ILS Channel 1", 2)
cockpit_action(25, 3007, 0) -- UFC, ON/OFF (release)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(25, 3004, 1) -- UFC, ILS (press)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(25, 3004, 0) -- UFC, ILS (release)
cockpit_action(25, 3007, 1) -- UFC, ON/OFF (press)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
message("Configure HDI", 2)
-- ILS On
cockpit_action(25, 3007, 0) -- UFC, ON/OFF (release)
-- box TCN on HSI
cockpit_action(35, 3015, 1) -- Left MDI, 5
-- box ILS on left MDI HSI
cockpit_action(35, 3014, 1) -- Left MDI, 4
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
message("Setting CRS to 334", 2)
cockpit_action(35, 3007, -1) -- Course set switch (press)
next_step(step, 3)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(35, 3007, 0) -- Course set switch (release)
cockpit_action(25, 3021, 1) -- UFC Keyboard Pushbutton, 3 (press)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(25, 3021, 0) -- UFC Keyboard Pushbutton, 3 (release)
cockpit_action(25, 3021, 1) -- UFC Keyboard Pushbutton, 3 (press)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(25, 3021, 0) -- UFC Keyboard Pushbutton, 3 (release)
cockpit_action(25, 3022, 1) -- UFC Keyboard Pushbutton, 4 (press)
next_step(step, 1)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(25, 3022, 0) -- UFC Keyboard Pushbutton, 4 (release)
cockpit_action(25, 3029, 1) -- UFC Keyboard Pushbutton, ENT (press)
timer.scheduleFunction(steps[step], step + 1, timer.getTime() + 1)
return nil
end
steps[#steps + 1] = function(step)
cockpit_action(25, 3029, 0) -- UFC Keyboard Pushbutton, ENT (release)
message("Ready: unpause and good luck!", 5)
--This is the last action, no further timer calls.
--timer.scheduleFunction(steps[step], step + 1, timer.getTime() + 1)
return nil
end
-- Mission init
message("Start: setting landing configuration, wait for ready message!", 2)
set_command(816) -- Active pause on
-- Landing configuration
cockpit_action(5, 3001, 0) -- Landing Gear Control Handle, Down
cockpit_action(5, 3009, 0) -- Arresting Hook Handle, Down
cockpit_action(2, 3007, -1) -- FLAP Switch, Full
cockpit_action(5, 3004, -1) -- Anti Skip Switch, Off
-- Left MDI settup with HDI at 5nm
cockpit_action(35, 3028, 1) -- Left MDI PB 18
cockpit_action(35, 3028, 1) -- Left MDI PB 18
cockpit_action(35, 3012, 1) -- Left MDI PB 2 (select HDI)
cockpit_action(35, 3018, 1) -- Left MDI PB 8 (scale 20nm)
cockpit_action(35, 3018, 1) -- Left MDI PB 8 (scale 10nm)
cockpit_action(35, 3018, 1) -- Left MDI PB 8 (scale 5nm)
-- Start TCN, ILS and course configuration actions
cockpit_action(25, 3003, 1) -- UFC , TCN (press)
-- Comms
set_command(179) -- Main communications menu
-- Start first time delayed action
next_step(1, 1)
F18 carrier landing final approach configured.miz