lua-users home
lua-l archive

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


On 2 November 2011 20:56, kingsley young <kingsleyyoung27@gmail.com> wrote:
> newReply1 = io.read();
>
> for newReply1=="beer" do
> io.write("SO which drink would you like: ", newReply1, "\n" );
> io.write("hite rum $7\n red wine $10\n gray goose $12 \n beer $2\n");
> end

This is not valid Lua syntax. The "for" statement has 2 forms [1]
(examples given):

    for var = 1, 100 do ... end
    for key, val in pairs(tab) do ... end

I do not know what "for newReply=='bear' do" is supposed to mean...
Maybe you are looking for a "while" loop?

    io.write("So, what woud you like? ")
    reply = io.read()

    while reply ~= "beer" do
        io.write("Sorry, we don't serve ", reply, ", try something else: ")
        reply = io.read()
    end

[1] http://www.lua.org/manual/5.1/manual.html#2.4.5