SenorRaj Posted September 19, 2015 Report Posted September 19, 2015 Hi, I am currently beginning to implement the x66c0 button modifier solution on my Saitek yoke and quadrant with great success (many thanks to Pete's documentation and Gypsy Baron's contributions on this site and others!). I'm also using a modified version of Pete's DisplayVals.Lua which is incredibly helpful to a relative newbie to FSX and Lua coding. What I have been unable to do is add the correct code in DisplayVals.Lua to display what mode I'm currently using. I've tried using the same syntax as is used in that Lua file, but it's quickly become apparent that that won't work with a button state. I have tried a couple of If-Then statements, but to no avail. Unfortunately, I'm no coder, and I have searched through every single one of the FSUIPC documents and in articles on this site, however I can't seem to find the correct syntax for what I thought would be relatively simple. Not for me unfortunately! If someone could at least tell me where exactly in the documentation I should be looking, it would be much appreciated. Thank you, Paul
Pete Dowson Posted September 19, 2015 Report Posted September 19, 2015 What I have been unable to do is add the correct code in DisplayVals.Lua to display what mode I'm currently using. I've tried using the same syntax as is used in that Lua file, but it's quickly become apparent that that won't work with a button state. I have tried a couple of If-Then statements, but to no avail. Unfortunately, I'm no coder, and I have searched through every single one of the FSUIPC documents and in articles on this site, however I can't seem to find the correct syntax for what I thought would be relatively simple. Not for me unfortunately! If someone could at least tell me where exactly in the documentation I should be looking, it would be much appreciated. Syntax, permitted instructions, and general language help is all provided on the Lua website, the one referenced in the Lua documents I provide (see below *). I cannot undertake to document the language itself, only the FSUIPC specific additions. However, if I understood what you wanted and what you've tried and failed with, maybe I could help more directly. For instance i've no idea what you mean by " it's quickly become apparent that that won't work with a button state". Pete * From the FSUIPC Lua documentation: What is “Lua”? It is a programming language. The best way to see and learn what it is all about is to visit this web page: http://www.lua.org/about.html
SenorRaj Posted September 19, 2015 Author Report Posted September 19, 2015 (edited) Syntax, permitted instructions, and general language help is all provided on the Lua website, the one referenced in the Lua documents I provide (see below *). I cannot undertake to document the language itself, only the FSUIPC specific additions. However, if I understood what you wanted and what you've tried and failed with, maybe I could help more directly. For instance i've no idea what you mean by " it's quickly become apparent that that won't work with a button state". Pete * From the FSUIPC Lua documentation: What is “Lua”? It is a programming language. The best way to see and learn what it is all about is to visit this web page: http://www.lua.org/about.html Hi Pete. What I meant was that I used the same syntax you use in DisplayVals.lua, ie mode = ipc.readSW(0x66c0) and then adding mode= to the ipc.display list. I've successfully done this for rudder trim, etc values, but as this is a button state I'm assuming I need to use a different query to get the mode state (1-3, or 0-2 to be exact). Thanks. Edited September 19, 2015 by SenorRaj
SenorRaj Posted September 19, 2015 Author Report Posted September 19, 2015 Apologies Pete, it's working now. I think i must have tested displayVals.lua before I had setup the offset modifier correctly in the aircraft.ini file. Apologies for any of your time wasted. And thanks again for your fantastic program and support! Paul
Pete Dowson Posted September 19, 2015 Report Posted September 19, 2015 Hi Pete. What I meant was that I used the same syntax you use in DisplayVals.lua, ie mode = ipc.readSW(0x66c0) and then adding mode= to the ipc.display list. I've successfully done this for rudder trim, etc values, but as this is a button state I'm assuming I need to use a different query to get the mode state (1-3). Thanks. You mean adding ".. \nMode=" .. mode" to the end, before the closing)? Why not show me the whole line? BTW with offset 66C0, are you sure it is an "SW" signed word (ie 2 bytes, or 16 bits?), with a range -65536 to +65535?. Usually, it is just used for a mode selection, a single unsigned byte (UB) is sufficient. That has a range of 0-255. BTW if you are still using the original code from the examples installed with FSUIPC, it would be a little more efficient these days to use the event system to make it run 20 times per second. To do this put function displayvals() at the beginning instead of the "while 1 do", remove the ipc.sleep(50) line, and add event.timer(50, "displayvals") at the end, after the 'end' line. Pete [LATER] Oops. Crossed with your "fixed" post.
SenorRaj Posted September 20, 2015 Author Report Posted September 20, 2015 You mean adding ".. \nMode=" .. mode" to the end, before the closing)? Why not show me the whole line? BTW with offset 66C0, are you sure it is an "SW" signed word (ie 2 bytes, or 16 bits?), with a range -65536 to +65535?. Usually, it is just used for a mode selection, a single unsigned byte (UB) is sufficient. That has a range of 0-255. BTW if you are still using the original code from the examples installed with FSUIPC, it would be a little more efficient these days to use the event system to make it run 20 times per second. To do this put function displayvals() at the beginning instead of the "while 1 do", remove the ipc.sleep(50) line, and add event.timer(50, "displayvals") at the end, after the 'end' line. Pete [LATER] Oops. Crossed with your "fixed" post. Thanks very much on the updated code for the displayvals.lua Pete, more effiency is always a good thing! Apologies again for unnecessarily wasting your time. Will be more thorough in future before posting a problem.
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