Jump to content
The simFlight Network Forums

Question about reading variables


Recommended Posts

I have been trying for a while to figure a way to read the "A" (and other) variables using a LUA script. I can read and write L variables just fine but I can't find a way to read an "A" variable. (A:PROP SYNC ACTIVE, bool) for example. Is there some reason this can't be done?

The point of the excercise is to take toggle only functions and add on/off assignability to them that can be easily included in the LINDA librairies. I have managed to kluge something together but only by adding an xml gauge to the plane for the reading of the "A" variables involved. Since the point is to make this something easy for pilots who are not computer savvy... adding a guage is not a great option.

What I have so far is this:

LUA

function Prop_Sync_On ()

ipc.writeLvar("L:JMH_Prop_Sync", 1)

end

function Prop_Sync_Off ()

ipc.writeLvar("L:JMH_Prop_Sync", 0)

end

Corresponding XML

(L:JMH_Prop_Sync, bool)

(A:PROP SYNC ACTIVE, bool)

!= if{ (>K:TOGGLE_PROPELLER_SYNC) }

Any Help?

Cheers, Bao

Link to comment
Share on other sites

I have been trying for a while to figure a way to read the "A" (and other) variables using a LUA script. I can read and write L variables just fine but I can't find a way to read an "A" variable. (A:PROP SYNC ACTIVE, bool) for example. Is there some reason this can't be done?

Checking the Gauge SDK it says for one of these A: variables:

"The A:GENERAL ENG FUEL PRESSURE, is a simulation variable (there are many hundreds of these, listed in the Simulation Variables document)."

Now these are SimConnect values which are almost all mapped to FSUIPC offsets, so they should be accessible using the various ipc.read and ipc.write functions. Choose the one which suits the variable type.

All of the FSUIPC offsets are listed in a document called FSUIPC4 Offsets Status, which is in the FSUIPC SDK. If you search that for "prop sync" you'll find is as a 32-bit Boolean value (i.e. 0 for false, 1 for active) at offset 2EC8. So you read it with ipc.readUD and write it with ipc.writeUD.

Regards

Pete

Link to comment
Share on other sites

Thanks Pete It works like a charm. I wasn't sure weather or not it could be written to (SDK says untested and the corresponding "A" variable in fsx can not be written to) so I tried it both ways.

funhction Prop_Sync_On ()

if ipc.readUD(0x2EC8) == 0 then

ipc.control(66287, 1)

end

end

Or

function Prop_Sync_On ()

ipc.writeUD(0x2EC8, 1)

end

Both work great

Now as for the UD on the ipc.write

Which in the plethera of pdf files will I find the explinations if UD, WD, etc.?

Link to comment
Share on other sites

Now as for the UD on the ipc.write

Which in the plethera of pdf files will I find the explinations if UD, WD, etc.?

There's no "WD". Plethora? Where else but the Lua library documentation?

All the functions supported by the FSUIPC Lua libraries are documented with explanations in the Lua Library document, in the Lua Plugins package in your FSUIPC Documents subfolder. Or download the latest package from the Download Links subfolder.

Regards

Pete

Link to comment
Share on other sites

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.