|
Making a function repeat and question on the use of 'return'
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Faedara
(104 posts) 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. | top |
|
| Posted by |
Nick Gammon
Australia (18,770 posts) 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:
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 (18,770 posts) bio
Forum Administrator |
| Date |
Reply #2 on Fri 26 Nov 2010 06:27 AM (UTC) [ quote
] |
| Message |
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
Faedara
(104 posts) 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. | 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
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )