[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Missing END
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Missing END

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


Posted by tobiassjosten   Sweden  (79 posts)  [Biography] 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/
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] 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.
[Go to top] top

Posted by tobiassjosten   Sweden  (79 posts)  [Biography] 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/
[Go to top] 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.


3,612 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]