Error message in Window Selectable script

I have started a new play test and on the very first battle I get this error message:

Script 'Window_Selectable' line 61: ZeroDivisionError occurred

divided by 0

I don't get this if I select a save file from an old play test.  And, btw, if anyone has seen another thread I started about an error in battle, that is for a different project, and so is unrelated to this one.

Any ideas/suggestions please?  I'm a scripting idiot, so have no idea where to start.

Thanks
What scripts are you using in your project? 
Here's a screenshot of the scripts list.  The only ones that won't fit onto one screen are Shaz's mouse system and event extract scripts.

Spoiler
">http://s1323.photobucket.com/user/ksjp17/media/scriptsinuse_zps669fe448.png.html'>
scriptsinuse_zps669fe448.png
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


Once again, start with a new project, add the scripts one at a time, until the error occurs. The last script added is the culprit. You really should try that before asking for help on the forum, especially if you have a lot of scripts in your project.


In fact, a search might be helpful to you as well, because I recall someone else reporting a very similar error (it has to do with number of columns being set to 0 instead of 1), and I think it was one of Yanfly's scripts that caused the issue. However, it COULD be one of Yanfly's scripts in connection with another script.
Unfortunately no new scripts have been added between the last time I began a new game play test and this time, except Tsukihime's skill swap script, which has already been deleted for other reasons.  So it's not easy to see which script is going to be the culprit.

I have also searched for previous threads about this error, and they suggest searching for all instances of col_max to find the one which is 0.  I have done that, and there are no instances where it is 0.
Add Mithran's Graphical Object Global Reference to your project (even though it's not a graphical object that's causing the crash, this script will help identify what is).


Turn on the console and play until your game crashes. When that happens, the console will have the error that caused the crash and tell you the class and line, but it will also have details about what called that, what called that, and so on. This should lead you to a Window_* or Scene_* class which will help narrow down the script causing the issue.
I did as you suggested.  The game console doesn't give any information when the game crashes.  However, something else is now apparent - perhaps the script you suggested slows things down enough for me to notice.

When the battle begins instead of getting the battle transition graphic I'm getting a pre-title Splash Screen.  On a new play through this then goes to the error message.  On a save file for an existing play through, it goes to a splash screen but still manages to move on to the battle screen itself without crashing.

I haven't touched the battle transition part of the game, ever.  I am using the default graphic and, in fact, have never even looked to see where to change it. 
start searching from another side:

Loading a save file also loads part of the scripts and data from a previous project version - that's why it's usually neccessary to make a new game after you have changed scripts or other data.

In your case, some of the changes done after you made that save file are wrong, causing that error - while the load of the old data without those changes let's play the game through the problem.

Try to remember what you did after the last save - that is where the error comes from. And that is not neccessarily the area where you might believe it is, because a missing close to a function (for example) might send the engine into the wrong functional area, and you get a false error report.

Try using this to find the source of your problem:

http://himeworks.wordpress.com/2013/06/09/custom-main-full-error-backtrace/
Here is what the console shows.  I must admit, it all means nothing to me.

">http://s1323.photobucket.com/user/ksjp17/media/Errormessage_zpse877d465.png.html'>
Errormessage_zpse877d465.png
The output lists the stack flow where the engine had been working before the error happened.

It looks like it had something to do with Tsukihime's Mapshot-script, and I remember reading somewhere that the battleback will be created based on the tiles of a map in a few special cases, if the developer doesn't specify a different battleback.

Check the map properties where the battle takes place, and set a specific battleback for that map.

If that solves the error, then there is a problem either with the tileset of that map or Tsukihime's Mapshot-Script.
All maps have their own battlebacks, and these have not been changed since the very first play through.  I have double checked, just to be sure, and that map does have a battleback.  Seeing the console message, I tried deleting Tsukihime's script to see if that would help, but it didn't make any difference except to eliminate the last line of the console info.
Ok, then Tsukihime probably used an additional iteration level to get the controls for the mapshot into the game - that would explain why there is a "main" below her script, but it also means that the backtracer doesn't list the real cause of the problem in the last line (as usual).

Still, the problem has to be caused by one of the scripts in the backtracer's list - so that at least reduces the number of scripts to check.

