Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hello together, again i have a Question. As we all know, have different Aircraft their different Needs. My actual Module blows up and grows bigger and bigger.

I think, it is Time, to outsource the Aircraft Specific Code in separate Lua-Files for each Plane.

So i want to build a Lua File as MainControl. This Module will call a Module, that holds all the needed global Variables in one Place and makes them visual for all following Steps.

Then the MainControl reads the Aircraft Data from the Sim and decicdes, which Module for the specific Aircraft has to be called.

For better understanding (i hope), i have made a WorkFlowSchema, that is attached.

My Question now is, if this is possible. Also i need to know, how to call them. Do i have to call or is it enough to call them with the function() Command?

Please keep in Mind, that i would create a separate for each Aircraft. 

Thanks in Advance for your Answers.

Joachim

LUA-Call.jpg

Posted

I don't see the need for a "Lua File as MainControl". You could simply create an [Auto] section for each aircraft which ensures that the (listed) LUA's specific to that aircraft are run when that aircraft is loaded. Here is an extract from my FSUIPC.ini which should illustrate this:

[Auto.B777]
1=Lua B777captain
2=Lua B777centrepanel
3=Lua B777copilot
4=Lua B777overhead1
5=Lua B777overhead2
6=Lua B777throttle
7=Lua B777radios
8=Lua b777inputsLeft
9=Lua b777inputsRight
10=Lua B777outputs1
11=Lua B777outputs2

[Auto.Dash8Q400]
1=Lua D8Q4inputsLeft
2=Lua D8Q4inputsRight
3=Lua D8Q4box

[Auto.A320X]
1=Lua trimwheel
2=Lua A320Xlights
3=Lua A320Xinputs1
4=Lua A320Xinputs2
5=Lua A320Xbox

The LUA's you see here interface the simulator with Arduino Mega's which either accept inputs from hardware switches and encoders or drive outputs on LED's  and OLED's.

Posted

First of all, thanks for your Reply.

If this works for me too, that was pretty easy.

If i understand that right, you have separate Lua Files created, they were named i.E. B777captain.lua?

But, what is the "Connector" between [Auto.B777] and the separate Files? Do i have to make special Entrys in each File?

 

Posted

(1) Yes, they are separate LUA files, like B777Captain.lua etc

(2) Placing a LUA filename in the [Auto.B777] section causes that LUA to be run when the aircraft is loaded. You would not need to make entries within the LUA for that.

Posted

Hmmm, that seems not to work. Or maybe i am doing it wrong.

I have build the Variablen.lua File, that holds all Variables, needed to operate my FlightLog.lua. In this File, there is an Entry declared   global KiloPoundFaktor = 0.453592 

Made the necessary Entry in FSUIPC.ini

[Auto.B772]
1=Lua Variablen

and

[LuaFiles]
1=FlightLog
2=log lvars
3=record to csv
4=LvarsToTxt
5=Variablen

But it seems, that the declared Variables are not "visible" for other Modules. Because running the FlightLog.lua leeds to this Error

   363672 *** LUA Error: D:\Simulatoren\Fliegen\P3Dv32\Modules\FlightLog.lua:174: attempt to perform arithmetic on global 'KiloPoundFaktor' (a nil value)

It makes also no Difference, if i declare that Variable as global or not. Everytime the same Error occurs. Any Idea to solve this?

 

Posted

ipc.setget.jpg

I would imagine (though I have not used this function myself) that you would use:

ipc.set( "KiloPoundFaktor", KiloPoundFaktor)

to set it, and

KiloPoundFaktor = ipc.get( "KiloPoundFaktor")

to retrieve it.

 

Posted

In Variablen.lua i set it with

    ipc.set("KiloPoundFaktor", 0.453592)

In FlightLog.lua, i will receive it with

    KPF = ipc.get("KiloPoundFaktor")

This also leads to the LUA-Error with a nil Value in KPF.

Seems, that i do something wrong, or that it is not possible, to make Variables outside the Modules visible.

If anybody had some further Ideas, i would highly appreciate them. 

Posted

Hope, i solved it by myself. There was a malformed Typing in Variablen.lua, which stopped the Module from running.

It seems, that after the Module had stopped, no one of the Variables were visible in other Modules, even if the Mistake was very late in the Module.

Now i will code all the needed Modules. If i encounter any further Problems, i would appreciate, if you could help again.

Again, special Thanks for your outstanding Support.

Posted

Sorry, but i have to come back for a Solution of this Problem:

Tried the Workflow with your Advise for the Auto Section in the Fsuipc ini File. I did'nt get it to work correct. So, i try now with Macros. Everything went okay, except from the following Problem, i can't solve by myself. Would be very glad, if you have a Solution. 

That is the Code in FlightLog.lua, that involves the B777PowerUp.lua

   if ipc.get("B777PowerOn") == "N" then 
       ipc.macro("Lua:B777PowerUp")
   end 

The Code in the B777PowerUp.lua works fine, except for the last Function of the DualJetwaySwitch (Key) on the CDU.

Can someone please have a Look at it? Thank you.

B777PowerUp.lua

B777PowerUp.log

Posted

From the Lua Library documentation:

macro.jpg

it would appear that you would write: ipc.macro("Lua B777PowerUp") without an intervening colon  when executing other Lua plug-ins, though I am not sure that this is the cause of your problem.

 

 

 

Posted

Sorry, but i have to come back again. I did not get this to work. Maybe  you could help me, when having a Look at the Files. The Aim of this Script is, to PowerUp the T7, what works real good. After that, the B777FuelInput.lua should be invoked. The Aim here is, to read a File with the Initial Fuel Qty and automatically key this Data into the CDU. After that, some other Things had to be done and recorded to a XML-File.

Thanks in Advance for your Help.

FlightLog.lua

B777FuelInput.lua

B777InitialFuelQty.txt

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.