Jump to content

Recommended Posts

Introduction

After finding the excellent Script Disabler (http://forums.rpgmakerweb.com/index.php?/topic/3687-script-disabler/) by TDS, I wrote my own version that handles my needs slightly better - as you can disable random single scripts a lot easier.

 

Simply place this script above all your own scripts (it can't interfere with anything accidentally), and then any scripts you want to disable simply put a # in front of the script name (you know - like a Ruby comment  ;) ).

 

The position for the script still exists, but the script content itself is blank - this means you can still debug other scripts properly, and it only needs a single character change to enable them again.

 

http://pastebin.com/bH3hLEMw

 

Screenshot

uOlPiaH.png?1

Share this post


Link to post
Share on other sites

I was confused at why this would be useful at all. But then I kept reading what it did, and it suddenly made a lot more sense! I don't think I'll be using it, but this is a good idea! A lot easier than cutting and pasting scripts from one project to another, just to debug scripts. Kudos! :)

Share this post


Link to post
Share on other sites

Nice. I've just gotten in the habit of putting an 'if true' at the beginning of the script and double ending it to turn scripts on and off. This seems to be a little more, elegant solution.

Share this post


Link to post
Share on other sites
9 hours ago, RedRose.190 said:

it would be nice if the script had an on/off switch... 

That would be dangerous and probably cause your game to crash.

Turning the script off when it was used to disable other scripts, may cause the disabled scripts to start running and then you could get an error since none of the data for the script was initialized.

Share this post


Link to post
Share on other sites
21 hours ago, roninator2 said:

That would be dangerous and probably cause your game to crash.

Turning the script off when it was used to disable other scripts, may cause the disabled scripts to start running and then you could get an error since none of the data for the script was initialized.

Wouldn't work anyway, at least not as the game is runnning. One thing about Ruby is that all Ruby actually sees is a list of commands. Scripts are just a list of commands that Ruby runs as the game loads. There isn't any way to 'unrun' a script. The thing this script does is interrupt Ruby before it runs scripts and runs them it's own way. If you want to turn things on and off in the middle of a game you basically need to do a temp save, spawn a new copy of the game process, and then load the temp save as the new process starts.

 

And yeah, the game could crash if none of the data for the script was initialized, but that will happen with saved games anyway unless the script is coded to prevent that. Personally I prefer to 'initialize' things using ||= rather then using the initialize method most of the time, as it both prevents crashes and allows me to initialize something only where I actually use it.

Edited by Kayzee

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted