Jump to content
The simFlight Network Forums

Help, Lua going in circles


DaveSCUSA

Recommended Posts

I have two issues.

1. Kept getting Lua compile errors with the ipc.readSTR statement with the Alpha_Buttons.lua module - attached:

-- Find A/C Title
local acloaded = "None"
acloaded = ipc.readSTR(0x0618,4)  -  Read ICAO Designator from acraft.cfg
ipc.log("A/C - "..acloaded)

So I commented the statements out (See the Lua module).

2. Now I have a clean compile but receive the errors:

   140078 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   144062 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   145125 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   189672 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   191984 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   195187 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   197031 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed

Each line item above appeared every time I exercized a switch on my Honeycomb Alpha.

The killed message doen't appear on my test PC - same user and MSFS synced with my Sim PC. The test PC does not have eith the Honeycomb Alpha or Bravo attached. 

I hope you can help fighue this out. I tried to find the Lua error "killed" online, but no details.

Thanks

FSUIPC7.ini FSUIPC7.log Alpha_Buttons.log Alpha_Buttons.lua

Link to comment
Share on other sites

14 hours ago, DaveSCUSA said:

1. Kept getting Lua compile errors with the ipc.readSTR statement with the Alpha_Buttons.lua module - attached:

-- Find A/C Title
local acloaded = "None"
acloaded = ipc.readSTR(0x0618,4)  -  Read ICAO Designator from acraft.cfg
ipc.log("A/C - "..acloaded)

So I commented the statements out (See the Lua module).

What error? I see no error in the log you attached. Note that the comment characters are '--' and not '-'. i.e. a double-dash. Is that your issue? The error message should indicate what the issue is....

14 hours ago, DaveSCUSA said:

2. Now I have a clean compile but receive the errors:

   140078 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   144062 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   145125 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   189672 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   191984 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   195187 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed
   197031 LUA: "C:\FSUIPC7\LuaFiles\Alpha_Buttons.lua": killed

Each line item above appeared every time I exercized a switch on my Honeycomb Alpha.

Your lua script is auto-started, However, it looks like yo have also assigned EVERY button yo start the lua script:

Quote

1=PC,143,CL1:R,1     -{Lua Alpha_Buttons}-
2=PC,144,CL1:R,0     -{Lua Alpha_Buttons}-
3=PC,145,CL1:R,1     -{Lua Alpha_Buttons}-
4=PC,146,CL1:R,0     -{Lua Alpha_Buttons}-
5=PA,13,CL1:R,0     -{Lua Alpha_Buttons}-
6=PA,14,CL1:R,0     -{Lua Alpha_Buttons}-
7=PA,15,CL1:R,0     -{Lua Alpha_Buttons}-
8=PA,16,CL1:R,0     -{Lua Alpha_Buttons}-
9=PA,17,CL1:R,0     -{Lua Alpha_Buttons}-
10=PA,18,CL1:R,0     -{Lua Alpha_Buttons}-
11=PA,19,CL1:R,0     -{Lua Alpha_Buttons}-
12=PA,20,CL1:R,0     -{Lua Alpha_Buttons}-
13=PA,21,CL1:R,0     -{Lua Alpha_Buttons}-
14=PA,22,CL1:R,0     -{Lua Alpha_Buttons}-
15=PA,23,CL1:R,0     -{Lua Alpha_Buttons}-
16=PA,24,CL1:R,0     -{Lua Alpha_Buttons}-
17=PA,25,CL1:R,0     -{Lua Alpha_Buttons}-
18=PA,26,CL1:R,0     -{Lua Alpha_Buttons}-
19=PA,27,CL1:R,0     -{Lua Alpha_Buttons}-
20=PA,28,CL1:R,0     -{Lua Alpha_Buttons}-
21=PA,29,CL1:R,0     -{Lua Alpha_Buttons}-
22=PA,30,CL1:R,0     -{Lua Alpha_Buttons}-
23=PC,133,CL3:R,0     -{Lua Bravo_Buttons}-
24=PC,134,CL3:R,0     -{Lua Bravo_Buttons}-
25=PC,135,CL3:R,0     -{Lua Bravo_Buttons}-
26=PC,136,CL3:R,0     -{Lua Bravo_Buttons}-
27=PC,137,CL3:R,0     -{Lua Bravo_Buttons}-
28=PC,138,CL3:R,0     -{Lua Bravo_Buttons}-
29=PC,139,CL3:R,0     -{Lua Bravo_Buttons}-
30=PC,140,CL3:R,0     -{Lua Bravo_Buttons}-
31=PC,141,CL3:R,1     -{Lua Bravo_Buttons}-
32=PC,142,CL3:R,0     -{Lua Bravo_Buttons}-
33=PC,143,CL3:R,0     -{Lua Bravo_Buttons}-
34=PC,144,CL3:R,0     -{Lua Bravo_Buttons}-
35=PC,145,CL3:R,0     -{Lua Bravo_Buttons}-
36=PC,146,CL3:R,0     -{Lua Bravo_Buttons}-

