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

Posted by Faedara on Fri 26 Nov 2010 06:07 AM — 4 posts, 19,517 views.

#0
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.
Australia Forum Administrator #1

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.
Australia Forum Administrator #2
Template:post=4957
Please see the forum thread: http://gammon.com.au/forum/?id=4957.
#3
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.