plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.

In the upcoming flighting, we've changed the behaviour of the content.xml file. If your addon uses this file, please read this article!

Please take a moment to read the platform’s guidelines before you get started!


Idea

DA40CGDFQ avatar image
DA40CGDFQ suggested StevenPearce edited

Save large number to LVars in javascript

You can read large numbers from LVars in javascript, however you cannot save them to LVars in javascript.
If you set an LVar in XML code:

(E:ABSOLUTE TIME, SECONDS) (L:XIP_ABSOLUTETIMESTART) - (>L:DA40180XIP_ABSOLUTETIME)

and then n javascript read the number - it gets the correct value:

var currenttime = SimVar.GetSimVarValue("L:XIP_ABSOLUTETIME", "seconds");


A number around 63000000000.000 give or take. How ever if you now save that number back

SimVar.SetSimVarValue("L:XIP_ELAPSETIMESTART", "seconds", currenttime);
it will not save correctly you get a number that is close but not the same.

aircraft
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

1 Comment

·
StevenPearce avatar image
StevenPearce commented StevenPearce edited

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

I expect the number you are getting when reading the SimVar is also wrong, you just don't notice the error.

You could try using BigInt() or passing the number as a string, but I have no idea if that works. BigInt didn't even exist in browsers 5 years ago, you had to use a library to work with big numbers.

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Write a Comment

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.