Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Mr. Dowson, you've been very patient and helpful. I hope I'm not pressing my luck.

The Questions: Can a Lua script read a Button Flag? OR Can FSUIPC make compound buttons based on a Lua flag?

The Reason: I'm making a Lua script to run my GF-MCP. So far, everything is working as programmed. I can't quite figure out how to program the IAS/MACH selector. I'm probably over complicating things again.

What I'm thinking:

I think I need two toggles. One for general SPD Hold and another for IAS & MACH. As far as I know, there's no offset that toggles the IAS & Mach display in FS9.

I could use the Lua Toggle but I need the rotary to toggle between changing the Airspeed value and the Mach value.

I could use a button flag, but then how do I program Lua to check it?

Thanks for your time and efforts.

Joe

Posted

Can a Lua script read a Button Flag?

Not at present, but it wouldn't be a bad idea to add such a facility! Great idea. I'll do it next week!

OR Can FSUIPC make compound buttons based on a Lua flag?

No. I really can't see that being practical. Each Lua thread has its own set of flags. Linking to one of them would be quite complex and I'm not sure how you'd record that within the 32 bits available for button encoding.

The Reason: I'm making a Lua script to run my GF-MCP. So far, everything is working as programmed. I can't quite figure out how to program the IAS/MACH selector. I'm probably over complicating things again.

Well, I don't know what route you are following -- really any type of compound or conditional button programming can be done by straight Lua scripting without complex button definitions. But the main thing which can relate Lua capabilities to button conditions is their access to FSUIPC offsets. Your Lua can write to offsets which are then defined as conditions on button assignments. You can use the user offsets 0x66C0 to 0x66FF.

I think I need two toggles. One for general SPD Hold and another for IAS & MACH. As far as I know, there's no offset that toggles the IAS & Mach display in FS9.

Correct. The IAS/Mach display is local to the MCP gauge code.

Whether the autothottle is following the IAS or the Mach value is, however, dependent on A/T settings -- IAS hold or Mach hold. Those two are certainly separate and will therefore tell you which to display. The problem really only arises when the A/T is NOT engaged and you want to adjust or display a mach or IAS value which isn't actually dictating speed. Really that can all be done locally to the MCP without the FS simulation being involved. If you think that way it makes it easier.

Regards

Pete

Posted
Not at present, but it wouldn't be a bad idea to add such a facility! Great idea. I'll do it next week!
That would be cool!
Well, I don't know what route you are following -- really any type of compound or conditional button programming can be done by straight Lua scripting without complex button definitions. But the main thing which can relate Lua capabilities to button conditions is their access to FSUIPC offsets. Your Lua can write to offsets which are then defined as conditions on button assignments. You can use the user offsets 0x66C0 to 0x66FF.
There are separate controls for changing the IAS speed and the Mach speed. So I set up a compound button to be a IAS/MACH toggle. Then I set the rotary to either change the IAS or Mach based on the button flag.

So I should be able to use an offset instead of a button flag to setup a compound button? I'll get into the book for that.

Thanks,

Joe

Posted

So I should be able to use an offset instead of a button flag to setup a compound button? I'll get into the book for that.

Yes.

For a simple flag just use, say, a byte at offset 66C0. In Lua set it by

ipc.wruteUB(0x66C0, 0) or ipc.wruteUB(0x66C0, 1)

and test is as an offset condition in the [buttons] section be preceding the usual button assignment by

B66C0=0 or B66C0=1

B is for Byte.

U is for Unsigned.

Pete

Posted

Not at present, but it wouldn't be a bad idea to add such a facility! Great idea. I'll do it next week!

Okay, I've added the new Lua function

ipc.testbuttonflag(joystick, button)

where the parameters are the same as for ipc.testbutton, but the resuilt is true or false depending on the state of the flag, not the button.

This is included in FSUIPC versions 3.997m and 4.724, being uploaded as I write this.

Regards

Pete

Posted

Okay, I've added the new Lua function

ipc.testbuttonflag(joystick, button)

where the parameters are the same as for ipc.testbutton, but the resuilt is true or false depending on the state of the flag, not the button.

This is included in FSUIPC versions 3.997m and 4.724, being uploaded as I write this.

Regards

Pete

You're just way too awesome!

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.