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.
Nil fix snippet

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 69
Nil Fix Snippet

Here's a small thing I wanted to share, which I've come to realize when playing around and trying out few scripts and fooling around in the editor. In many cases, a no method error is caused by Nilclass error due to the fact that the script is calling for Nil class instead of Empty Class, which may cause a nomethod error as there's not a defined NilClass. This snippet should remove many incompatibility errors and crashes due to Nilclass not having an empty method. On few test runs, it's had good results so I thought I'd share it. I've not had any extensive testings but it should be plug&play.

Screenshots

Not applicable

How to Use
For optimal performance, put this bellow all other scripts you may have and above main process.

Demo

Not really needed...

Script

Code: [Select]
class NilClass
    def empty?
        true
    end
end

FAQ
Post question and answers to common question here in the following format:

Q: Can I use this in comercial project?
A: You can use it in anything, it's more of a snippet than script so...
Q: Will this work in *insert another rpgmaker or engine here*?
A: I only have acess to RPGMaker Ace so I can't say for sure.

Credit and Thanks
No need to credit me or anything, free to use and all that goodness.

Thank you Jesus from the beginning

***
Rep:
Level 77
RMRK Junior
Hopefully this will fix the bug in Yanfly's Adjust Limits script where setting an individual actor's max level above 98 causes a crash...

***
Rep:
Level 69
You can try. I'd like to hear a report from if it does, it's at least fixe one script's functionality so far. From what I tried, it did fix Yanfly System Options randomly crashing as well with this title script.  :blizj:

http://www.rpgmakervxace.net/topic/825-title-screen-aqua/


*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
I'm surprised that hasn't caused you a wide range of issues.

NilClass means that something is either missing or not initialised.
If you're simply neutralising the error message like this, I'd imagine that would cause Undefined Behaviour.
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 69
I'm surprised that hasn't caused you a wide range of issues.

NilClass means that something is either missing or not initialised.
If you're simply neutralising the error message like this, I'd imagine that would cause Undefined Behaviour.

On the contrary, without this one script I was using did not work at all. Even when loading properly it would cause problems in other places. After the snippet, everything works as they should.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Well, it will "work" in cases where a script checks if x is empty when there is a possibility that x is nil, when x is not operated on if empty? is true, and when the script still functions whether x is nil or not. However, for many scripts on which this could potentially operate, those conditions won't be satisfied, and this "fix" won't simply hide error messages, it will prevent code from running that has to run in order for the script to function. In the result, the script will behave unexpectedly without telling you why, and that's really, really bad. To be sure, the project would crash without this "fix", but with this "fix" any scripter who is looking to diagnose the errors in his or her logic will be at a serious disadvantage.

As a scripter, I would never want something that suppresses error messages, since error messages disclose failures in my logic that should be corrected, not ignored. In other words, error messages disclose errors, but they aren't themselves errors, and they don't need to be "fixed".

That said, I can understand why some non-scripters might want something like this for situations where the logical error is otherwise harmless, but I will caution that if you ever encounter any errors or lack of function in any other script you use, delete this "fix" before asking a scripter for help. In general, I think you're better off to ask for help with a script that's throwing errors, and not to just put this code in and hope it's a situation where the actual error in the script is otherwise harmless.

Still, thank you for sharing.
« Last Edit: September 16, 2012, 09:33:56 PM by modern algebra »

***
Rep:
Level 77
RMRK Junior
Example: Adjust Limits is broken with regards to actor levels. Use even one note tag and the game won't even start.

***
Rep:
Level 69
Well, it will "work" in cases where a script checks if x is empty when there is a possibility that x is nil, when x is not operated on if empty? is true, and when the script still functions whether x is nil or not. However, for many scripts on which this could potentially operate, those conditions won't be satisfied, and this "fix" won't simply hide error messages, it will prevent code from running that has to run in order for the script to function. In the result, the script will behave unexpectedly without telling you why, and that's really, really bad. To be sure, the project would crash without this "fix", but with this "fix" any scripter who is looking to diagnose the errors in his or her logic will be at a serious disadvantage.

As a scripter, I would never want something that suppresses error messages, since error messages disclose failures in my logic that should be corrected, not ignored. In other words, error messages disclose errors, but they aren't themselves errors, and they don't need to be "fixed".

The scripter had abandoned the said script and it's no longer supported, the last update was in January. There's not anything wrong in the script per say but it is causing this bug for some reason. With the snippet, the script now functions and one can enjoy it without the errors its causing. :o
« Last Edit: September 16, 2012, 11:35:40 PM by Drbigt »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Regardless, a specific solution for that script is better than a general solution which makes errors in other scripts hard to detect. It would be better just to post a topic in Scripts asking for help with the specific script.

If you are getting a NoMethodError, it is because you do not know what class of object you are operating on (in this case). Defining the missing methods in the classes you do not want to be operating on is not a viable or rational fix. As an analogy, let's say you want to call Mark but select the wrong contact and call Mary instead. The best way to fix this problem would be to hang up and call Mark, but what this script does is rename Mary to Mark in your Contacts List; you are still talking to Mary and not Mark. Sometimes this might not cause a problem (for instance, if you were calling Mark for IT help and Mary is also an IT person), but in the majority of cases, Mary is not a useful substitute for Mark and it is better not to be calling Mary when you want to be calling Mark.
« Last Edit: September 17, 2012, 12:04:07 AM by modern algebra »

***
Rep:
Level 69
But what about the script that's not working without this? Should I just remove it?  ???

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
No, you should post a topic in Scripts identifying the script and asking for help. It's more likely an incompatibility than a straight error, so it might help if you also recreate the error in a new project and upload it.