Lua-当前时间(以毫秒为单位) [英] Lua - Current time in milliseconds

查看:1679
本文介绍了Lua-当前时间(以毫秒为单位)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种通用方法可以获取当前时间(以毫秒为单位)或以毫秒为单位?

Is there a common way to get the current time in or with milliseconds?

os.time(),但仅提供完整的秒数.

There is os.time(), but it only provides full seconds.

推荐答案

在标准C语言中,没有.除非您愿意自己修改lua解释器以使os.time使用所需的分辨率,否则您将需要安顿下来几秒钟.但是,如果您要编写代码供他人独立运行,而不是像Web应用程序那样可以完全控制环境,那么这可能是不可接受的.

In standard C lua, no. You will have to settle for seconds, unless you are willing to modify the lua interpreter yourself to have os.time use the resolution you want. That may be unacceptable, however, if you are writing code for other people to run on their own and not something like a web application where you have full control of the environment.

另一种选择是用C编写您自己的小DLL,它使用新函数扩展lua,该新函数将为您提供所需的值,并要求将DLL与您的代码一起分发给将要使用它的人.

another option is to write your own small DLL in C that extends lua with a new function that would give you the values you want, and require that dll be distributed with your code to whomever is going to be using it.

这篇关于Lua-当前时间(以毫秒为单位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