Skip to content

Commit

Permalink
Added logic for A-10C/A-10C2/F/A-18C left and right engine logic for …
Browse files Browse the repository at this point in the history
…console illumination.

Reset aircraft state when simulation stops.
  • Loading branch information
iknowkungfutoo committed Dec 3, 2023
1 parent 83a87f5 commit cda6872
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
12 changes: 10 additions & 2 deletions Hooks/dcs2arget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
--
--
-- Author: slughead
-- Date: 2/12/2023
-- Date: 03/12/2023
--
-- Version 1.0.6 - Added logic for A-10C/A-10C2/F/A-18C left and right engine
-- logic for console illumination.
-- Version 1.0.5 - Added F/A-18C Hornet console light control.
-- Version 1.0.4 - Converted from export.lua to "hooks" file.
-- Version 1.0.3 - Added A-10C console light control.
Expand All @@ -42,7 +44,7 @@ local generic_aircraft_utils

local dcs2target = {}

dcs2target.VERSION = "DCS2TARGET v1.0.5"
dcs2target.VERSION = "DCS2TARGET v1.0.6"

dcs2target.lastUpdateTime = DCS.getModelTime()

Expand Down Expand Up @@ -87,6 +89,8 @@ end
function dcs2target.onSimulationStop()
log.write('dcs2target', log.INFO, 'onSimulationStop')

dcs2target.aircraft_lamp_utils = nil

if target_socket then
socket.try(target_socket:send( tm_target_utils.pack_data(tm_target_utils.QUIT) ))
target_socket:close()
Expand Down Expand Up @@ -125,6 +129,10 @@ function dcs2target.onSimulationFrame()
elseif (dcs2target.aircraft.Name == "FA-18C_hornet") then
dcs2target.aircraft_lamp_utils = require("fa-18c_hornet_lamps")
end

if (dcs2target.aircraft_lamp_utils ~= nil) then
dcs2target.aircraft_lamp_utils.init()
end
end

local send_update = false
Expand Down
21 changes: 15 additions & 6 deletions dcs2target/a-10c_lamps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
-- script.
--
-- Author: slughead
-- Date: 28/11/2023
-- Date: 03/12/2023
--
------------------------------------------------------------------------------

local P = {}
a_10c_lamps = P

P.APU_RPM_GUAGE = 13
P.APU_GEN_PWR_SWITCH = 241
P.CONSOLE_LIGHT_DIAL = 297
P.APU_RPM_GUAGE = 13
P.APU_GEN_PWR_SWITCH = 241
P.LEFT_AC_GENERATOR_POWER = 244
P.RIGHT_AC_GENERATOR_POWER = 245
P.CONSOLE_LIGHT_DIAL = 297

P.speedbrakes_value = nil
P.console_light_value = nil
Expand All @@ -39,8 +41,10 @@ local function get_console_light_value( current_value )
-- get engine info
local lEngInfo = Export.LoGetEngineInfo()

if ((apu_rpm >= 0.7 and apu_gen_pwr_switch == 1) or (lEngInfo.RPM.left > 50)) then

if ((apu_rpm > 0.8 and apu_gen_pwr_switch == 1) or
(lEngInfo.RPM.left > 50 and device:get_argument_value(aircraft_lamp_utils.LEFT_AC_GENERATOR_POWER) == 1) or
(lEngInfo.RPM.right > 50 and device:get_argument_value(aircraft_lamp_utils.RIGHT_AC_GENERATOR_POWER) == 1) )
then
value = device:get_argument_value(aircraft_lamp_utils.CONSOLE_LIGHT_DIAL)
value = math.floor(value * 5)
end
Expand Down Expand Up @@ -78,6 +82,11 @@ local function get_speedbrake_value( current_value )
return updated, value
end

function P.init( self )
self.speedbrakes_value = nil
self.console_light_value = nil
end

function P.create_lamp_status_payload( self )

local updated = false
Expand Down
13 changes: 11 additions & 2 deletions dcs2target/fa-18c_hornet_lamps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
-- TMHotasLEDSync.tmc script.
--
-- Author: slughead
-- Date: 2/12/2023
-- Date: 03/12/2023
--
------------------------------------------------------------------------------

local P = {}
fa_18c_hornet_lamps = P

P.CONSOLE_LIGHT_DIAL = 413
P.LEFT_GENERATOR_CONTROL_SWITCH = 402
P.RIGHT_GENERATOR_CONTROL_SWITCH = 403

P.speedbrakes_value = nil
P.console_light_value = nil
Expand All @@ -33,7 +35,9 @@ local function get_console_light_value( current_value )
-- get engine info
local lEngInfo = Export.LoGetEngineInfo()

if (lEngInfo.RPM.left > 60) then
if ((lEngInfo.RPM.left > 60 and device:get_argument_value(aircraft_lamp_utils.LEFT_GENERATOR_CONTROL_SWITCH) == 1) or
(lEngInfo.RPM.right > 60 and device:get_argument_value(aircraft_lamp_utils.RIGHT_GENERATOR_CONTROL_SWITCH) == 1))
then
value = device:get_argument_value(aircraft_lamp_utils.CONSOLE_LIGHT_DIAL)
value = math.floor(value * 5)
end
Expand Down Expand Up @@ -68,6 +72,11 @@ local function get_speedbrake_value( current_value )
return updated, value
end

function P.init( self )
self.speedbrakes_value = nil
self.console_light_value = nil
end

function P.create_lamp_status_payload( self )

local updated = false
Expand Down

0 comments on commit cda6872

Please sign in to comment.