Jump to content
The simFlight Network Forums

Recommended Posts

Posted (edited)

Hi all, I have been following a post on the Aerosoft forum(https://forum.aerosoft.com/index.php?/topic/140328-as-a320-key-mapping-with-fsuipc/) on how to use FSUIPC and lua files to operate controls in the A320. I have followed it to the best of my abilities and have had intermittent results. I am using FSUIPC4, and have added the:

[Auto]
1=A320Engine

[LuaFiles]
1=A320Engine

Sections to my .ini file (A320Engine.lua is the file name)

The lua file is in the same directory and i am have a mixed bag of results. Some times it works but 90% of the time nothing happens. I have tied my best to try and understand the lua Documentation that comes with FSUIPC but I am struggling a tad. If someone is able to give me some guidance on this it would be greatly appreciated !

Edited by cr2130
Posted
3 hours ago, cr2130 said:

I am using FSUIPC4, and have added the:

[Auto]
1=A320Engine

[LuaFiles]
1=A320Engine

Sections to my .ini file (A320Engine.lua is the file name)

Two things wrong there:

1. The [Auto] section is for complete commands, not a list of files.  It is for Macros,as well, not just loading Lua files. If fact any control you can assign can be executed automatically as well.

So the entry should be 1=Lua A320Engine

The documentation does explain this, with examples!

 

2. You do NOT add entries to the [LuaFiles] section at all. That is where FSUIPC keeps track of which Lua files you've added. Please do NOT edit it!

Pete

 

Posted

My apologies if what I have done has frustrated you, I am completely new to this and was only doing what I believed others had done as shown in the Aerosoft forum as I was and still am struggling to  get to grips with this. Thanks for the help.

Posted
2 hours ago, cr2130 said:

My apologies if what I have done has frustrated you

No, nothing's frustrated me. I was just pointing out the errors.

With the Lua not being loaded, it obviously cannot work. Does it work after you corrected the entry in [Auto] as i showed?

Pete

 

Posted

Thanks for the reply, i have managed to get it working with your help, When in FSX it does not run on its own I have to trigger it to start (if that's the phrase to use) then the commands run fine, Is this normal behaviour ? Thanks for the help so far !

Posted
31 minutes ago, cr2130 said:

When in FSX it does not run on its own I have to trigger it to start (if that's the phrase to use) then the commands run fine, Is this normal behaviour ?

I don't know what you mean by "trigger". It should load and execute automatically if loaded via the [Auto] method. There are other ways of loading it. Could you describe what you mean by "trigger"?

Pete

 

Posted

Thanks for replying. when I first made the changes you described above it didn't appear to work so I assigned a button to "Lua A320Engine" in a random attempt to get it to work after pressing this button in the sim all the commands started to work. I have loaded FSX several times since and it is working first time, every time now without pressing the "Lua A320Engine" button which did nothing to start with by the sounds & look of it. Thank you for your help.

Posted
3 hours ago, cr2130 said:

when I first made the changes you described above it didn't appear to work so I assigned a button to "Lua A320Engine" in a random attempt to get it to work after pressing this button in the sim all the commands started to work.

Okay. then please show me your INI file, because the [Auto] section with the same entry should most certainly do the same thing as that button!

3 hours ago, cr2130 said:

I have loaded FSX several times since and it is working first time, every time now without pressing the "Lua A320Engine" button

Ah, So, that sounds like you changed the [Auto] section and assumed it would somehow work without you restarting the sim?

The [Auto] section is actioned when the system loads. If you use profiles you can have separate profile-dependent Auto sections, by [Auto.<profile name>], and those would be actioned on a change of aircraft which then caused a different profile to be loaded.

Also you can reload button, key and axis settings using facilities in their own Option Tabs,  but otherwise the settings are only loaded when you start the sim.

Pete

 

Posted

Hi, sorry about the delay ! I feel like i'm sending you around in circles here as today it has stopped working again. Nothing has been changed and nothing has been unplugged. I have set a profile for the aircraft and have been trying to use the Lua with this profile. I have attached my ini file. Many Thanks !

FSUIPC4.ini

Posted
5 hours ago, cr2130 said:

I have set a profile for the aircraft and have been trying to use the Lua with this profile. I have attached my ini file.

The Lua will start when you start the Sim. It isn't specific to any Profile. If you want it to be then you have to change the section name from 

[Auto]

to

[Auto.Aerosoft A320]

However, it will be running in any case -- unless it has an error in it or it didn't work properly in the first place. It currently has nothing to do with whether you are using a Profile or not.

You should check in the Log to see if an error is registered for your Lua plug-in.

I can't really help further. I've not seen your plug-n and know nothing at all about it. 

Pete

 

Posted

Thanks  for replying and all the help, I think have enough information to have a look into the Lua and see if something is wrong in there. Thanks !

Posted

Apologies for posting again. I have created a few Lua files now that work fine but have created another with which to control the Radio Masters taken from the same links as above and this is not working, I have tried both the "On" & "Off" parameters with "Lua Set" as well as the "toggle" parameter with the "Lua Toggle".  I have attached the lua. If you are able to assist that would be amazing. Thanks !

A320Radio.lua

Posted

With just a quick look found many errors, that is.. If you supplied the full code.
Here's the code with errors commented out and 2 lines added to replace bad ones.
 

function AB_PDS_CPT_Radios_on ()
    ipc.writeLvar("AB_PDS_RADIO_CPT_POWER", 1)
    -- AB_OVH_Pushbutton () NO FUNCTION WITH THAT NAME
    -- DspShow ("Rdio", "on") NO FUNCTION WITH THAT NAME
end

function AB_PDS_CPT_Radios_off ()
    ipc.writeLvar("AB_PDS_RADIO_CPT_POWER", 0)
    -- AB_OVH_Pushbutton () NO FUNCTION WITH THAT NAME
    -- DspShow ("Rdio", "off") NO FUNCTION WITH THAT NAME
end

function AB_PDS_CPT_Radios_toggle ()
	-- if _tl("AB_PDS_RADIO_CPT_POWER", 0) then WRONG FORMAT, NO FUNCTION WITH THAT NAME
	if ipc.readLvar("AB_PDS_RADIO_CPT_POWER") == 0 then
       AB_PDS_CPT_Radios_on ()
	else
       AB_PDS_CPT_Radios_off ()
	end
end

function AB_PDS_FO_Radios_on ()
    ipc.writeLvar("AB_PDS_RADIO_FO_POWER", 1)
    -- AB_OVH_Pushbutton ()  NO FUNCTION WITH THAT NAME
    -- DspShow ("Rdio", "on")  NO FUNCTION WITH THAT NAME
end

function AB_PDS_FO_Radios_off ()
    ipc.writeLvar("AB_PDS_RADIO_FO_POWER", 0)
    -- AB_OVH_Pushbutton ()  NO FUNCTION WITH THAT NAME
    -- DspShow ("Rdio", "off")  NO FUNCTION WITH THAT NAME
end

function AB_PDS_FO_Radios_toggle ()
	-- if _tl("AB_PDS_RADIO_FO_POWER", 0) then WRONG FORMAT, NO FUNCTION WITH THAT NAME
	if ipc.readLvar("AB_PDS_RADIO_FO_POWER") == 0 then
       AB_PDS_FO_Radios_on ()
	else
       AB_PDS_FO_Radios_off ()
	end
end

event.flag(1, "AB_PDS_CPT_Radios_on")
event.flag(2, "AB_PDS_CPT_Radios_off")
event.flag(3, "AB_PDS_FO_Radios_on")
event.flag(4, "AB_PDS_FO_Radios_off")

When creating luas, this part of the "most excellent" logging tab of FSUIPC will tell you what's wrong, the line number, what it is doing etc..
Indispensable! (note, this screenshot is from an older version, but should be close)

4.jpg.65e62204ca60353499249ab67ad4bae6.jpg

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.