As the lua script is running, when you press a button that is assigned to start the lua script, the currently running script is killed and then restarted, hence the error messages.
As your lua script is auto-started and waiting for your alpha button events, you don't need any assignments in FSUIPC7. just remove all of those. As it says in the lua plugins document:

Quote

FSUIPC allows up to 256 simultaneously running Lua programs, each independently running in their own FS thread. When you start a Lua program running which is already running, the previous incarnation is first ruthlessly and unceremoniously terminated. ...

John

 

Link to comment
Share on other sites

 

3 hours ago, John Dowson said:

Your lua script is auto-started, However, it looks like yo have also assigned EVERY button yo start the lua script:

John

 

Thank you for your time. I am still getting used to FSUIPC and its nuances.

I'm still a bit confused about starting and the sequence of events in the Lua. 

In reading the documentation, it appears the series of actions needed to set up an execution of a plug-in (Lua module) with events are:

1. Assign a switch/button to an Lua module either by using a text editor on the FSUIPC7.ini file or using the Key/Buttons assignments facility. For Buttons - "5=PA,13,CL1:R,0  -{ALTERNATOR_ON}-" and for Keys - "0=54,136,L1:R,0  -{rctl+6: Press=Lua Alpha_Buttons }-".

2. In the Lua module, use event.Buttons or event.Key ("event.button(A,13, "TOGGLE_AVIONICS_MASTER") -- On" or "event.key(54,136,"ATC_RAlt_6")") to execute the function in the Lua module.

3. The .ini entries tie the button press/key press to the Lua module.

4. Add the Lua module name to the [Auto] section to load the Lua module ("1=Lua Alpha_Buttons" and "4=Lua Sayo-12Keys").

5. Add the Lua module to the [LuaFiles] section ("1=Alpha_Buttons" and "4=Sayo-12Keys") also include "LuaPath=C:\FSUIPC7\LuaFiles" to use a folder to contain the .lua files. These entries provide the buttons/keys definitions with the Lua module where the function resides.

6. Start MSFS 2020 and start an aircraft to run and the the Lua modules will be available when an aircraft is in its flying state.

Can I understand from your statement quoted above that an Lua entry in the [Auto] section and an event in an Lua module are mutually excleusive? You state "assigned EVERY button to start the lua script". Not sure what that means. Does every entry in the [Buttons] and [Keys] sections in the .ini start a Lua script?

What are my steps to correct the situation if it is other than removing the Lua entries from the [Auto] section? 

What am I not understanding from the sequence of actions above that is causing errors. And I did miss the single "-" on the ipc.readSTR entry, old eyes.

Thanks again.

Link to comment
Share on other sites

You assign a button/key to start the lua if that is what you want to do. You would normally do this for a lua script that ran to do something and then exited, or for testing purposes. Lua scripts that wait for events are started and left running. Such scripts are usually automatically started, but you can start such a script on a button press, but every time you press the button the lua will be started, and if already running that will be killed first.

Your lua script is used for assignments, so it should be auto-ran. You do not need to start auto-ran scripts on a button.

4 minutes ago, DaveSCUSA said:

Can I understand from your statement quoted above that an Lua entry in the [Auto] section and an event in an Lua module are mutually excleusive?

No, but used with care. You can assign to a button if you have a need to re-start a running (auto) lua script.

5 minutes ago, DaveSCUSA said:

You state "assigned EVERY button to start the lua script". Not sure what that means. Does every entry in the [Buttons] and [Keys] sections in the .ini start a Lua script?

You have the lua script started on (almost) every button press, as I showed you in my last post:

3 hours ago, John Dowson said:

 

Quote

