Jump to content
The simFlight Network Forums

ipc.readLvar() data format


Recommended Posts

Hello Pete,

Does n= ipc.readLvar() assume a particular data format for the value n read (byte, word, floating point, etc), or does it just default to the Lvar's format? 

I'm asking because if I read an Lvar value and then want to write it to an offset with ipc.writeXX(0x1234, n), I need to decide what XX is (UB, SW, DBL, etc).

Best for the holidays,

Al

 

Link to comment
Share on other sites

1 hour ago, ark1320 said:

Does n= ipc.readLvar() assume a particular data format for the value n read (byte, word, floating point, etc), or does it just default to the Lvar's format? 

It actually arrives as a double float (FLOAT64), which is just a number in Lua's terms.  There's only one "number" type in Lua, so it is something you don't need to worry about.

1 hour ago, ark1320 said:

I'm asking because if I read an Lvar value and then want to write it to an offset with ipc.writeXX(0x1234, n), I need to decide what XX is (UB, SW, DBL, etc).

Well, that depends on what sort of values you expect or want to deal with. Lua numbers are all floating point and therefore also signed, but many applications of L:Vars are neither -- eg plain 0 and 1 for OFF/ON. but 0 and 1 will stil be okay whether signed or unsigned and whether fixed point orfloating point. 

In other words it is your choice what you want to see in your offset. If you elect for fixed point and there are fractions, FSUIPC will round it to the nearest whole number. But a negative number stored as unsigned will look to you are a very large positiive number).

Hope this is clear?

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.