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

查看:88
本文介绍了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 中,没有.您将不得不等待几秒钟,除非您愿意自己修改 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天全站免登陆