lua脚本中,如何实现and语句?

2025-05-11 02:42:41
推荐回答(1个)
回答1:

a and b 语句 表示 对 ab做与操作,
如果a为真,返回值为后者,如果 a为假 返回值为a本身
or的话相反 如果a为真 返回值为a,如果a为假 返回值为b
所以你这里只要使用

if (Keys.held.Up) then
a=a+1
c=c+1
end
if (a==5 and b==5) then
c=100
end
if (a==5 or b==5) then
c=100
end
不要把所有东西写到一行里
这样不会提高程序的执行效率,反而会降低代码的可读性