Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Missing END

Missing END

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Thu 28 Apr 2005 02:15 PM (UTC)
Message
I wrote this function:
function canEat ()
    if bHerb == 1 then
        if doHerb == nil then
            if aff['anorexia'] ~= 2 then
                return 1
            else
                return 0
            end
        else
            return 0
	end
    else
        return 0
    end
end

And now I'm trying to compare it: canEat () ~= nil
But it just wont work with me. The error message I got speaks of a missing END, to mark the end of the function:
[string "Plugin"]:284: `end' expected (to close `function' at line 237) near `<eof>'

Even though I fail to see how/where the function is lacking a END, I added on in the end, but got this:
[string "Plugin"]:239: attempt to call global `canEat' (a nil value)
stack traceback:
	[string "Plugin"]:239: in function `curePrompt'

I'm guessing there really should be one more END in there, but obviously not in the end of it.. Could anyone with keener LUA-eyes help me out here?

Simplicity is Divine | http://nogfx.org/
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Thu 28 Apr 2005 05:54 PM (UTC)

Amended on Thu 28 Apr 2005 05:55 PM (UTC) by Flannel

Message
You sure that it's this function? Since I don't get an error. Possibly an error where you're calling it? or maybe the function before it?

You can also get rid of all those else's and rewrite it like this (unless of course, you were going to change some of those return 0s later):
function canEat ()
  if bHerb == 1 then
    if doHerb == nil then
      if aff['anorexia'] ~= 2 then
        return 1
      end
    end
  end
  return 0
end

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Reply #2 on Thu 28 Apr 2005 08:17 PM (UTC)
Message
Solved it just now. Apparently I had done something like:
if expression then
    command
if expression2 then
    command2
end

Changed number two to "elseif" and now it's running again.

Simplicity is Divine | http://nogfx.org/
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,157 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.