L049 setup & engine start via Lua scripts

This is the place where we can all meet and speak about whatever is on the mind.
User avatar
Warbirds
Technical Sergeant
Posts: 735
Joined: 13 Sep 2004, 22:05
Location: Iowa

Re: L049 setup & engine start via Lua scripts

Post by Warbirds »

It really is a great little tool and makes me wish I was better at programing lua scripts. I hope we see more of this type of thing for the Connie and maybe even for the B-377 or B-17.
Paul Grubich 2018
Professional texture artist painting virtual aircraft I love.
Be sure to check out my aged cockpits for the A2A B-377, B-17 and Connie at Flightsim.com and Avsim library
Image

severniae
Senior Airman
Posts: 191
Joined: 04 Jul 2009, 10:43
Location: England

Re: L049 setup & engine start via Lua scripts

Post by severniae »

I'll keep you posted... Hopefully I'll manage to figure out the syntax! Though I may need some help if anyone here is an expert? (Looking at you Paul!!)

I'm trying to add in some automation into the flows... so there are PF actions and PM actions... we'll see how far I get...

severniae
Senior Airman
Posts: 191
Joined: 04 Jul 2009, 10:43
Location: England

Re: L049 setup & engine start via Lua scripts

Post by severniae »

Hmm.. So so far... very confused!! but making sense of it all slowly.

Initially what I want to do, set it so that when I call "Gear up" in MCE, the co pilot raises the gear lever, then waits 30 or so seconds for the gear to be up, then places it in the middle position.

I did something I found on the forum to find all LVARs, and that seemed to give me every var that was active, And I think the one that I need is "LandingGearLeverPos" - it currently shows in the log "L:LandingGearLeverPos = 2.000000" - So I'm making an assumption that 1, and 0 are neutral position, and up, respectively.

Now trying to figure out if the best way is to attempt to create a LUA script (never done that before!!) or use MCE's scripting utility to do it for me, as it can issue a command, issue a pause, then perform another action. Though I'm struggling to figure out how to map the commands to keys for the MCE engine to 'press' for me.

Someone on another thread talks about creating a macro, to use in FSUIPC, and that looks like what I need, but he only mentions putting in "set" after the "=" rather than the vaule...

Would the below be vaild as a macro? and then assignable as a key in FSUIPC?

"1=L:LandingGearLeverPos=0"

Otherwise I'm very confused, as I'm not sure how "set" or "toggle" would work here...

severniae
Senior Airman
Posts: 191
Joined: 04 Jul 2009, 10:43
Location: England

Re: L049 setup & engine start via Lua scripts

Post by severniae »

Hmm.. So so far... very confused!! but making sense of it all slowly.

Initially what I want to do, set it so that when I call "Gear up" in MCE, the co pilot raises the gear lever, then waits 30 or so seconds for the gear to be up, then places it in the middle position.

I did something I found on the forum to find all LVARs, and that seemed to give me every var that was active, And I think the one that I need is "LandingGearLeverPos" - it currently shows in the log "L:LandingGearLeverPos = 2.000000" - So I'm making an assumption that 1, and 0 are neutral position, and up, respectively.

Now trying to figure out if the best way is to attempt to create a LUA script (never done that before!!) or use MCE's scripting utility to do it for me, as it can issue a command, issue a pause, then perform another action. Though I'm struggling to figure out how to map the commands to keys for the MCE engine to 'press' for me.

Someone on another thread talks about creating a macro, to use in FSUIPC, and that looks like what I need, but he only mentions putting in "set" after the "=" rather than the vaule...

Would the below be vaild as a macro? and then assignable as a key in FSUIPC?

"1=L:LandingGearLeverPos=0"

Otherwise I'm very confused, as I'm not sure how "set" or "toggle" would work here...

Gypsy Baron
A2A Master Mechanic
Posts: 3396
Joined: 02 Aug 2008, 17:04
Location: San Francisco

Re: L049 setup & engine start via Lua scripts

Post by Gypsy Baron »

In a MCRO file it would be:

1=L:LandingGearLeverPos=SET

Only use TOGGLE for thos L:Vars that only have 2 states(BOOL type), 0 ot 1
For those, you may need to R$EAD the current setting to determine if you need to
perform the toggle or not. It may already be set to your desired state.

