Airbuspilot Posted October 4, 2016 Report Posted October 4, 2016 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
ckovoor Posted October 5, 2016 Report Posted October 5, 2016 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.
Airbuspilot Posted October 5, 2016 Author Report Posted October 5, 2016 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?
ckovoor Posted October 5, 2016 Report Posted October 5, 2016 (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.
Airbuspilot Posted October 5, 2016 Author Report Posted October 5, 2016 aaah, okay and thanks for your Response. I will try it out.
Airbuspilot Posted October 6, 2016 Author Report Posted October 6, 2016 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?
ckovoor Posted October 6, 2016 Report Posted October 6, 2016 I have not myself worked with setting and accessing global variables across separate LUA threads, so I hope someone better qualified will step in here to advise you, but you might find something useful in this thread: http://forum.simflight.com/topic/81176-lua-ipcset-and-ipcset/#comment-489713
Airbuspilot Posted October 6, 2016 Author Report Posted October 6, 2016 Thanks for your outstanding Support. I will try it tomorrow and hope, it will work. Hope, i can find an Example, how to use it exactly.
ckovoor Posted October 7, 2016 Report Posted October 7, 2016 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.
Airbuspilot Posted October 7, 2016 Author Report Posted October 7, 2016 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.
ckovoor Posted October 7, 2016 Report Posted October 7, 2016 I would suggest that you post all of the relevant code so that it could be checked for any other lacunae.
Airbuspilot Posted October 8, 2016 Author Report Posted October 8, 2016 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.
Airbuspilot Posted October 12, 2016 Author Report Posted October 12, 2016 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
ckovoor Posted October 12, 2016 Report Posted October 12, 2016 From the Lua Library documentation: 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.
Airbuspilot Posted October 13, 2016 Author Report Posted October 13, 2016 okay, thanks for the fast Response. I will try it this Way and see, if it brings the Healing. :-)
Airbuspilot Posted October 15, 2016 Author Report Posted October 15, 2016 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now