Jump to content
The simFlight Network Forums

Maximum Number of Lua Macros


DanW

Recommended Posts

Hi Pete,

This is with 4.858, i've got about 135 Lua Macros (and more coming) for various actions I map my hardware to.

However when I get more than 127 macros it won't add any more than that to the list in the FSUIPC.ini

Is there a maximum number of macros, or is it failing to add the new ones because of something else? e.g finding an error or something in one of my macros that stops the list growing larger?

If there is a limit, is there another way I can get all my macros into the same file but still be accessible by the button assignment tab?

At the moment, for every discrete function that I want to map a button to I create a lua file like this:

require("MD11_LIB")

event.offset("029C", "UB", "VVS_plus")

Mainly because it's the only way I know how to do it, if there is a better way I'd be interested to know.

many thanks

Link to comment
Share on other sites

Hi,

Register the buittons via the event.button function in one single file and execute the necessary function directly instead of registering seperate LUA calls via the button dialogue. Look also at the other event functions. They are VERY powerful. Check also the enclosed example plugins.

Rgds

Reinhard

Link to comment
Share on other sites

Dan, I came across the very same thing.

I was trying to create a lot of macro's in the modules folder, the solution to my problem was to create a single lua script to handle all my needs.

The maximum number of individual macros is 128, this was confirmed for me by Pete.

See here:

Regards Glenn.

Link to comment
Share on other sites

However when I get more than 127 macros it won't add any more than that to the list in the FSUIPC.ini

Is there a maximum number of macros,

Yes. it is limited because there are only 7 bits available to encode it into the Windows WM_COMMAND format. If I have to extend this format it would be a major re-write. FSUIPC has been developed incrementatlly, with Lua facilities being bolted onto Macro facilities which were bolted onto the normal FS/Windows command system.

If there is a limit, is there another way I can get all my macros into the same file but still be accessible by the button assignment tab?

One macro file can contain an almost unlimited number of macros. For Lua programming you can also use the Parameter value to select among any number of different programmed actions.

Mainly because it's the only way I know how to do it, if there is a better way I'd be interested to know.

Please review some of the User Contributions in the subforum of that nmame. There are lots of good examples to follow.

Regards

Pete

Link to comment
Share on other sites

Thanks guys, I might try the event.button monitoring the buttons so I can keep it all in one place.

If I then put the script that monitors button events, in a section specific to one substring named aircraft type, am I going to run into problems when reloading that aircraft?

For example in the FSUIPC ini:

[Auto.PMDG 737NGX]
1=Lua NGX_buttons

If I change to the Trike, and reload the NGX again for another flight, or change from the 800 to the 600 variant, am I going to get this script running multiple times?

Do I need to explicitly terminate it when the plane is unloaded?

Also is there a way to call mouse macros from a Lua script?

I need to use a combination of Lua and mouse macros to control everything nicely, but it would be nice to keep all the assignments together in the one file regardless of how it is actioned..

many thanks

Link to comment
Share on other sites

Thanks guys, I might try the event.button monitoring the buttons so I can keep it all in one place.

Not sure I understand you here. Why would that make any difference? Most of the examples in User Contributions do it with each button assigned to the same Lua plug-in but with a different parameter for each function, You still only need maybe just one plug-in for each different aircraft.

If I then put the script that monitors button events, in a section specific to one substring named aircraft type, am I going to run into problems when reloading that aircraft?

What sort of problems are you thinking you'll get? I don't know of any.

If I change to the Trike, and reload the NGX again for another flight, or change from the 800 to the 600 variant, am I going to get this script running multiple times?

Do I need to explicitly terminate it when the plane is unloaded?

No. Plug-ins loaded for a specific aircraft are killed off when that aircraft is no longer loaded.

Also is there a way to call mouse macros from a Lua script?

Yes, by executing the macro using the ipc.macro function. You still need them defined in a .mcro file.

Regards

Pete

Link to comment
Share on other sites

Not sure I understand you here. Why would that make any difference? Most of the examples in User Contributions do it with each button assigned to the same Lua plug-in but with a different parameter for each function, You still only need maybe just one plug-in for each different aircraft.

If I was using the parameter method to do this, then I would have to configure things both inside the script, and also inside the FSUIPC gui where I would map the buttons, lookup which parameter number corresponds etc. So in order to manage all my assignments, I would have to both edit the file and go into FSUIPC gui or ini file.

So when I say Event.Button() allows me to keep it in one place, I'm hoping I can just have one big script for an aircraft, event.button("joyletter",button,"function-name") one line per assignment and no need to go into the gui or ini file. Any time I need to make a change, it's just one file. It just seems so much easier this way unless I've mistaken how this works.

I'll use that ipc.macro as well thanks, I will call my existing macro files with it keeping all the assignments in my single lua file.

Thanks for the clarification on running the background luas, the only problem I was worried about was having multiple luas building up in the background when changing aircraft.

Link to comment
Share on other sites

If I was using the parameter method to do this, then I would have to configure things both inside the script, and also inside the FSUIPC gui where I would map the buttons, lookup which parameter number corresponds etc. So in order to manage all my assignments, I would have to both edit the file and go into FSUIPC gui or ini file.

So when I say Event.Button() allows me to keep it in one place, I'm hoping I can just have one big script for an aircraft, event.button("joyletter",button,"function-name") one line per assignment and no need to go into the gui or ini file. Any time I need to make a change, it's just one file. It just seems so much easier this way unless I've mistaken how this works.

I see. Well, it would be okay that way. I suppose it's a matter of taste. I tend towards the idea that the plug-in programmed part defines the actions on the aircraft just effectively providing more functions for assignment, separating the business of sorting out how the aircraft works separately from which buttons or switches you are going to use for what. Then changing assignments is easy -- once the file defining the aircraft actions is made and done it wouldn't need any changes for different device assignments.

So, one way is easier in one way and messier in another, and vice versa.

Pete

Link to comment
Share on other sites

Yep I can see your point, in the long term it may be nicer to not have to go back into the lua file.

Although for now I'm facing a massive task of moving all my scripts around into the new method, this will be quickest for me for now to get me flying again.

Thanks for the advice

Link to comment
Share on other sites

  • 4 years later...
On 30/09/2012 at 9:40 AM, Pete Dowson said:

One macro file can contain an almost unlimited number of macros. For Lua programming you can also use the Parameter value to select among any number of different programmed actions.

Hi, could you send here an example.

For example, i have a luafiles who contain 2 functons :

PMDGBaseVar = 	0x00011000		-- 69632
PMDG_ClkL = 	0x20000000		-- 536870912
PMDG_ClkR = 	0x80000000		-- -2147483648
PMDG_dec = 	    0x00002000 		-- 8192
PMDG_inc = 	    0x00004000 		-- 16384
PMDG_RelL = 	0x00020000		-- 131072
PMDG_RelM = 	0x00040000		-- 262144
PMDG_RelR = 	0x00080000		-- 524288

-- Toggle CMDA
function NGX_AP_CMDA_toggle ()
    ipc.control(PMDGBaseVar+402, PMDG_ClkL)
end

-- Toggle CMDB
function NGX_AP_CMDB_toggle ()
    ipc.control(PMDGBaseVar+403, PMDG_ClkL)
end

How can i call first or second function by Keypress or Button +switches ?

I am in the same case, previously i have separed all function in specific files but i have quicly more than 127 lua files in my module folder.

Thanks for all.

Sky

Edited by Skyzo
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.