Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Looking through the FSUIPC Lua ref doc. I'd like to be able to get the current time in ms in a script I'm planning out. I believe Lua doesn't have a standard (os-independent) way to do this. Since you have event.timer in your exposed libs (as well as several other ms based functions), I'm guessing you've implemented this in c++ and you're calling something there in your Lua libs. I'm wondering if you'd consider exposing a plain old "get time in ms since the epoch" sort of function in one of your libs? 

Posted
4 hours ago, Matthew Twomey said:

I'd like to be able to get the current time in ms in a script I'm planning out. I believe Lua doesn't have a standard (os-independent) way to do this.

Which "time" do you want? The windows systems time, the one set on your PC. Or the time in the Sim?

There's an "absolute time" (!!) which is probably the former, as a double in offset 0230.  Local FS time and the related Zulu is given in other offsets nearby.

The time in the Operating System, no matter which, is provided by the Lua os library function os.time.  Most (all in most cases) of the functions in the standard Lua libraries are included in the FSUIPC interpreter, as documented in the Lua PDF provided. For Lua standard library functions please refer to Lua.org (or buy the book! 😉 )

There is a also the elapsed time since FSUIPC was started (ipc.elapsedtime) but I don't think that's what you wanted. 

Pete

 

Posted
1 hour ago, Pete Dowson said:

The time in the Operating System, no matter which, is provided by the Lua os library function os.time.  Most (all in most cases) of the functions in the standard Lua libraries are included in the FSUIPC interpreter, as documented in the Lua PDF provided. For Lua standard library functions please refer to Lua.org (or buy the book! 😉 )

Yes, this was the point of my post - if you take a look at lua.org, you'll see that os.time() typically returns time in seconds. This indeed appears to be the case in the interpreter you are using in FSUIPC. What I'm looking for is milliseconds.

Thank you for the offset pointer, I didn't think to search the offsets doc for it as an alternative. That gives back milliseconds and that will work for me!

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.