Jump to content
The simFlight Network Forums

LUA and panel


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.