This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

attempt to compare number with nil
#1
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)
end
Reply
#2
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.
Reply
#3
Log gives me

Code:
* number: 0

Thanks 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.
Reply


Forum Jump: