RMVXA - stack level too deep (com. events)

0 Members and 1 Guest are viewing this topic.

*
Rep: +0/-0Level 20
Chasing the Dreams
Hello there.

First of all, I'm from Poland, so sorry for my language mistakes in advance. ;)

I have a problem with this error message about "Stack level too deep". Before I decided to ask here, I tried to fix my problem by myself. But I didn't succeed. Then, I looked through the whole Internet to check if there is any solution for my problem. But there's not.

Generally, as I read, the majority of the errors with too deep stack level is caused by the scripts (one duplicated or two not compatible with each other). But in that cases, the error appears after clicking "Playtest" (at the beginning). I can playtest my game without any trouble, however, I created a kind of system which includes a smartphone in my game.

Let me show you, how it works - will be easier to see it instead of trying to describe:
https://youtu.be/Rhpx3H0dum0

And then, I can "click" (switch between apps - it's this characteristic "tap" sound) using arrow keys exactly 85 times before the error appears.

I'll explain how I made this whole system. It is based on Common Events and pictures. Please take a look on that screenshot:


Each highlighted (chosen) application on the smartphone screen is a different common event (as you can see - com. events 199-207 on my screenshot). When you press a specific arrow key (eg. down), it loads new picture with proper application highlighted. If you are on "Flashlight" app highlighted (top middle, with a bulb icon) and press right arrow key, the picture with lightbulb highlighted will be cleared and new picture (with "Calendar" icon chosen) will be loaded. Then, the player can see it as switching between the apps.
Additionally, I use "Stop All Movement" script by Yanfly to prevent main character from moving when the smartphone is being used.

I'm really sorry for such long explanation, but I did my best to explain my problem as clear as possible for best help results. ;)
I have no idea in which point the stack is being overflowed, because I tried to protect from it using "Break loop", "Jump to label: END" and all this stuff (I consider I'm just stupid and I don't know how to use it correctly). After 85 clicks the error appears, but when I quit using smartphone after eg. 70 clicks and start it again, I can click another 85 times (so the stack is being cleared)...

You are the most experienced guys, I hope you can see something I missed. Probably the solution is quite easy, but I need your assistance... Thanks! :)
« Last Edit: May 19, 2016, 06:30:38 PM by Credt »

*
Rep: +0/-0Level 20
Chasing the Dreams
Hey, I did it!

I understood what was happening all the time and where I overflowed the stack. When using 9 different common events, I looped the whole engine almost infinitely. Then, the game could handle no more than 85 loops before exceeding the limit. Like this:

When button "UP" is pressed - do something - event #1 is running.
    Then, when button "DOWN" is pressed - do something else - events #2 and #1 are running.
        Then, when button "UP" is pressed - do something else again - events #3, #2 and #1 are running.
            [...]
                Then, when button "LEFT" is pressed - do something - events #85, #84, [...], #2 and #1 are running - stack overflowed!


The whole program had no chance to stop, because all common events were still running on the stack.


To fix it, I've made only one common event called "Telephone". Inside, I created 9 different loops, each named by Label (1 to 9). Then, when some button is pressed, the program jumps to the proper label (instead of loading another event) and waits for the next instruction inside a loop. Again, after pressing another button, it just jumps to another label, still inside just one common event, and waits again. After making a choice (eg. if the player would like to turn on a Flashlight app), the whole common event "Telephone" ends with "Exit Event Processing" and that's it!

I tested it by clicking over 200 times and it worked without any errors.
I posted my solution for the future - maybe someone will face a similar problem one day. ;)

*
The Hero of Rhyme
Rep:
Level 82
( ͡° ͜ʖ ͡°)
2014 Best RPG Maker User - StoryProject of the Year 20142014 Queen of RMRK2011 Best Newbie2014 Best RPG Maker User - Creativity2014 Kindest Member2013 Queen of RMRKBronze SS AuthorBronze Writing ReviewerSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.GOOD!For frequently finding and reporting spam and spam bots2012 Best Yuyubabe Smiley2012 Best RPG Maker User (Creativity);o
Woo! I'm glad you got it fixed! ^_^ And thanks for sharing your solution! :)
Spoiler for My Games and Art:
ℒℴѵℯ❤


My Artwork Thread

The Lhuvia Tales [Current]

Ambassador [Complete]

The Postman [Complete]

The Wyvern [Complete]

Phoenix Wright: Haunted Turnabout [Complete]

Major Arcana [Cancelled]