[RMMV] SCRIPT CALL FOR WAIT?
Posts
Pages:
1
gameinterpreter doesn't work... so how do you execute a wait in a script command?
Thanks to whoever answers this, don't feel like planting another branch tree!
Thanks to whoever answers this, don't feel like planting another branch tree!
Well, in VX Ace, the precise code for the Wait command looks like...
...that, where "duration" is how many frames you want to "wait" for. I imagine MV isn't all that different in that regard, so it could be a matter of figuring out how to use this code. Which might be half the battle. I know, for my own part, I've tried reading the burb about the Fiber class in the help file. However, I just cannot understand what it's trying to tell me ;_;
class Game_Interpreter #-------------------------------------------------------------------------- # * Wait #-------------------------------------------------------------------------- def wait(duration) duration.times { Fiber.yield } end end
...that, where "duration" is how many frames you want to "wait" for. I imagine MV isn't all that different in that regard, so it could be a matter of figuring out how to use this code. Which might be half the battle. I know, for my own part, I've tried reading the burb about the Fiber class in the help file. However, I just cannot understand what it's trying to tell me ;_;
MV does it slightly differently. The wait command simply sets a _waitCount property, and in the update function if _waitCount is greater than 0 the interpreter breaks out of its infinite while loop (meaning the interpreter will stop running for the duration of the wait).
If you want to execute a wait using a script command, it's pretty much a simple matter of setting the _waitCount property of the map/troop interpreter to the number of frames you want the wait to last for. (the interpreter actually has a function called wait, which takes duration as a parameter, which does exactly this).
As an aside, Marrend, quick explanation on Fiber: it's sort of like a thread but it's not *true* concurrency. A Fiber is a block of code that you can pause and resume at will. It will not run until the first time it's resumed, and each time you resume it, it will simply continue where it left off when you last yielded. Fiber.yield causes the Fiber to yield control to the code that resumed it.
If you want to execute a wait using a script command, it's pretty much a simple matter of setting the _waitCount property of the map/troop interpreter to the number of frames you want the wait to last for. (the interpreter actually has a function called wait, which takes duration as a parameter, which does exactly this).
As an aside, Marrend, quick explanation on Fiber: it's sort of like a thread but it's not *true* concurrency. A Fiber is a block of code that you can pause and resume at will. It will not run until the first time it's resumed, and each time you resume it, it will simply continue where it left off when you last yielded. Fiber.yield causes the Fiber to yield control to the code that resumed it.
Pages:
1