1=PC,143,CL1:R,1     -{Lua Alpha_Buttons}-
2=PC,144,CL1:R,0     -{Lua Alpha_Buttons}-
3=PC,145,CL1:R,1     -{Lua Alpha_Buttons}-
4=PC,146,CL1:R,0     -{Lua Alpha_Buttons}-
5=PA,13,CL1:R,0     -{Lua Alpha_Buttons}-
6=PA,14,CL1:R,0     -{Lua Alpha_Buttons}-
7=PA,15,CL1:R,0     -{Lua Alpha_Buttons}-
8=PA,16,CL1:R,0     -{Lua Alpha_Buttons}-
9=PA,17,CL1:R,0     -{Lua Alpha_Buttons}-
10=PA,18,CL1:R,0     -{Lua Alpha_Buttons}-
11=PA,19,CL1:R,0     -{Lua Alpha_Buttons}-
12=PA,20,CL1:R,0     -{Lua Alpha_Buttons}-
13=PA,21,CL1:R,0     -{Lua Alpha_Buttons}-
14=PA,22,CL1:R,0     -{Lua Alpha_Buttons}-
15=PA,23,CL1:R,0     -{Lua Alpha_Buttons}-
16=PA,24,CL1:R,0     -{Lua Alpha_Buttons}-
17=PA,25,CL1:R,0     -{Lua Alpha_Buttons}-
18=PA,26,CL1:R,0     -{Lua Alpha_Buttons}-
19=PA,27,CL1:R,0     -{Lua Alpha_Buttons}-
20=PA,28,CL1:R,0     -{Lua Alpha_Buttons}-
21=PA,29,CL1:R,0     -{Lua Alpha_Buttons}-
22=PA,30,CL1:R,0     -{Lua Alpha_Buttons}-
23=PC,133,CL3:R,0     -{Lua Bravo_Buttons}-
24=PC,134,CL3:R,0     -{Lua Bravo_Buttons}-
25=PC,135,CL3:R,0     -{Lua Bravo_Buttons}-
26=PC,136,CL3:R,0     -{Lua Bravo_Buttons}-
27=PC,137,CL3:R,0     -{Lua Bravo_Buttons}-
28=PC,138,CL3:R,0     -{Lua Bravo_Buttons}-
29=PC,139,CL3:R,0     -{Lua Bravo_Buttons}-
30=PC,140,CL3:R,0     -{Lua Bravo_Buttons}-
31=PC,141,CL3:R,1     -{Lua Bravo_Buttons}-
32=PC,142,CL3:R,0     -{Lua Bravo_Buttons}-
33=PC,143,CL3:R,0     -{Lua Bravo_Buttons}-
34=PC,144,CL3:R,0     -{Lua Bravo_Buttons}-
35=PC,145,CL3:R,0     -{Lua Bravo_Buttons}-
36=PC,146,CL3:R,0     -{Lua Bravo_Buttons}-

See that every button assignment on your Alpha is starting the Alpha_Buttons.lua script. That is just crazy!

7 minutes ago, DaveSCUSA said:

What are my steps to correct the situation if it is other than removing the Lua entries from the [Auto] section? 

No! You want the lua auto-started. You should remove/delete all those button assignments that start the lua script, as you dont need these as the lua is already running nd waiting for button press events from your Alpha.

10 minutes ago, DaveSCUSA said:

What am I not understanding from the sequence of actions above that is causing errors.

Step 3:

10 minutes ago, DaveSCUSA said:

3. The .ini entries tie the button press/key press to the Lua module.

You do not need this. You only need to do this if you want to start a lua on a button press, as i have said many times now. Your lua is already running, via the [Auto] section.

Also, step 5:

12 minutes ago, DaveSCUSA said:

5. Add the Lua module to the [LuaFiles] section ("1=Alpha_Buttons" and "4=Sayo-12Keys") also include "LuaPath=C:\FSUIPC7\LuaFiles" to use a folder to contain the .lua files.

You should NEVER manually modify the [LuaFiles] section (unless you REALLY understand what you are doing!). This section is maintained by FSUIPC7 by scanning your folders.

But why are you doing all this in lua anyway? Why not just assign directly in FSUIPC?

Link to comment
Share on other sites

1 hour ago, John Dowson said:

You do not need this. You only need to do this if you want to start a lua on a button press, as i have said many times now. Your lua is already running, via the [Auto] section.

You should NEVER manually modify the [LuaFiles] section (unless you REALLY understand what you are doing!). This section is maintained by FSUIPC7 by scanning your folders.

I'm sorry John, what is obvious to you is not always understood by your customers.

You keep saying "assignment on your Alpha is starting the Alpha_Buttons.lua script" and "lua on a button press, as i have said many times now". where is the Lua started by a button/key press? Between the lines interpretation, does every button/key assignment in the [Button] and [Key] sections start the Lua module?

What I am understanding is that the steps should be:

1. List the Luas in the [Auto] section or use the ipcready.lua module.

2. The event.button and event.key statements in the module will be executed whenever a button/key press is completed.

3. Don't need the entries in the [LuaFiles] section in FSUIPC7.ini except the LuaPath entry.

4. No [Buttons] or [Key] sections in the FSUIPC7.ini are needed except if one wants to start a module with a press.

If the above is not correct or I still don't understand, please point me to documentation that provides the steps needed and what entries are needed where to execute a function on a button or key press.

Link to comment
Share on other sites

Just now, DaveSCUSA said:

You keep saying "assignment on your Alpha is starting the Alpha_Buttons.lua script" and "lua on a button press, as i have said many times now". where is the Lua started by a button/key press?

And I have showed you this twice now. For the third time, and to be clear - from your FSUIPC7.ini:

1 hour ago, John Dowson said:

