Lua 中出现“尝试对函数值执行算术运算”的奇怪错误

我正在使用纯 Lua 编写一个 BASIC 解释器,在编写我的 SLEEP X 函数时遇到了难题。

我并不是专家,但这里看起来没有任何错误...

function s(time)
local time=tonumber(time)
if useSleep then sleep(time) elseif useWait then wait(time) else
--oh no
--我们将尽力而为
local ct=os.time+time
repeat until(os.time>=ct)
end end
--test
s(5)
点赞
用户107090
用户107090

你需要调用os.time,使用os.time()

os.time是函数。

os.time()是它的返回值。

2019-04-29 11:08:41