带公差的 IF 语句

我有一个针对恒温器的 Domoticz LUA 脚本,并且我想在 IF 语句中实现公差。

当前代码如下:

if (current < target) then
            debuglog('加热中 - 启动物理加热器: '.. physicalheater)
 else debuglog('加热中 - 关闭物理加热器: '.. physicalheater)

我想要实现的是:

if (current < target +-2 ) then
            debuglog('加热中 - 启动物理加热器: '.. physicalheater)
 else debuglog('加热中 - 关闭物理加热器: '.. physicalheater)
点赞