I think you'll have to check those half dozen scripts for compatibility issues...
The problem here is that there is a zero division error in `row_max` when performing an operation using the return value of the col_max method. The method looks like

 def row_max [(item_max + col_max - 1) / col_max, 1].maxendSo if a child class overwrote col_max, it wouldn't appear in the stacktrace.My understanding of the stack trace is that all of the calling methods are pushed onto the stack, and popped off when it returns, so in the case of the row_max method, you have something like

call row_max (push onto stack)call col_max (push onto stack)col_max returns (pop from stack)evaluate row_max using return value (throws exception)So you would never see col_max on the stack cause it was already popped.I don't know if there is a way to actually keep track of any popped methods.

The first thing I would do is

1. In script editor, hit ctrl + shift + F

2. Search for "def col_max" no quotes

And list any custom scripts from the results.
There are only 5 scripts with def col_max.  They are

Yanfly: Battle Engine

            Party System

            Ace Save Engine

Todd's Difficulty Select

Modern Algebra's Quest Journal.

The first 4 I also used in my first project (the one with the problem is my second) and there was never a compatability issue there.

The Quest Journal has been installed since the very beginning, so right from the first play through.  I would have thought that if there was a compatability problem with that, it would have shown up a long time ago.  This is maybe the 5th playthrough from scratch that I've started.
The quest journal needs to be programmed to show the quests - it might be that you made an error when writing that code, causing the script to malfunction.

No matter what, I think you should test

1) if the problem disappears if you remove one of those scripts

2) if any of those scripts has been modified from the original (in case of the quest journal, look for differences outside the quest list)
Bit of a disaster for me, really.  The problem only went away when I deleted Yanfly's Battle Engine - and of course all the other battle scripts depend upon it.  having deleted it, the game successfully moved into battle, but straight to the message that I was victorious, no actual battle.

There are only 2 instances of def col_max in that script.  They are:

line 1773  def col_max; return $game_party.max_battle_members; end

line 2103  def col_max; return item_max; end

At no time have I modified this script.  It is well beyond my competence to even think of doing so.  It was inserted at the very beginning, when I was doing preparatory work, and hasn't been touched since.
I was going to say the first custom script in that list is Yanfly's battle engine on line 2094. That's where I would have started looking for the issue, and then gone forwards/backwards from that.


That last line you've quoted looks interesting. If there are NO items to display, then col_max will be 0. Are you sure there's something to list in that window?
line 1773  def col_max; return $game_party.max_battle_members; end
line 2103  def col_max; return item_max; end
You don't need to modify a script directly to cause the problem, it would also happen if another script rewrites a specific method.

Now you have to follow the parts you found to see where the zero comes from - based on the lines you found, it could either be

"max_battle_members" in "Game_party" or

"item_max"

Check those two occurences in the same way you checked for col_max, until you can either say that the result can never be zero or until you have found the part where the return is made zero. If those searches get you to other functions that only redirect them, then search for those other cases until you found the functions or methods where the result is calculated or set.
In  the debug project, Yanfly's Battle Engine is the only script I've inserted.  To make sure that I hadn't inadvertently changed something I downloaded a fresh copy from Yanfly's own site.  Still getting the same error message, which doesn't make any sense to me. 

I have made no changes to the default scripts in this project - I normally do things like change font colours, stuff like that - but I have left those alone to make sure I'm not doing anything which causes the problem.  I can see no logical reason why this error crops up now after I don't know how many hours of play testing over the months.

EDIT

I've cured the problem, though I don't know how.  Because this error made no sense I deleted the script entirely to see what would happen.  The game switched to battle, but still immediately went to the victory screen, instead of going into the default battle system.  I therefore wondered if an error had crept in to the opening troop of the game.  I couldn't see a problem, but I deleted it anyway and remade it - and the error message went away.  I do not know what the troop error was, because I have played that troop hundreds of times in test plays, and I didn't think to take a screen shot of it first before changing it.

Anyway, thanks to everyone who took the time and trouble to help me.  This was much appreciated and was the only thing which kept my stress levels about this problem manageable.
You probably never tested that specific case for months until now. That is how bugs work.


If this is related to enemy selection window, maybe you should check if it is a specific troop setup that's causing the bug to occur.

Original thread: https://forums.rpgmakerweb.com/threads/error-message-in-window-selectable-script.18735/