Problem description: I've looked mostly everywhere I could think of, and I can't seem to find the code that lets me add values per second, or just in any unit of time really. What I want the verb to be able to do is increase a variable by a set amount every set amount of seconds. Anyone know how to do this?
IE. I hit the meditate verb and want my spirit to go up rand(0,20) every 2 seconds. Without continuously hitting the meditate verb. Sorry if I come across as vague.
ID:844603
Jun 30 2012, 8:27 pm (Edited on Jun 30 2012, 8:35 pm)
(See the best response by Kaiochao.)
|
|
In response to Kaiochao
|
|
mob/verb I tested that and it gave me a message about infinite looping... Any ideas on how to dodge that? |
Don't you see a difference between our code? Tabs matter.
proc Only statements in the while()'s code block will be affected by the while(). You need to indent. The reason you're getting an infinite loop is because your delay isn't under the while(). Also, you never stop meditating. |
Ahhh ok! I definitely understand now. Thanks for the clarification, as I said I'm new to this but hopefully I'll catch on quick :). I used
Meditate() |
Nice one. Infinite loop.
Be sure to have a filter for this in atom/moveable() (or, wherever you want really) if(meditating) |
This is one of your most basic looping statements, I'd say.
When you do this, it will keep repeating the code for as long as the condition is met. Of course, this means code after it will not be run until the loop breaks.