![]() |
|
attempt to compare number with nil - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: attempt to compare number with nil (/showthread.php?tid=4404) |
attempt to compare number with nil - sx3 - 28.11.2022 Keep getting this error and I'm not sure how to get rid of it. 3/0/41 is DPT1 3/0/21 is a percentage value. I have tried using DPT9 and now using DPT5 3/0/21 is mostly at 0%, I've tried to manually set the GA to 0 to be sure it's not nil. Code: Resident script:9: attempt to compare number with nil
stack traceback:Code: local auxswitch = grp.getvalue('3/0/41')
local auxstatus = grp.getvalue('3/0/21')
if auxswitch == true then
grp.write('3/0/57', 0)
elseif (auxswitch == false and auxstatus == 0) then
grp.write('3/0/57', 1)
elseif (auxswitch == false and auxstatus >= 1 and auxstatus <= 33) then
grp.write('3/0/57', 2)
elseif (auxswitch == false and auxstatus >= 34 and auxstatus <= 66) then
grp.write('3/0/57', 3)
elseif (auxswitch == false and auxstatus >= 67 and auxstatus <= 100) then
grp.write('3/0/57', 4)
endRE: attempt to compare number with nil - admin - 28.11.2022 Add log(auxstatus) after grp.getvalue and check what you get in Logs tab. You should use event script instead of resident. Add a common tag to 3/0/41 and 3/0/21 then map an event script to this tag. RE: attempt to compare number with nil - sx3 - 28.11.2022 Log gives me Code: * number: 0Thanks for the tip regarding event. Haven't realized that a tag can trigger event-script, always thought it had to be specific GA. Will migrate the script to event later. |