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 ➜ Making a function repeat and question on the use of 'return'

Making a function repeat and question on the use of 'return'

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


Posted by Faedara   (106 posts)  Bio
Date Fri 26 Nov 2010 06:07 AM (UTC)
Message
Alright, this is a small simple and probably silly question, if I make this function:


    if herb_bal == n or
      aff.anorexia == y or
      aff.aeon == y or
      aff.sleep == y or
      aff.stunned == y or
      aff.impaled == y or
      aff.transfixed == y or
      aff.broken == y then
      -- repeat if statement
    else
      -- continue code
    end


How do I make this constantly repeat?
I think I replace "-- repeat if statement" with "return" but I'm not sure, and I couldn't find a help file on 'return', or even a decent reference to it.

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 26 Nov 2010 06:26 AM (UTC)
Message

while herb_bal == n or
      aff.anorexia == y or
      aff.aeon == y or
      aff.sleep == y or
      aff.stunned == y or
      aff.impaled == y or
      aff.transfixed == y or
      aff.broken == y do

-- some sort of delay here or your PC will freeze up

    end


Not sure about the "== n" - do you mean:


aff.anorexia == "y" or


Bear in mind those variables won't change if you have a tight loop - you probably need to wait a second, in which case you may have to rethink the loop.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 26 Nov 2010 06:27 AM (UTC)
Message
Template:post=4957 Please see the forum thread: http://gammon.com.au/forum/?id=4957.

- Nick Gammon

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

Posted by Faedara   (106 posts)  Bio
Date Reply #3 on Fri 26 Nov 2010 06:48 AM (UTC)
Message
Yeah, those were supposed to be in quotation marks, haha.

And unless I make it so that it runs by activating every time I receive my prompt, I don't see how that w- oh... yeah... that's actually a good idea.

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
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,186 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.