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

Gammon Software Solutions forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Making a function repeat and question on the use of 'return'

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Faedara   (104 posts)  [Biography] bio
Date Fri 26 Nov 2010 06:07 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 26 Nov 2010 06:26 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Fri 26 Nov 2010 06:27 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Faedara   (104 posts)  [Biography] bio
Date Reply #3 on Fri 26 Nov 2010 06:48 AM (UTC)  quote  ]
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.
[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.


1,150 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]