RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Script Troubleshooting for the Non-Scripter

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2011 Favourite Staff Member2011 Best Veteran2011 Most Mature Member2010 Best Use Of Avatar And Signature Space2010 Most Mature Member
Script Troubleshooting Tutorial for the Non-Scripter


Apologia

Most errors that people see from released scripts are not major and can easily be fixed, even by the non-scripter. The purpose of this tutorial is to teach some very basic strategies on diagnosing and fixing common errors without any particularized scripting knowledge. It does not aim to teach you how to script, but simply goes through a few of the most common errors you are likely to encounter when using custom scripts and what can be done about them by yourself, before asking the scripter. In the main part of this tutorial, I will go through some common error messages, what they might mean, and how to fix them. I will not be explaining why these errors occur or why these tips fix them since that requires some knowledge of scripting, and this tutorial is aimed at the non-scripter. If you would like to know, feel free to ask me in this topic and I will explain to the best of my knowledge.


Caution

Most of the tips in this tutorial do not require you to do any substantial editing to your script, since if that is required, your best strategy is to go to a scripter. However, if you do try to edit a script, do not do so in your main project. It is a lot safer to make a test project and do any editing there, as even small errors on your part may become quite a headache and it's better to be safe. Again, there is nothing in this tutorial that would require you to do any major editing, this caution is mostly just in case you get creative. Don't get creative.


General

Remember: the first thing to do when encountering any error is to go to the topic where the author published the script and see if anyone else has had the same problem and if the error has been addressed. The easiest fix is the one you don't have to do. Secondly, if this tutorial does help you to fix the error, then you should still alert the author of the script to the error. It is a simple courtesy and one which you should always undertake, as scripters want their scripts to be bug-free.

Also, some common errors, such as the bug where you can't set a variable to the stats of an actor, are bugs in the default scripts and not the result of any custom script. A good set of fixes for these can be found in Yanfly's Core Fixes and Upgrades. Check those out and see if the bug you are getting is resolved by one of those scripts.


Common Errors

  • Unable to find file
    Quote from: Error Message
    Unable to find file Graphics/Directory/Filename.
    Spoiler for Troubleshooting Tip:
    As you might already appreciate, this is probably not a problem with the script. It doesn't even have to be related to the script. Maybe you deleted a character face that you use in a message. However, when this error is related to a script, it probably means that you forgot to download necessary files, or placed them in the wrong folder, or named them incorrectly. Go to the website where you found the script and make sure you have all the necessary files. If it still isn't working, re-read the instructions to make sure you've done everything that you're supposed to have done. If so, go into the script and look for a configurable section. It may have a part where you set which graphic to use in a particular situation; make sure it refers to an existing graphic and isn't misspelled or anything. If none of that works, then it may be the very rare scenario where the scripter made a mistake in his/her code or failed to include necessary instructions. Alert the scripter to the error.

  • SystemStackError
    Quote from: Error Message
    Script 'Slot Name' line x:SystemStackError occured.

    stack level too deep.
    Spoiler for Troubleshooting Tip:
    This is a recursion error. If it happens without having reset, then you probably can't do anything about it by yourself as it is a serious logic error or may be an incompatibility. Alert the scripter and ask them to fix it if the tips on resolving script incompatibilities don't work. If, however, it has happened anytime after you pressed F12 to reset the game, then the problem could be that the script aliases a hidden or inherited method, in which case it is easy to fix. Go into the script editor to the slot and line identified. Look to the name of the method that line is within (i.e. the closest "def whatever_name" line). Somewhere in that class, there should be a line which aliases that method and it will look like:
            alias whatever_alias whatever_name
    Some scripters will put that line right above the method they are redefining. Others will put it at the top of the class. Find it and change it to:
            alias whatever_alias whatever_name unless self.method_defined? (:whatever_alias)
    You may need to repeat the process for a number of methods. This is a good place to follow the directives of the caution. Also, just in case you don't realize this, "whatever_alias" and "whatever_name" could be anything - I use those labels simply for ease of reference. For instance, it could be:
            alias mit_lsu_name_1er4 name
    in which case to fix it, you would replace it with:
            alias mit_lsu_name_1er4 name unless self.method_defined? (:mit_lsu_name_1er4)

  • RGSSError
    Quote from: Error Message
    Script 'Slot Name' line x:RGSSError occured.

    failed to create bitmap.

    Spoiler for Troubleshooting Tip:
    When the slot name is 'Cache' and the line is 80, then as Mithran notes:
    Quote from: Mithran
    ... This problem is most likely caused by either an invalid or blank image file trying to be loaded, or another file with the same name as the image file trying to be loaded in the same directory that is not an image file your Title folder should hold only valid images and only one of each by any given name (Bitmap class will load the first file with the name, regardless of the extension)...

    In other words, find out which graphic was trying to be loaded and then go to the corresponding folder in Graphics (like System, Battlers, Characters, etc...). Make sure there is only one file in the folder by that name and make sure it is a valid image file.

    As GubiD notes, this error may also occur when a script tries to create a Bitmap with a width or height of less than 1. This is most likely a logic error on the part of the scripter and he or she will need to be alerted. However, if there is a configuration section that allows you to choose the width or height of something (like a window) then it could be a user error as well. Make sure that any time there are values like that, they are within appropriate parameters. (This may or may not be a problem depending on the script - I know for some of my scripts where I let the width or height of something be configurable, I will have a value of -1 be an indication to have the window's size be automatically sized depending on other factors, such as the size of other windows at the time or the resolution of the screen. So read the instructions, but that may be the problem.)

    Similarly, this error can occur if the width and height are too large, and that may occur where a script generates the size of a Bitmap depending on how many items are to be listed in the window. That can happen if you have, for instance, lots of different stacks of items in Scene_Item. Yanfly wrote a fix for that in her Core Fixes, though it is not a perfect fix as it will cut off the offending items in the list. As far as I know, there is no perfect general fix for it, but a scripter might be able to whip something up for you by, for instance, swapping bitmaps. The other thing you could do is reduce the number of items that will appear in the list at any given time.

  • NoMethodError
    Quote from: Error Message
    Script 'Slot Name' line x: NoMethodError occured.

    undefined method 'method_name' for object
    Spoiler for Troubleshooting Tip:
    There are a number of possible reasons for this error, some of which would require a scripter to take a look. However, there are a couple situations where this can easily be fixed by you.
    • You're loading an old save file.
      A lot of scripts are designed to setup data upon initialization. For a lot of saved objects, such as actors, that initialization happens only once by default, when you first start the game. JUst start a new game and this error will go away if this is the problem. If it is absolutely crucial that you preserve this save file, then contact a scripter and if he/she is willing, then it is a simple matter to manually initialize the necessary data for that save file. Generally, if this is the case, then object will be nil.
    • The scripter misspelled a method name or changed a method's name without changing a line that refers to it.
      As silly as it sounds, this is not super uncommon, especially where it is not a critical element of the script and therefore wasn't tested properly. This is likely not the case if the object identified is nil. So look at the class that object belongs to. Object will look something like: #<Class_Name:0x2eeb330>. Ignore the latter stuff and just look at Class_Name. Find out which class that is, and then look for the method 'method_name' is intended to refer to. Keep in mind that it may be any number of other issues, so only act on this if it is obvious this is what happened. If you do find something similar and believe that misspelling is likely to be the issue, then return to the line that threw the error and replace the misspelled method name with the method name you found.
    • Script Incompatibility
      The most common reason for this error is incompatibility. See the section on them for details on how to resolve a problem like this.

  • Syntax Error
    Quote from: Error Message
    Script 'Slot Name' line x. SyntaxError occurred.
    Spoiler for Troubleshooting Tip:
    This error message will appear at the very start of the game before the title screen even loads up. If it occurs in-game and doesn't give a script name or line, then it is very likely a call script error and I encourage you to take a look at that. Anyway, it is very rare for one of these errors to be in a published script, since they are the easiest to find and fix, and any attempt to test it will identify the error. By and large, when this error occurs, it is one of three things: (1) the script was corrupted by BBCode when it was posted; (2) you copied the script incorrectly (left out a line or two, for instance); or (3) you made an error when configuring the script. So first, go to the place where you got the script and try recopying the script. If it has a demo, test the demo and see if it works there. Then, look for errors in your configuration if it has a configuration script. Things that you should particularly look out for are unclosed brackets and quotation marks. Another thing to look out for are hashes. When setting up a hash (which will typically be setup as:
          CONSTANT = {
            a
    => x,
            b
    => y,
            etc...
         
    }
    where a, b, x, y can be anything) it is easy to make a mistake. Things to look out for are that the middle part is => and not just =, and that there is a comma after each line (though not necessarily the last). Anyone of those will cause a syntax error. Luckily, the line it identifies should be near the line that causes the error, which is not always the case syntax errors involving unclosed branches. If you have ruled out any error on your part in copying or in configuration, then alert the author of the script and ask for his/her help.

  • Call Script Errors
    Spoiler for Troubleshooting Tip:
    Some scripts have options that allow you to use the Script event command to modify or track something about the script; maybe set a variable to a value or something. You follow the directions perfectly, but then you still get an error message popup. These error messages can take many forms, but one of the most common are Syntax errors and argument errors. The most common reason for this is that your command uses more than one line in the script call box. This is very easy to fix; all you need to do is set some of the objects to short local variables. Look for periods. As a general rule, you can split an expression at any point before a period. For instance, if you are asked to do something like:
            $game_variables[y] = $game_party.quests.quest (z).objectives.size
    That's mostly nonsense, but it illustrates my point. You can store any number of those objects in separate variables. For instance:
            a = $game_party.quests
            $game_variables[y] = a.quest (z).objectives.size

    or:
            a = $game_party.quests.quest (z)
            $game_variables[y] = a.objectives.size

    or:
            a = $game_party.quests.quest (z).objectives
            $game_variables[y] = a.size

    Anyway, I'm sure you get the idea by now. That is the most general way to split an expression so that it will fit on one line. You shouldn't put the whole of the first part of the equation (before the equal sign) into a local variable though as then you wouldn't be getting your desired result.

    There are other ways to fit an equation on one line as well. For instance, the expression above would also have worked just to split it at the = sign.
            $game_variables[y] =
            $game_party.quests.quest (z).objectives.size

    However, not every expression you'll want to split is of that form, whereas every expression that you want to evaluate will have parts that you can split up, so you should use that way unless you know better.


Script Incompatibilities

The most common reason for a script not to work properly is a conflict with another script. If none of the above tips resolve your error, then you should look into the possibility that it is a script incompatibility. The first thing to do is confirm whether it is a script incompatibility. To do this, make a new project and recreate the error-throwing situation. Then move the problem script into that project. If the error does not occur, then it is a script incompatibility. If it is, then you have to identify which other script is causing the problem. Move each of your other scripts into the clean project one by one until the error occurs. The last script you added is the conflicting script. Now that you know which scripts are problematic, try switching their order in the Script Editor. In other words, if Script X is above Script Y, move Script Y above Script X. Try running the project again and see if the error occurs. If it does then there's not much more you can do by yourself. However, your work in identifying the errors is not all for naught. Alert the authors of both scripts to the incompatibility and ask them for help. The fact that you have already identified the incompatible script and have a clean project with only the error situation in it means that they will probably be much more motivated to help you as half their job is done.



Closing Note

There are probably a bunch of other common and simple little errors I didn't think of when writing this tutorial. If you can think of any, then just bring them to my attention and if there is likely to be a simple fix then I will add it to this tutorial. Also, remember that even if your bug is fixed by following the tips in this tutorial, you should always report errors to the author of the script as a courtesy. Moreover, if your bug is not fixed by the tips in the tutorial, you should always ask the author of the script first and, if he/she refuses, then post a topic asking for help from other scripters.
« Last Edit: July 08, 2011, 05:39:19 PM by modern algebra »

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Great tutorial Modern! Not only does this let people fix errors on they're own, but it also gives them a bit of scripting knowledge.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2011 Favourite Staff Member2011 Best Veteran2011 Most Mature Member2010 Best Use Of Avatar And Signature Space2010 Most Mature Member
I'm glad you like it. I don't know how much scripting knowledge it gives anyone though :P

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Btw, script errors when using call scripts that are too long for the call script box are common errors with a relatively easy fix. Sounds like something you could add in?

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2011 Favourite Staff Member2011 Best Veteran2011 Most Mature Member2010 Best Use Of Avatar And Signature Space2010 Most Mature Member
yeah, that's a good idea.

*
Small Bat Dev
Rep:
Level 76
2012 Best Artistf*ck u >:(2011 Best Artist2010 Best NewbieParticipant - GIAW 11Bronze - GIAW 92011 Most Attractive Female MemberBronze - Game In A Week VII
Does this count as Necro-posting?

Very usefull, I'll have to look at it when I actually have the patience to.


***
Rep:
Level 75
What the...?
What if you get a SystemStackError in a default script?  Is it still okay to alias it as described here, MA?  This is definitely a necropost.  Sorry.  But just ran into a problem where this information could be useful today.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2011 Favourite Staff Member2011 Best Veteran2011 Most Mature Member2010 Best Use Of Avatar And Signature Space2010 Most Mature Member
Sorry for not responding to this earlier.

If you're getting a SystemStackError in a default script, the source of the error is likely in a custom script and it is either a very serious logical error or an incompatibility with another script. Isolate the problem script(s) following the normal guidelines for incompatibilities (add them all in one at a time) and alert the scripter(s) to the error. Failing that, recreate the error in a new project, upload and share it in a script help forum.

**
Rep: +0/-0Level 83
Man, what a day....
Hey, can you tell me if i get error somewhat like this:

Script (script_name) line x: NoMethodError occurred
undefined method 'update' for nil:NilClass
_______________________________________________

Please tell me how to fix it.
Thanks....

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
A lot of times when somebody gets that error, it is because they are using an old save that was made before they implemented the script into their game.

Try starting a new game and if it still gives you that error, then you might actually need help :)
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

*
Rep:
Level 82
It can be a hard problem to solve without seeing the script. It's easy for a scripter to identify the potential problem than it is for them to describe how to fix it in a general way. If loading a new game doesn't work, check if it is a script incompatibility.

If it isn't that, it would probably easier to just attach/upload the script (or even the project) and see if a scripter will take a look at it. I'm usually more than happy to do a little bit of debugging for a project.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
It can be a hard problem to solve without seeing the script. It's easy for a scripter to identify the potential problem than it is for them to describe how to fix it in a general way. If loading a new game doesn't work, check if it is a script incompatibility.

I can be very hard indeed. In fact it can be unsolvable hard. That's why you don't see a script which finds the error and tells you how to fix it. It is unfortunately provable impossible to create such a script.

What we can do when we just hear about an error is to think of similar problems and how they were fix. Maybe the fix is similar, maybe not.
This list is an excellent compilation by modern algebra of common problems and their typical causes.

*hugs*