ark1320 Posted July 14, 2016 Report Share Posted July 14, 2016 Hi Pete, I have a set of 12 individual Lua scripts that allow the assignment of keys to 12 autopilot functions in FSX. The scripts are small, typically about 20 lines or less each. My question is, would it be better (more efficient operationally) to combine all these scripts into one script and then differentiate the particular functions using 12 ipcPARAM values (perhaps by defining 12 functions and using a large if-then-elseif statement), or leave them as separate scripts? Or perhaps given the small size of the scripts, it doesn’t make much difference either way? I don’t know if Lua scripts are reinterpreted or recompiled on each call, or if there are other timing considerations when interfacing with FSX, etc. Thx, Al Link to comment Share on other sites More sharing options...
Pete Dowson Posted July 14, 2016 Report Share Posted July 14, 2016 If they are called individually, by different assignments, as you say, it is probably slightly more efficient to leave it the way it is. In fact, if you are likely to use 2 of the 12 very closely to each other, that would work better in any case, because when one is completed there's a bit of a delay before the thread and its resources get removed. If you re-use the same plug-in before that's done it has to wait to reload. I only allow one instance of each plug-in to run at a time. And, yes, they are recompiled each time, but only to an intermediate language, not to processor machine code -- then that is interpreted. The is a Lua compiler available on the Lua website, and FSUIPC will accept pre-compiled Lua programs the same as source ones -- but really for small programs it's not worth it as you wouldn't notice. Event-driven plug-ins are the most efficient, because they are loaded and compiled once (eg via [Auto] sections in the INI file, and then act on events as they occur. For this you'd be better off with one larger plug-in interpreting what you want done by the parameter, as you suggest. You would then assign via LuaValue instead of the straight run Lua control, and interpret the ipcPARAM value passed to the plug-in. (event.param). Or, if the assignments are fixed to specific keypresses or buttons then you could just the events for those instead of assigning at all. Pete Link to comment Share on other sites More sharing options...
ark1320 Posted July 14, 2016 Author Report Share Posted July 14, 2016 18 minutes ago, Pete Dowson said: Or, if the assignments are fixed to specific keypresses or buttons then you could just ?? the events for those instead of assigning at all. Pete Hi Pete, Each script (or autopilot function) would have a user selected key assigned to it, but each function will have a fixed ipcPARAM value assigned by me. I assume the missing word in the quote above is ' detect' ? Is there a limit on the number of Lua scripts that can be listed in FSUIPC.ini at one time? Thanks very much for all the info. Al Link to comment Share on other sites More sharing options...
Pete Dowson Posted July 14, 2016 Report Share Posted July 14, 2016 55 minutes ago, ark1320 said: I assume the missing word in the quote above is ' detect' ? No, should be a "use" there. Sorry. i.re. event.key or event.button. 56 minutes ago, ark1320 said: Is there a limit on the number of Lua scripts that can be listed in FSUIPC.ini at one time? Yes. I think it's 127. Of course you don't list them -- that's automatic -- but the internal encoding of assignments has only 7 bits for the refernce to the LuaFiles list. Pete Link to comment Share on other sites More sharing options...
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