lua-users home
lua-l archive

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


> In conclusion, your code contains a lot a small errors, so I would
> suggest you to buy and read the book "Programming in Lua" !

For the true novice, I think working through TutorialDirectory using
just the interpreter is the best recommendation:
http://lua-users.org/wiki/TutorialDirectory

- David

On Sat, Oct 29, 2011 at 2:22 AM, Patrick Rapin <toupie300@gmail.com> wrote:
>> 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" !
>
>