Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi Peter,

First time on these forums, although I have been reading and searching your posts over the last couple of days. Other than that I'm a real noob (as they say) with FSUIPC + Lua. Have experience with CH scripting, but FSUIPC and Lua just add a new dimension to it all.

Basically I wanted to demonstrate the power of FSUIPC and test a few lines with conditions, as below:

[Keys.PMDG B1900C]

1=76,10,65751,0

2=78,11,66379,0

3=66,11,66239,0

4=83,11,65560,0

5=79,8,66378,0

6=84,11,66240,0

7=76,8,66376,0

8=D0574>3048 66,9,66846,0 I actually used 900m for testing purposes :)

9=D0574<3048 66,8,65584,0

11=D02BC<23040 71,9,66080,0

12=W0366=0 71,8,66079,0

Description:

For those browsing by, lines 8 & 9 set a condition such that the plane must be greater than FL100t to set BAROMETRIC STD PRESSURE(66846) - SHIFT b. Thus, it must be below FL100 to set BAROMETRIC - B.

Line 11 Sets a condition such that the IAS must be undert 180kts IAS (23040/128=180), for GEAR DOWN(66080) - SHIFT g.

Line 12 is from page 20 of the advanced users guide.

Question:

So with regards to the script above, is it possible to replicate keypress commands with thier offset conditions, just using Lua?

For example, relicating Line 11 in Lua code - Gear Down key will Not work until the IAS< 23040

Best Regards

John

Posted

So with regards to the script above, is it possible to replicate keypress commands with thier offset conditions, just using Lua?

There are currently no facilities in the Lua libraries to intercept or act on keypresses (except of course by being assignerd to a keypress). The need has never come up before. Mostly Lua is used in hardware type scenarios rather than keyboard us for flying.

However, I can see that hooking the keyboard in the same way that FSUIPC does could be useful, so I'll put it on the list. Not sure what priority it should have compared with FSUIPC assignments and hotkeys. What do you think? Lua to hook first? Then of course if passed on (by "ipc.keypress") I'd need to avoid the loop.

I can't get to such things for a couple of weeks. My code signature expires in a week or so and I'm trying to update all the documentation for FSUIPC so I can make a complete replacement release before then, with the new 3-year signature.

I suspect that, in most cases, you'd be better using the event.control function instead. In your example, for instance, you'd hook the Gear Toggle or Gear Down controls instead of just the keypress -- then it would work for buttons and switches too.

(However, at present the event.control facility only calls the Lua function when that control is seen. It doesn't stop it, so maybe a different facility is needed -- if such stopping is possible. I don't know offhand).

Regards

Pete

Posted (edited)

There are currently no facilities in the Lua libraries to intercept or act on keypresses (except of course by being assignerd to a keypress). The need has never come up before. Mostly Lua is used in hardware type scenarios rather than keyboard us for flying.

I suspect that, in most cases, you'd be better using the event.control function instead. In your example, for instance, you'd hook the Gear Toggle or Gear Down controls instead of just the keypress -- then it would work for buttons and switches too.

(However, at present the event.control facility only calls the Lua function when that control is seen. It doesn't stop it, so maybe a different facility is needed).

Ok,

Could you elaborate on this aspect: "- you'd be better using the event.control function instead. In your example, for instance, you'd hook the Gear Toggle or Gear Down controls instead of just the keypress -- then it would work for buttons and switches too." :)

Of course your referring to linking in the actual button on my controller that initiates the key press.

Hence, the initating button is checked against the condition first.

......a little late here on this side of the planet :o

Edited by RNAV05
Posted

Could you elaborate on this aspect: "- you'd be better using the event.control function instead. In your example, for instance, you'd hook the Gear Toggle or Gear Down controls instead of just the keypress -- then it would work for buttons and switches too." :)

You need to read the last part too:

(However, at present the event.control facility only calls the Lua function when that control is seen. It doesn't stop it, so maybe a different facility is needed).

What exactly needs elaborating for you?

Pete

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.