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 ➜ Weird if problem

Weird if problem

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


Posted by Gore   (207 posts)  Bio
Date Tue 29 May 2007 10:28 PM (UTC)
Message
function il_curare ()
  if prev_curare == 1 then -- Line 424
    return 'You are afflicted 1.'
    prev_curare = 2 -- Line 426
  end
  if prev_curare == 2 then
    return 'You are afflicted 2.'
    prev_curare = 1
  end
end

function venom_scytherus (n,o,wc)
  Send ('secrete scytherus')
  Send ('conjure '..target['cur']..' illusion '..il['bite']..il['nl']..il_curare())
  Send ('bite '..target['cur'])
  Send ('purge')
end

Compile error
World: Achaea
Immediate execution
[string "Script file"]:426: 'end' expected (to close 'if' at line 424) near 'prev_curare'


Why is it telling me that? heh
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 29 May 2007 11:39 PM (UTC)
Message
After a "return" it is not logical to put more statements, as they will never be executed.

Thus the line:


prev_curare = 2


... cannot be reached, and it is advising that only "end" is possible here.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #2 on Wed 30 May 2007 02:24 AM (UTC)

Amended on Wed 30 May 2007 02:26 AM (UTC) by Shaun Biggs

Message
You might also want to change that around with an if/else just to save a bit of error checking.

function il_curare ()
  if prev_curare == 1 then -- Line 424
    prev_curare = 2 -- Line 426
    return 'You are afflicted 1.'
  elseif prev_curare == 2 then
    prev_curare = 1
    return 'You are afflicted 2.'
  end
end

If you don't use an else, you will validate both of the statements, since you will set prev_curare to 2 before checking if it's set to 2. That might be what you're trying to do though, I admit I don't know much about Achea and it's status affects. This is, of course, only a risk if you change your code to get rid of the returns, but it's a good idea in case you decide make changes at a later date.

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Gore   (207 posts)  Bio
Date Reply #3 on Wed 30 May 2007 10:22 AM (UTC)
Message
Ah yeah that makes sense, sorry about that, and thanks -g- I had an else statement but I changed it to two seperate if's to see if it would fix the problem. Such simple errors! thanks again.
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.


15,311 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.