[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: hello I'm new and in a jam
- From: Patrick Rapin <toupie300@...>
- Date: Sat, 29 Oct 2011 09:22:49 +0200
> reply1 = io.read -- reply1 should only equal yes or no
reply1 now does not contain "yes", or "no", but the function io.read itself !
You probably forgot the parenthesis and want to write
reply1 = io.read()
> reply1 = yes
Now reply1 is nil, because yes is here a global variable most probably
not defined in the environment.
You forgot the quotes (either "yes", 'yes' or [[yes]] )
> if reply1 == yes then
Here for the same reason you test if reply1 is nil, and not if it is
the "yes" string.
> io.write("Oh good what would you like to drink ", g_Name, "\n")
> print(" white rum $7\n red wine $10\n gray goose $12 \n beer $2")
It is a bad idea to mix the io.write and the print function for the
regular output messages.
Most Luaers tell that print should only be used for debugging, and
io.write for serious output.
(Personally, I only use "print" for output, because I found easier to
redefine "print" than the io library for logging or sending to
OutputDebugString, for example)
In conclusion, your code contains a lot a small errors, so I would
suggest you to buy and read the book "Programming in Lua" !