count++ 和 count%x 从 Java 到 Lua 的翻译

count++ and count%x translation from Java to Lua

我正在 Lua 中构建程序。

在我的代码中,我必须将 count++ 从 Java 翻译成 Lua。我该怎么做? 我假设它是 count = count + 1,但是还有其他方法可以解决这个问题吗?

还有,当你写(count % 20 == 0)的时候,Lua、(math.mod(count,20) == 0)是正确的翻译吗?

以上两行我都试过了,但是其中一条好像不行。

a % b == a - math.floor(a/b)*b

来自:Lua replacement for the % operator

count = count + 1 就可以了

您可以通过粘贴

来查看实际效果
count = 1 
count = count + 1
print(count)
print((count - math.floor(count/2)*2) == 0) --ie count % 2 == 0

进入http://www.lua.org/cgi-bin/demo