Jump to content




Attempt to compare nil with a number


  • You cannot reply to this topic
2 replies to this topic

#1 coarse

  • New Members
  • 2 posts

Posted 18 March 2014 - 11:17 PM

Whenever I try to input the number of tunnels (var a) I want, the program replies with
:21: attempt to compare to nil
even though i have set
local a = tonumber(read())
. The previous versions of this program did not have these errors at all.

The code:
Spoiler


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 18 March 2014 - 11:50 PM

You are declaring a as local to that function. When that function ends, a goes out of scope, so any attempts to use the variable a outside of that function will find that it is nil.

#3 coarse

  • New Members
  • 2 posts

Posted 19 March 2014 - 12:01 AM

I see, thank you! I will edit this post to see if it now works. I have to go to school in a few minutes so I wont be back until 4 pm gmt+8





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users