1=PC,143,CL1:R,1     -{Lua Alpha_Buttons}-

This will start the lua script when you press button 143 on joystick C, your Alpha yoke.

1 hour ago, John Dowson said:

2=PC,144,CL1:R,0     -{Lua Alpha_Buttons}-

This will start the lua script when pressing button 144. etc etc. You have such assignments for EVERY button. Can you not see this? What do you think those assignments actually do, if not starting the lua script? From the Lua plugins document:

Quote
Lua <name> to run the named program

So, each of your button assignments is starting the lua script, and as it is already running, it will be killed first.

5 minutes ago, DaveSCUSA said:

Between the lines interpretation, does every button/key assignment in the [Button] and [Key] sections start the Lua module?

Only if you assign it as such, which you seem to have done for all your alpha buttons (and similarly for your Bravo).

6 minutes ago, DaveSCUSA said:

1. List the Luas in the [Auto] section or use the ipcready.lua module.

You do this if you want the lua ro be auto-started. Many luas run on a button press. It is up to YOU to decide how to start the lua. However, almost all luas that use the event library, and just run waiting for an event to happen, should be started in the [Auto] section. Or, better, in the profile-specific [Auto.xxx] section, if they are specific to certain aircraft only.

8 minutes ago, DaveSCUSA said:

2. The event.button and event.key statements in the module will be executed whenever a button/key press is completed.

Yes, if the lua is running.

9 minutes ago, DaveSCUSA said:

3. Don't need the entries in the [LuaFiles] section in FSUIPC7.ini except the LuaPath entry.

No!. Don't EDIT this section, apart from LuaPath. All numbered entries are managed by FSUIPC7. Do not add or delete from this section.

10 minutes ago, DaveSCUSA said:

4. No [Buttons] or [Key] sections in the FSUIPC7.ini are needed except if one wants to start a module with a press.

No! If you have an assignment to a button or key press, then it will be added to this section. You just DO NOT need to assign your buttons/keys to start a lua that is already running.

12 minutes ago, DaveSCUSA said:

If the above is not correct or I still don't understand, please point me to documentation that provides the steps needed and what entries are needed where to execute a function on a button or key press.

Read the user guide on button and key assignments. If you are a beginner, a

I do not understand why you are starting with lua, and not just assigning your buttons/keys to the standard controls/events or presets (also Input Events will be available for assignment in the next release, currently available as a beta - see Announcements sub-forum). It is a lot easier then using lua, and you can do most things via the UI.

John

Link to comment
Share on other sites

Thanks for the extraordinary time you've spent on this.

Please forget any reply on starting an Lua module with a button press. Just want to execute code to manipulate a Sim event. Again, all I need is: 1. Event.button or event.key executing a function in a module. 2. Run that module via the [Auto] section. 3. Have a LuaPath in the [LuaFiles] section if the Lua is located in that folder. That's it? No other actions needed?

As an ex-pilot and retired programmer, I have options I want to use to make the use in the home built cockpit more realistic. I have the pilot manuals for several aircraft. I can more easily tie functions together that aren't correct in the MSFS aircraft. E.g. Upon start. Ensure the ignition is on. Fuel valve is open. Starter stops after reaching its minimum rpm. 

Link to comment
Share on other sites

15 minutes ago, DaveSCUSA said:

Again, all I need is: 1. Event.button or event.key executing a function in a module. 2. Run that module via the [Auto] section. 3. Have a LuaPath in the [LuaFiles] section if the Lua is located in that folder. That's it? No other actions needed?

Yes

15 minutes ago, DaveSCUSA said:

As an ex-pilot and retired programmer, I have options I want to use to make the use in the home built cockpit more realistic. I have the pilot manuals for several aircraft. I can more easily tie functions together that aren't correct in the MSFS aircraft. E.g. Upon start. Ensure the ignition is on. Fuel valve is open. Starter stops after reaching its minimum rpm. 

You can do this via lua, but if its on-start, why have a continually running lua? For on-start, you can also use the InitialButton ini parameter (see Advanced User guide), This can trigger one-off actions already assigned to buttons. Alternatively, consider individual lua functions - one to insure the ignition is on, one to open the fuel valve, etc. Or combine as needed, These don't need to be continually running - they can exit once their function is complete.

From the lua you attached, you seem to want to handle all your assignments via lua and event.button. You can do this (this is what LINDA does), but it can get really complicated and is not necessary. Assign your buttons/switches as normal, via the button assignments, and just use lua for more complex things.
 

Link to comment
Share on other sites

The other reason I use Lua! Although I retired as an IT executive and business consultant, I find preogramming very relaxing and rewarding. Since retiring, I have completed projects in HTML/CSS, Python, VBA, FSX XML and now FSUIPC7 Lua. Next step, native Lua.

Link to comment
Share on other sites

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.