Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种方法来暂停我的程序以允许用户在它关闭之前阅读,但函数 (os.sleep(timeSeconds)) 显然不存在。有人知道解决方法吗?
你可以利用os.clock()and os.time()。前任:
os.clock()
os.time()
function sleep(n) local t = os.clock() while os.clock() - t <= n do -- nothing end end
n 以秒为单位。随意制作os.time()版本。
更好地使用 OS 内置设施来保留输出窗口,而不是引入人为延迟。如果用户从已经打开的命令窗口运行您的程序或将输出重定向到文件怎么办?你强迫他白白浪费时间。