[RM2K] [SCRIPTING] WHAT CAUSES AN EVENT SCRIPT IN PROGRESS TO CANCEL AND CHANGE PAGES?
Posts
Pages:
1
I've seen an event where the page 1 script is contained in an infinite LOOP with no BREAK anywhere. But when the conditions for page 2 are fulfilled, the event switches to page 2 and the infinite loop aborts.
I've also seen an event with 2 pages that ends like this:
Change switch ON
Set Screen Tone (R: 0, G: 0, B: 0, S:100,) 5 sec (W)
Teleport:
That change switch command changes the active page of the event containing this script, which I'd expect to mean it should abort it, and yet the teleport still fires successfully.
Does anyone know what the rule is about changing pages causing currently-running scripts to abort?
I've also seen an event with 2 pages that ends like this:
Change switch ON
Set Screen Tone (R: 0, G: 0, B: 0, S:100,) 5 sec (W)
Teleport:
That change switch command changes the active page of the event containing this script, which I'd expect to mean it should abort it, and yet the teleport still fires successfully.
Does anyone know what the rule is about changing pages causing currently-running scripts to abort?
as far as I know loop use condition meet if condition didn't meet then the loop will abort, about the page 2 that isn't loop which mean even you change the switch that change the page, the script will work until the end of event.
like
Page 1 Switch on
then run the script on page 1, since it loop it will ask again did Switch 1 on?
if still on the script will keep repeat
Page 2 Switch off
->Change switch ON
(there no condition that ask will script abort if condition page meet or not so the script will continue until the end, at end they didn't loop because switch has changed or condition didn't meet)
->Set screen tone
->Teleport
That's all I know.
like
Page 1 Switch on
then run the script on page 1, since it loop it will ask again did Switch 1 on?
if still on the script will keep repeat
Page 2 Switch off
->Change switch ON
(there no condition that ask will script abort if condition page meet or not so the script will continue until the end, at end they didn't loop because switch has changed or condition didn't meet)
->Set screen tone
->Teleport
That's all I know.
whatever the exact reason is, it means RM does the "should this event change pages?" check at both the end of an event page, and also at the end of a loop's body.
Perang: RM2K doesn't have any concept of "loop condition". There's only an infinite loop and a break loop command.
Yukinose: "Checking page conditions at the end of the loop body" is one thing I actually know for sure is not true, because in this particular script, the end of the loop body is never hit. All paths end in a GOTO that sends execution back up to the top of the loop. (Don't ask why; I have no idea.)
Yukinose: "Checking page conditions at the end of the loop body" is one thing I actually know for sure is not true, because in this particular script, the end of the loop body is never hit. All paths end in a GOTO that sends execution back up to the top of the loop. (Don't ask why; I have no idea.)
author=Mason_Wheeler
"Checking page conditions at the end of the loop body" is one thing I actually know for sure is not true, because in this particular script, the end of the loop body is never hit. All paths end in a GOTO that sends execution back up to the top of the loop. (Don't ask why; I have no idea.)
For reasons I can never seem to remember for more than a day, GOTO is preferable in rm2k(3) over the Loop command, so for whatever you're referencing it makes perfect sense that it used GOTO.
As for the actual topic, I've never looked into this question before, but it would make sense that "checking page conditions" occurs at the end of the page, loop, or the GOTO command. If you wanted to check, just throw in a message box or event move after a switch command to see what still triggers when.
First of all, I wouldn't use loops. There always seems to be something screwy with them. You can get the same results from
label 1
code you want to loop
wait 0, or above
jump to label 1
It gives you much more control. You can put in condition branches to break out of the loop or even jump to other loops by creating label 2, and putting a jump to label 2 in a branch.
(to break out of this loop)
label 1
code you want to loop
wait 0, or above
IF (switch0001 is ON)
\\jump to label 100
jump to label 1
label 100
However, why do you have a page 2 on an event where you want a loop to keep going on page 1? If the loop is meant to keep going, then it should be on it's own event and that page 2 on a different event. Only 1 page of an event can process at one time, and the page on the right will take priority. That seems like it's working as designed.
When you activate a switch to enable another page or event, the code will continue to process to the end, then not repeat. Which is why you can teleport after turning on the switch. I think after you teleport, if you go to another map, the event on the previous map that started the teleport will stop processing(not 100% sure on this). In that case you could do something like, use a common event so it doesn't matter which map you're on and where you teleport to.
I usually don't put anything after a teleport, then on the destination map create an autorun event to finish up whatever code needs to be there, then turn itself off when done(or do a call of a common event). But it all depends on the situation, how other events are set up, and whatever nuances comes up from the engine.
label 1
code you want to loop
wait 0, or above
jump to label 1
It gives you much more control. You can put in condition branches to break out of the loop or even jump to other loops by creating label 2, and putting a jump to label 2 in a branch.
(to break out of this loop)
label 1
code you want to loop
wait 0, or above
IF (switch0001 is ON)
\\jump to label 100
jump to label 1
label 100
However, why do you have a page 2 on an event where you want a loop to keep going on page 1? If the loop is meant to keep going, then it should be on it's own event and that page 2 on a different event. Only 1 page of an event can process at one time, and the page on the right will take priority. That seems like it's working as designed.
When you activate a switch to enable another page or event, the code will continue to process to the end, then not repeat. Which is why you can teleport after turning on the switch. I think after you teleport, if you go to another map, the event on the previous map that started the teleport will stop processing(not 100% sure on this). In that case you could do something like, use a common event so it doesn't matter which map you're on and where you teleport to.
I usually don't put anything after a teleport, then on the destination map create an autorun event to finish up whatever code needs to be there, then turn itself off when done(or do a call of a common event). But it all depends on the situation, how other events are set up, and whatever nuances comes up from the engine.
author=Link_2112
However, why do you have a page 2 on an event where you want a loop to keep going on page 1? If the loop is meant to keep going, then it should be on it's own event and that page 2 on a different event. Only 1 page of an event can process at one time, and the page on the right will take priority. That seems like it's working as designed.
I don't. It's not my script. I'm trying to build a game engine that can clone the functionality of RPG Maker, and I'm testing it on an existing game. The infinite loop broke things, because the script never ended, so I added some code to check for page changes. But that change broke the "set switch before teleport" case on a different map. I'm trying to figure out what the exact semantics are so I can recreate them properly.
Oh, yeah, you won't get many answers here. There's maybe 3 people I can think of that could help you. Kazesui, Wolfcoder and Cherry. I think Pepsi_Otaku knows a bit from his work with dynRPG, but very few people know how the engine works deep inside. Maybe a few other users who I've seen discussing the nitty gritty of the engine. Others who are making engines that run RM games. OpenRPG I think is one.
I would recommend that you explain your goal when asking these kinds of questions, to avoid getting unhelpful responses. I wouldn't have bothered to reply since I don't know why code works the way it does. Just how to work with it so it doesn't break, heh.
I would recommend that you explain your goal when asking these kinds of questions, to avoid getting unhelpful responses. I wouldn't have bothered to reply since I don't know why code works the way it does. Just how to work with it so it doesn't break, heh.
That's an interesting project. Is there a reason you're not examining VXA's or MV's codebase? Perhaps they'd give insight into how RM parses through the event commands on an event page.
I'm certainly ignorant of how they exactly work. For my own game, I've primarily just been working with modifying Scene_Map.
I'm certainly ignorant of how they exactly work. For my own game, I've primarily just been working with modifying Scene_Map.
author=Yukinose
That's an interesting project. Is there a reason you're not examining VXA's or MV's codebase? Perhaps they'd give insight into how RM parses through the event commands on an event page.
That's a good idea. I'll have a look.
author=Yukinose
That's an interesting project. Is there a reason you're not examining VXA's or MV's codebase? Perhaps they'd give insight into how RM parses through the event commands on an event page.
I see the same behavior in VX Ace, but I don't see any good explanation for why it works the way it does. There's nothing special in the looping code that would account for it.
I think I'll re-ask with a VXAce tag and see if any of the Ruby gurus around here can help.
Pages:
1















