lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello there,

So this is my first "lua mailing list" post and I got a problem with my lua code

I just started coding luai yesterday and tutorials won't give me answers to my case.

So, in this scenario, I want the code to first ask the user for his name and age. Then, depending the age is either below or above (or exact) 18, it should print different text lines.

The problem is, it prints the line "Hello, .. myName" but everything after doesn't compile...

As said, it's my first code and still trying to improve my knowledge of lua/luai. Any further improvements would also be appreciated.

Here's the code:

io.write("Please enter your name here: ")
local myName = io.read( )
io.write("Please enter your age here: ")
local myAge = io.read( )

print ("Hello, " .. myName)

if myAge < 18 then
 print ("\nwe're sorry but you must be 18 or above to continue")
end
if myAge >= 18 then
 print ("\nYou are allowed to continue without limitations")
end

Thanks in advance
(Also English isn't my first language so please excuse any English mistakes)