The MCRO file is used to make FSUIPC4 'aware' of L:Variables. Once it reads that
file, those L:Vars get added to the list of assignable FSX controls. That list is alphabetical
so I use one for each of my aircraft with the name "A2A_B17G.MCRO" or "A2A_L049.MCRO", etc.,
That way those L:vars defines appear near the top of the list.
You can then assign them to a switch, button or an axis 'range', so if you wanted to assign
the gear switch (0,1,2 parameters) to an axis you would define 3 'zones' based upon the
position of the axis, assign each to the gear lever L:Var with the appropriate parameter for that zone.

There is a Virtual Co-Pilot available somewhere. I know a couple of the 91st Bombardment Group
are using it with the A2A B-17G. It responds to voice inputs I believe.

Maybe check AVSIM or SimOuthouse for it.

Paul

Image

severniae
Senior Airman
Posts: 191
Joined: 04 Jul 2009, 10:43
Location: England

Re: L049 setup & engine start via Lua scripts

Post by severniae »

So, lots of progress over the last few days.

I'm using a combination of MCE and FSUIPC to do most of the work, and it really is coming together quite nicely. I still need to work on the co-pilot preflight flows, but most other phases of flight are working quite nicely. It's especially nice to just have to say 'approach set up please' and have the co pilot go off and turn off wing ice, set the RPM etc...

I got stuck for ages on trying to get the co-pilot to set the gear to neutral on activation of the "gear up" command - I tried to use MCE's voxscript to initiate a command I created for 'gear to neutral' 20 seconds after selecting gear up, but for some reason he won't do it, so I've had to add it to part of the after takeoff flow. Though to be honest, I can't find that there is a great amount for the FO to be doing for a post take-off flow. So I'm still looking to see if there is a way to trigger gear to neutral for straight after gear up... but this will work for now.

Paul - I have to admit I've studied your scripts in great detail and from them figured out how to do other stuff, its not as difficult as I first thought, it's just taking me a little while to get used to the syntax. It took me a long time to realise that the reason none of my scripts were working was that I hadn't included the function calls at the end of the script as you have! I hope you don't mind, but I split out and added a few parts to fit in the lua scripts with the VFE/MCE flows... I'm trying to write all my own stuff from this point out. These scripts really are powerful!

Gypsy Baron
A2A Master Mechanic
Posts: 3396
Joined: 02 Aug 2008, 17:04
Location: San Francisco

Re: L049 setup & engine start via Lua scripts

Post by Gypsy Baron »

Here is a lua routine I run on the A2A B-17G to handle setting the gear switch to neutral and
announce that action. I assume you are dealing with the A2A B-17 and not the Connie as the Connie
doesn't have a 'neutral' position.

Code: Select all


   function Gear_Switch(lvar, direction)

  state = ipc.readLvar("L:LandingGearLeverPos")

-- Delay 3 seconds to insure gear has started to move

    ipc.sleep(3000)

 	ipc.display("Gear Check Loaded", 1)

-- Gear Up check

   if state == 0 then

    while state == 0 do

	   ipc.display("UP Loop", 1)

       if ipc.readLvar("L:LandingGearL") == 0 and ipc.readLvar("L:LandingGearC") == 0 and ipc.readLvar("L:LandingGearR") == 0 then

        ipc.writeLvar("L:LandingGearLeverPos", 1)

        state = 1

 		ipc.sleep(3000)

		sound.play("gear_neutral",99,315)

      end

    end

   end

-- Gear Down check

   if state == 2 then

    while state == 2 do

	 	ipc.display("Down Loop", 1)

       if ipc.readLvar("L:LandingGearL") == 100 and ipc.readLvar("L:LandingGearC") == 100 and ipc.readLvar("L:LandingGearR") == 100 then

	    ipc.writeLvar("L:LandingGearLeverPos", 1)

        state = 1

 		ipc.sleep(3000)

		sound.play("gear_neutral",99,45)

        end

    end

   end

end

   event.Lvar("L:LandingGearLeverPos",2000,"Gear_Switch")

-- event.timer(500, "Gear_Switch")

-- event.button(1,5,"Gear_Switch")

This happens automatically. No need to command the Co-Pilot to do this although I am sure you could
modify it to trigger off that command.

Paul

Image

DrumsArt
Staff Sergeant
Posts: 286
Joined: 24 Jun 2013, 15:11
Location: France

Re: L049 setup & engine start via Lua scripts

Post by DrumsArt »

Gypsy Baron wrote:Here is a lua routine I run on the A2A B-17G to handle setting the gear switch to neutral and
announce that action. I assume you are dealing with the A2A B-17 and not the Connie as the Connie
doesn't have a 'neutral' position.

Paul

Image
Hi,

