如果声明有宽容

时间:2016-09-17 21:30:49

标签: lua

我有一个用于恒温器的Domoticz LUA脚本,我想在IF语句中实现容差。

目前的代码如下:

if (current < target) then
            debuglog('Heating - Turning Physical Heater On: '.. physicalheater)
 else debuglog('Heating - Turning Physical Heater OFF: '.. physicalheater)

我想要达到的目标是:

if (current < target +-2 ) then
            debuglog('Heating - Turning Physical Heater On: '.. physicalheater)
 else debuglog('Heating - Turning Physical Heater OFF: '.. physicalheater)

0 个答案:

没有答案