Skittles Posted July 28, 2011 Report Posted July 28, 2011 I'm still using FS2004 so I'm referring to FSUIPC 3.997c When I was tinkering with GFDisplay, it would re-load the ini file when it detected a change in the ini file. Regarding the lua files... the FSUIPC Manual for Advanced Users states... Lua plugins to be executed, in order, automatically whenever the current aircraft is changed (or, indeed, first loaded), or a specific named aircraft (or Profile) is loaded When I change aircraft, it does re-load the lua like it states but the aircraft goes into a spinning dive if it's already in flight. Is it possible to include when the user aircraft is reloaded?
Pete Dowson Posted July 28, 2011 Report Posted July 28, 2011 Regarding the lua files... the FSUIPC Manual for Advanced Users states... Lua plugins to be executed, in order, automatically whenever the current aircraft is changed (or, indeed, first loaded), or a specific named aircraft (or Profile) is loaded When I change aircraft, it does re-load the lua like it states but the aircraft goes into a spinning dive if it's already in flight. Is it possible to include when the user aircraft is reloaded? Er ... you are not only quoting that line out of context, it isn't even a sentence, so actually states nothing at all on its own. Please read the whole part. The bit you quote actually starts with By some editing in the INI file, you can arrange for one or more Macros or ... and after that it explains what editing you have to do. So ... have you done it? Have you checked it? Please don't waste both of out time by quoting little parts of the manual which are meaningless out of context. If you have a problem making the [Auto ...] system work for an aircraft, show me what you've done in the INI file. And nothing in FSUIPC itself is going to make an aircraft go into a spinning dive. I think you need to explain why you thing it is anything to do with FSUIPC or a Lua plug-in. Pete
Skittles Posted July 29, 2011 Author Report Posted July 29, 2011 Er ... you are not only quoting that line out of context, it isn't even a sentence, so actually states nothing at all on its own. Please read the whole part. The bit you quote actually starts with By some editing in the INI file, you can arrange for one or more Macros or ... and after that it explains what editing you have to do. I didn't think you would appreciate me quoting the whole section since you wrote it. Some people may feel like I'm throwing it in their face. I just wanted to quote the part that says FSUIPC can be setup to automatically load the lua files. So ... have you done it? Have you checked it? Yes I did, yes I have and it's loading the lua as expected. Please don't waste both of out time by quoting little parts of the manual which are meaningless out of context. If you have a problem making the [Auto ...] system work for an aircraft, show me what you've done in the INI file. I didn't say I was having a problem with it loading automatically. And nothing in FSUIPC itself is going to make an aircraft go into a spinning dive. I think you need to explain why you thing it is anything to do with FSUIPC or a Lua plug-in.I didn't say FSUIPC was causing the spinning dive, it's FS2004 doing that.I just wanted to know if it's possible to have FSUIPC either re-run the "Auto" section or just re-load the lua file when the user reloads the aircraft. That would prevent FS2004 from sending the aircraft in to a dive. I thought it would make the file editing/troubleshooting go a little smoother. I'm upset for getting jumped on... I was just asking a question and trying to provide a little background to give my question some meaning. Sorry
Pete Dowson Posted July 29, 2011 Report Posted July 29, 2011 I didn't think you would appreciate me quoting the whole section since you wrote it. Some people may feel like I'm throwing it in their face. I just wanted to quote the part that says FSUIPC can be setup to automatically load the lua files. Which I did actually know! ;) By omitting the part that says "this is how" I naturally assumed you didn't realise you had to edit the INI file. Else why bother telling me about having Lua files loaded? Yes I did, yes I have and it's loading the lua as expected. Okay. So all of the first part of the post was really irrelevant and caused my misunderstanding of what you wanted to say! I just wanted to know if it's possible to have FSUIPC either re-run the "Auto" section or just re-load the lua file when the user reloads the aircraft. I think, then, you should have just asked that. Unfortunately it cannot detect a reload -- it does what it does now by seeing the aircraft name change. What is the problem with an aircraft reload? The Lua program shouldn't be stopping. Why does it need restarting? Maybe there's another solution to your problem? And apologies for appearing to "jump on you". If you re-read what you posted you will see why I couldn't see the question you really wanted to ask amidst what certainly looked to be a complaint against either the documentation of the Lua loading facilities or both. Regards Pete
Skittles Posted July 29, 2011 Author Report Posted July 29, 2011 I'm sorry about how I structured my post, yes I can understand the confusion. At first, I thought if I just asked the question, it would prompt you to ask me questions. I was trying to anticipate your questions. I'll give you the long story... I'm learning the lua script. I have the file ipcready.lua which contains a single line... ipc.macro("Lua GF-ModDisp") This is correctly loading and running my GF-ModDisp.lua file. This is written to display the Mag heading and speed on my GF46. function HDG(offset, value) gfd.SetDisplay(GF46,0,1,value) -- Display Mag Heading end function ASPD(offset, value) if ipc.readSW(0x0366) == 0 then gfd.SetDisplay(GF46,0,0,value /128) -- Display Air Speed end end function GSPD(offset, value) if ipc.readSW(0x0366) == 1 then gfd.SetDisplay(GF46,0,0,value *1.9438445 /65536) -- Display Ground Speed end end ----------------------------------- event.offset("2B00", "DBL", "HDG") -- A/C Mag Heading event.offset(0x02bc, "UD", "ASPD") -- Air Speed event.offset(0x02b4, "UD", "GSPD") -- Ground Speed It's working correctly. I'm trying to figure out how to make the displayed values a whole number. When I make a change in the code, I save the lua file and then change aircraft in the sim. (Thereby reloading the lua file) so I can see the affects of the change. When I change aircraft, the sim sends them spinning to the ground. So I was hoping it was possible to get FSUIPC to recognize a "aircraft reload".
Pete Dowson Posted July 29, 2011 Report Posted July 29, 2011 I'm learning the lua script. I have the file ipcready.lua which contains a single line... ipc.macro("Lua GF-ModDisp") I thought you were having your plug-in loaded automatically via the [Auto ...] system? For that you only need to put a line with Lua GF-ModDisp into the [Auto ...] section. There's no reason to use ipcReady as well. That's for Lua programs you want running all the time regardless of aircraft etc. Also, whilst ipc.macro("Lua GF-ModDisp") will work, it is a little easier and more efficient to use ipc.runlua("GF-ModDisp") BTW why "2B00" for one of the offsets and 0x.... for the others? Nothing wrong, just inconsistent. "2B00" is treated as 0x2B00. I'm trying to figure out how to make the displayed values a whole number. There's a Lua math library function called "floor" for that: math.floor(29.3456) gives 29. If you want to round to the nearest whole number add 0.5, i.e math.floor(x + 0.5) When I make a change in the code, I save the lua file and then change aircraft in the sim. (Thereby reloading the lua file) so I can see the affects of the change. It is much easier and quicker to simply assign a temporary keypress to the Lua and use that. Whilst testing plug-ins i tend to use TAB+Q (easy being next to each other). When you start a Lua program again it kills the first incarnation and loads it again. When I change aircraft, the sim sends them spinning to the ground. Not nice. Why's that? So I was hoping it was possible to get FSUIPC to recognize a "aircraft reload". It can only do that if the name changes. Regards Pete
Skittles Posted July 29, 2011 Author Report Posted July 29, 2011 I thought you were having your plug-in loaded automatically via the [Auto ...] system? For that you only need to put a line with Lua GF-ModDisp into the [Auto ...] section. There's no reason to use ipcReady as well. That's for Lua programs you want running all the time regardless of aircraft etc. I've been going back and forth, experimenting. I will go back to using the ini [Auto] section. Also, whilst ipc.macro("Lua GF-ModDisp") will work, it is a little easier and more efficient to use ipc.runlua("GF-ModDisp") OKBTW why "2B00" for one of the offsets and 0x.... for the others? Nothing wrong, just inconsistent. "2B00" is treated as 0x2B00. I was tinkering with which I like better There's a Lua math library function called "floor" for that: math.floor(29.3456) gives 29. If you want to round to the nearest whole number add 0.5, i.e math.floor(x + 0.5) Yes, I found the "floor" function, but I was missing the idea of adding 0.5... Thank You!It is much easier and quicker to simply assign a temporary keypress to the Lua and use that. Whilst testing plug-ins i tend to use TAB+Q (easy being next to each other). When you start a Lua program again it kills the first incarnation and loads it again. So instead of using Ctrl-Shft-R to reload the aircraft I can have it reload the lua... Why do I make things more complicated than they are? (Don't answer that LOL) Thank you for your time and sorry for the frustration I've caused. ADDED: That did the trick... the Math.Floor command works great and so does re-loading the lua. Boy did I make a mess out of this. Again, my apologies.
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