The Connie have a "neutral" position...

Thank you for your work.

Regards,
Richard Portier
MAXIMUS VI FORMULA|Intel i7-4770K [email protected] x8|NVIDIA GeForce GTX 1080ti|M16GB|Windows10 Pro 64|Fsx Accel|P3Dv4.5HF2|Rex|Saitek Pro Flight Yoke/Rudder/Quadrant/Switch Panel|ThrustMaster Hotas Warthog|ActiveSky P3Dv4+Asca|Mce|All A2A

Gypsy Baron
A2A Master Mechanic
Posts: 3396
Joined: 02 Aug 2008, 17:04
Location: San Francisco

Re: L049 setup & engine start via Lua scripts

Post by Gypsy Baron »

Ah, you are right Richard. There is a neutral position that I never noticed as the default
FSX gear UP/DOWN works fine (G key) without having to 'double-send the command as you do
in the B-17G if you don't have it in neutral.

Looking from the Co-Pilots seat you can't see any markings and since my 'G' key button on my Saitek
stick operated the gear with no issues I never gave ity another thought.

I'll have to have a look at this after I come back from my week on The Big Island.

Paul


EDIT: Looks like the L:Var "L:LandingGearLeverPos" has a parameter of 0, 1or 2 as in the B-17G so that
can be used to cycle the gear instead of 'G' I suspect. The L:Var is the same as the B-17G so my Lua script
I posted above should work on the Connie as well.
Paul
Image
Image
i7-4790K @4.4Ghz OC - ASUS Z97-A- 16GB Corsair 1600mHz - GTX 760 2GB
240GB + 500GB EVO SSD's - 2x500GB and 1x2TB WD Black 7200 RPM drives

severniae
Senior Airman
Posts: 191
Joined: 04 Jul 2009, 10:43
Location: England

Re: L049 setup & engine start via Lua scripts

Post by severniae »

Paul,

Did you ever manage to get the LUA scripts to set the RPM settings? You mentioned you were looking at it, and wondered if you'd had any success.. And it's paralel to something I want to do, but sadly at the moment don't really know how to do it.

I want to script a command to maintain a given MP - for instance for cruise I want a 'virtual' engineer to set and hold 33mp for climb, and have it maintain it, instead of me haivng to manually keep throttling up as I go (as a real engineer would). Is there any way of coding this constant maintenance of power? Also.. How would I script to have the 'virtual' person 'let go' of the throttles and give me back control?

Cheers,
James

Gypsy Baron
A2A Master Mechanic
Posts: 3396
Joined: 02 Aug 2008, 17:04
Location: San Francisco

Re: L049 setup & engine start via Lua scripts

Post by Gypsy Baron »

severniae wrote:Paul,

Did you ever manage to get the LUA scripts to set the RPM settings? You mentioned you were looking at it, and wondered if you'd had any success.. And it's paralel to something I want to do, but sadly at the moment don't really know how to do it.

I want to script a command to maintain a given MP - for instance for cruise I want a 'virtual' engineer to set and hold 33mp for climb, and have it maintain it, instead of me haivng to manually keep throttling up as I go (as a real engineer would). Is there any way of coding this constant maintenance of power? Also.. How would I script to have the 'virtual' person 'let go' of the throttles and give me back control?

Cheers,
James
Hello James,

The MP/RPM setting stuff has been on the back burner as I was traveling and just returned from
Hawai'i on Saturday night. I've got quite a bit of 91st Bombardment Group mission preparation
work to do so that I have everything in place when I leave for Europe and Cape Breton for the
summer. I also have 3 trips coming up in April and May, so I'll have to squeeze the Connie stuff
in as time and motivation permits.

As to scripting a "MP Hold" function, that should be doable by periodically reading the current MP's
(the L:Vars) and adjusting them to be within some predefined tolerance of the desired MP. Actually,
you should instead adjust the BMEP's and the MP's will fall in line with those settings.

To disengage the script you could call another to 'kill' the 'MP Set' script or a switch/button assigned
in FSUIPC4 to call the 'Lua Kill' function for that script. Several ways to do the disengage.

Any script that would be 'controlling' the RPM/MP/BMEP would need to disable the hardware throttle
inputs while the script is in control. There is a pair of offsets that disable throttle inputs but revert
to enabled after 10 seconds. Those offsets would need to be written within each 10 second interval to
keep the throttles disabled continuously.

Paul

Image

new reply

Return to “Pilot's Lounge”

Who is online

Users browsing this forum: Wakner and 51 guests