Problem with WIP mod after updating dcs to 2.5.. - Page 2 - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 08-14-2019, 07:12 PM   #11
J900
Junior Member
 
Join Date: Oct 2018
Posts: 43
Default

This code seemed to work well before updating, will give that a try..

Code:
dofile(LockOn_Options.script_path.."command_defs.lua")
dofile(LockOn_Options.script_path.."devices.lua")

local gear_system = GetSelf()
local dev = GetSelf()

local update_time_step = 0.01
local sensor_data = get_base_data()

make_default_activity(update_time_step)

local GEAR_COMMAND = 0
local GEAR_STATE = 0
local Gear = 68 --internal DCS ID
local GearElem = 3001 -- clickable pointer element ID

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

dev:listen_command(Gear)

function SetCommand(command,value)
local wowml = sensor_data.getWOW_LeftMainLandingGear()
   if wowml > 0 then
      if command == Gear or GearElem then
	if (GEAR_COMMAND == 0) then
	  GEAR_COMMAND = 1
	else
	  GEAR_COMMAND = 0
	end
  end   
		
end
  if command == Gear or GearElem then
	if (GEAR_COMMAND == 0) then
	  GEAR_COMMAND = 1
	else
	  GEAR_COMMAND = 0
	end
  end
end
	
function update()
  if (GEAR_COMMAND == 1 and GEAR_STATE > 0) then	
    GEAR_STATE = GEAR_STATE - GEAR_TIME_IN
  end
  
  if (GEAR_COMMAND == 0 and GEAR_STATE < 1) then 
    GEAR_STATE = GEAR_STATE + GEAR_TIME_OUT
  end
  
  set_aircraft_draw_argument_value(0, GEAR_STATE)
  set_aircraft_draw_argument_value(3, GEAR_STATE)
  set_aircraft_draw_argument_value(5, GEAR_STATE)
end

need_to_be_closed = false
J900 is offline   Reply With Quote
Old 08-14-2019, 07:37 PM   #12
Sirius
Member
 
Sirius's Avatar
 
Join Date: Mar 2017
Location: North Carolina, USA
Posts: 614
Default

Try using this code:

Code:
dofile(LockOn_Options.script_path.."command_defs.lua")
dofile(LockOn_Options.script_path.."devices.lua")

local gear_system = GetSelf()
local dev = GetSelf()

local update_time_step = 0.01
local sensor_data = get_base_data()

make_default_activity(update_time_step)

local GEAR_COMMAND = 0
local GEAR_STATE = 0
local Gear = 68 --internal DCS ID
local GearElem = 3001 -- clickable pointer element ID

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

dev:listen_command(Gear)

function post_initialize()
  if GEAR_WEIGHT > 0 then
    GEAR_STATE = 1
  else
    GEAR_STATE = 0
  end

  set_aircraft_draw_argument_value(0, GEAR_STATE)
  set_aircraft_draw_argument_value(3, GEAR_STATE)
  set_aircraft_draw_argument_value(5, GEAR_STATE)
end

function SetCommand(command,value)
  if GEAR_WEIGHT == 0 then
    if command == Gear or GearElem then
      if GEAR_COMMAND == 0 then
        GEAR_COMMAND = 1
      else
        GEAR_COMMAND = 0
      end
    end
  end
end
	
function update()
  if GEAR_WEIGHT == 0 then
    if (GEAR_COMMAND == 1 and GEAR_STATE > 0) then	
      GEAR_STATE = GEAR_STATE - GEAR_TIME_IN
    end
    
    if (GEAR_COMMAND == 0 and GEAR_STATE < 1) then 
      GEAR_STATE = GEAR_STATE + GEAR_TIME_OUT
    end
  end
  
  set_aircraft_draw_argument_value(0, GEAR_STATE)
  set_aircraft_draw_argument_value(3, GEAR_STATE)
  set_aircraft_draw_argument_value(5, GEAR_STATE)
end

need_to_be_closed = false
This code will utilize the post_initialize() function more to determine before the mission starts where the gear is supposed to start. In your SetCommand() function, your code had indention block issues and I believe you forgot to close the function. (that or one of the IF statements) You were also checking in your SetCommand() for the gears to be able to move as long as gear weight was on, meaning only if you were on the ground. Hope this helps!
__________________
I no longer make flyable aircraft mods for the community.

Spoiler:

PC Specs: AMD Ryzen 5, AMD Radeon RX 580, 24 GB DDR4, 128 SSD, 2 TB HDD
Modules: A-4E, MiG-23UB | AV-8BNA V/STOL, A-10C, AJS-37, C-101, F-5E, F-14B, F-15C, F-86F, Ka-50, L-39, M-2000C, SA-342, Spitfire LF Mk. IX, Su-25A, Su-27, Su-33, UH-1H, Yak-52
Discord: Sirius#8952
Sirius is offline   Reply With Quote
Old 08-15-2019, 06:59 PM   #13
J900
Junior Member
 
Join Date: Oct 2018
Posts: 43
Default

Ahh that makes more sense, strange as still has issue with gear where gear is actually up but extends straight away without input. Tried changing the GEAR_STATE values around for post initialize function and even removed the GEAR_STATE = 1 value altogether but seems unaffected..
One thing i did notice was that when the gear state values were swapped around the gear was already in down position when air starting as opposed to lowering, can't seem to get the gear to stay in although once it has initially lowered it does function perfectly up and down afterwards ...

Regards

Last edited by J900; 08-15-2019 at 07:03 PM.
J900 is offline   Reply With Quote
Old 08-17-2019, 01:20 PM   #14
J900
Junior Member
 
Join Date: Oct 2018
Posts: 43
Default

Resolved, thanks Sirius..
J900 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 08:05 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.