astrograppa Posted August 10, 2010 Report Posted August 10, 2010 Hi, I would like to make a little lua program that allows me (means a button of joistick)to toggle a view of panel, then a second panel and finally none. The sequence is as follows: 1-push button 2-view the overhead panel (shft+6) number control 65911 3-push button 4-view the pedestal (shft+5) number control 65910 (and remove the overhead) 5-push button 6-remove pedestal (any panel) 7-push button ....restart over It's possible? ...and it is easy? Tanks
Pete Dowson Posted August 10, 2010 Report Posted August 10, 2010 I would like to make a little lua program that allows me (means a button of joistick)to toggle a view of panel, then a second panel and finally none. The sequence is as follows: 1-push button 2-view the overhead panel (shft+6) number control 65911 3-push button 4-view the pedestal (shft+5) number control 65910 (and remove the overhead) 5-push button 6-remove pedestal (any panel) 7-push button ....restart over It's possible? ...and it is easy? Yes. In fact you could do it just by conditional button programming in the FSUIPC INI file. But in Lua the logic is easier to follow. You need a memory of what last function your button executed, so you can move onto the next. The easiest way is to use one of the free FSUIPC offsets (the range 66C0 to 66FF is free for users). So: x = ipc.readUB(0x66C0) if x == 0 then ipc.control(65911) else if x == 1 then ipc.control(65910) else if x == 2 then -- et cetera, for each view change or whatever function you want -- ending with end x = x + 1 -- move on to next mode if x > 3 then -- 3 for 4 different settings (as we start at 0), and so on x = 0 end ipc.writeUB(0x66C0, x) Save your code into the FS Modules folder as, say "myviews.lua", and assign your button to it in the FSUIPC Buttons page. you may need to ask FSUIPC to relad the settings if you change the file whilst FS is running. Regards Pete
astrograppa Posted August 10, 2010 Author Report Posted August 10, 2010 Thanks Pete, you are a true genius and an endless resource of information. I modified the program in this way and it works perfectly. x = ipc.readUB(0x66C0) if x == 0 then ipc.control(65909) else if x == 1 then ipc.control(65909) ipc.control(65911) else if x == 2 then ipc.control(65911) end end end x = x + 1 -- move on to next mode if x > 2 then -- 3 for 4 different settings (as we start at 0), and so on x = 0 end ipc.writeUB(0x66C0, x)
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