variables - Lua Others can run my code perfectly fine but I run into errors? -


i have lua script have been trying work. first lua script. asked else run code, , worked fine them. however, when try run anywhere (i have tried running in ideone.com, codepad.com, lexecutor, garry's mod etc), same error message. error message 'attempt compare nil number' , it's on line 4. if helps, os windows 7. code below , ask guys test see if works. if possible, state used run if worked. it's meant input box come , user has input age. if age on or under 12, old/young , if age 12 'welcome, son!'.

io.write ("enter age:") age = io.read() age = tonumber(age) if age < 12   print ("o noes, young!") elseif age > 12   print ("o noes, old!") else   print ("welcome, son!") end 

the code fine. problem is, if try out on websites ideone, have provide input explicitly, otherwise age gets no input, value nil, causing error.

demo on ideone, note stdin part.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -