Jump to content
The simFlight Network Forums

First time trying to use a LUA script!


Recommended Posts

Hi Peter,

This is probably going to sound like a really silly question.

I found on the A2A forum a small lua script for making the reverser's work in the A2A simulations B377 Stratocruiser, using FSUIPC. I asked in the forum about where this code should be copied too and was told in needs to be in the FSX modules folder, as that is where FSUIPC lives. I was told that the instruction "B377 reverse" and "B377 reverse exit" would then appear in the list of button options in FSUIPC's drop down box. So after typing the said code, which I include a copy of below, I see nothing in the "FSX Buttons" drop down.

Script #1:- Enter reverse pitch - file named "B377_Reverse.lua"

This script sends "F1" (key code 112) and then multiple F2's (keycode 113).

The number of times that F2 is sent was chosen to move the VC throttles

all the way back to full reverse position.

Code:

i = 0

ipc.keypress(112)

ipc.sleep(250)

while i < 14 do

ipc.keypress(113)

ipc.keypress(113)

ipc.keypress(113)

ipc.sleep(50)

i = i + 1

end

Script #2 - Exit reverse pitch File name "B377_Exit_Revers.lua"

The script sends F3 (keycode 114) multiple times...enough to move the

VC throttles out of the reverse zone and just into the 'normal' range..or idle thrust.

Code:

i = 0

while i < 15 do

ipc.keypress(114)

ipc.sleep(50)

ipc.keypress(114)

ipc.sleep(50)

i = i + 1

end

So my question is really about how to place these files in the "Modules" folder, do they have to be saved as special file format, in a sub folder, do I need to download a program to create these files in the correct format? or are these just saved as "text" files?

I maybe should mention that while I have FSUPIC set up with profiles for each aircraft etc, I can alter cfg files too my ends and do stuff like that, I have never tried to write my own code, which this essentially is, so I'm currently slightly overwhelmed with what is probably a very simple problem, and just need some advice to get started.

Thanks for any advice.

David Phillips

Link to comment
Share on other sites

I found on the A2A forum a small lua script for making the reverser's work in the A2A simulations B377 Stratocruiser, using FSUIPC. I asked in the forum about where this code should be copied too and was told in needs to be in the FSX modules folder, as that is where FSUIPC lives. I was told that the instruction "B377 reverse" and "B377 reverse exit" would then appear in the list of button options in FSUIPC's drop down box. So after typing the said code, which I include a copy of below, I see nothing in the "FSX Buttons" drop down.

What do you mean by the "FSX Buttons" dropdown?

What was the name of the Lua file you copied into the Modules folder? Was FSX running at the time? If so you need to press the "reload" button in the FSUIPC Buttons & Switches tab so it will rescan the folder for files.

So my question is really about how to place these files in the "Modules" folder, do they have to be saved as special file format, in a sub folder, do I need to download a program to create these files in the correct format? or are these just saved as "text" files?

They need to be files with a short but recognisable name, and filetype Lua. For example B377 reverse.lua. The entry in the drop down would then be "Lua b377 reverse".

Pete

Link to comment
Share on other sites

Hi Peter,

Thanks for the reply and sorry for not reading your post straight away!

I think what I meant by "FSX Buttons" dropdown, was that the way I read the original post on the A2A site after creating the mentioned files "B377 reverse.lua" and "B377 exit revers.lua" I was assuming that these titles would appear in the list of commands that appear in FSUIPC under the "FSX buttons" so that I could assign the buttons on my throttle to that command. On second thoughts thinking about it now, a few days later I think I'm all wrong with this as the code in the Lua files tells FSUIPC which buttons is being assigned anyway.

The name of the Lua files, were the two that I pasted in my original post, which I copied from the original post in the A2A forum, hence my confusion as to whether a Lua file was just simply a text file with the .lua at the end or indeed did I need to download some program in order for the files to be recognised as Lua files.

I think FSX was running at the time so maybe I should have restarted FSX to see if my efforts worked or not.

I think I will need to spend some more time doig some homework on Lua files and how to arrange them properly.

Thanks again for your information.

Regards

David Phillips.

Link to comment
Share on other sites

I think what I meant by "FSX Buttons" dropdown, was that the way I read the original post on the A2A site after creating the mentioned files "B377 reverse.lua" and "B377 exit revers.lua" I was assuming that these titles would appear in the list of commands that appear in FSUIPC under the "FSX buttons" so that I could assign the buttons on my throttle to that command.

They will appear, but as "Lua b377 reverse" and "Lua b377 exit reverse", as I already explained. The prefix "Lua" is always there to show that it is a Lua plug-in you are assigning to.

On second thoughts thinking about it now, a few days later I think I'm all wrong with this as the code in the Lua files tells FSUIPC which buttons is being assigned anyway.

Sorry, you've lost me there. It doesn't matter what the code in the plug-ins does, you need some way of making them run. That's normally by a button or key assignment, unless you want them running all the time, which for these certainly doesn't sound likely!

I think FSX was running at the time so maybe I should have restarted FSX to see if my efforts worked or not.

No no. You evidently did not really read my previous reply. I explained there that all you needed to do was press the Reload button. Any added files will then be recognised.

I think I will need to spend some more time doig some homework on Lua files and how to arrange them properly.

They don't need arranging. Please just read what I write a little more carefully and you'll be okay.

Regards

Pete

Link to comment
Share on other sites

Hi Peter,

Thanks for the reply, just wanted to let you know I have sorted out my problem, I was making it alot harder than it really was! Guess that's what happens when you don't fully understand what your trying to achieve. I had the Lua scripts in the right place and they were working but I was looking for something to select in FSUIPC, when you select assign a button to a task using the "fsx controls" drop down menu in FSUIPC................... Confusion caused by my own ignorance, lol.

Anyway thanks again for your patience trying to explain how these things work.

Regards.

David Phillips.

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.