Jump to content
The simFlight Network Forums
Sign in to follow this  
ark1320

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

 

Share this post


Link to post
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

 

Share this post


Link to post
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...
Sign in to follow this  

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