RGSS(X) Script Disabler

Discussion in 'RGSSx Scripts In Development' started by FenixFyreX, Jul 23, 2014.

  1. FenixFyreX

    FenixFyreX Fire Deity Veteran

    Messages:
    434
    Likes Received:
    307
    Location:
    A Volcano Somewhere
    First Language:
    English
    Hi folks; a recent post made me think about the ability to disable scripts, and I bring to you today the method to do it:

    Pastebin - RGSS(X) Script Disabler

    Here's the code:

    #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××# Script Disabler v1.0.2# FenixFyreX# RPG Maker XP, VX, and VXAce#×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××# This script allows the user to disable scripts by id; more specifically, the # ScriptsToDisable array below includes scripts to disable at runtime that need# to be disabled so as to debug a project without actually deleting the script.## This script needs to be placed ABOVE ALL CUSTOM SCRIPTS to function; it does# not work if it isn't the VERY first custom script installed.#×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××# CONFIG#×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××# These are names of scripts (the left column in the script database) to# disable. This will ignore the Main script (you can't disable it).ScriptsToDisable = ["▼ Main Process"]#×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××# PLEASE DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING.#×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××# For The Curious Scripter - How It Works#×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××# RPG Maker's internals call eval() to execute the scripts in the database; thus# I've overriden it to ignore eval'ing the script should it's index be found in# the config below. It "undefines" my alias to eval when the Main script is # reached.#×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××$top_binding = bindingalias eval_disable_alot_of_scripts evaldef eval(code, *argv) if code.is_a?(String) && (script = $RGSS_SCRIPTS.find {|a| a[3] == code }) if code.include?("rgss_main { SceneManager.run }") eval("def eval(*argv); eval_disable_alot_of_scripts(*argv); end", $top_binding) $top_binding = nil else if ScriptsToDisable.include?(script[1]) code = "" end end end eval_disable_alot_of_scripts(code, *argv)end#×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××# END SCRIPT#×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
    It's still under construction, for three two reasons:

    1) I'm not sure about custom Main scripts, such as when people rewrite when and how rgss_main() is called; and

    2) suggestions! I want opinions and options to make this better, and into an actual releasable script.

    3) The index thing seems clunky; how could I make it better? Hmm...perhaps by name and/or by index?...

    I know for a fact it works in at least VX and Ace (I don't know if Scene_Gameover exists in XP; I don't have XP) versions of RGSS; It -should- work in XP; try it out. And please, comment!
     
    Last edited by a moderator: Jul 23, 2014
    #1
    Zeriab and Dr.Yami like this.
  2. estriole

    estriole Veteran Veteran

    Messages:
    1,030
    Likes Received:
    334
    First Language:
    indonesian
    for number 1 and 3... why not using script name instead of script content as marker what script to disable :D .

    (TDS script and my script do that approach... btw i don't mean to advertise my script... sorry if this offending you...

    just wanna share :D ...) (TDS use <Disabled_Scripts></Disabled_Scripts> to disable any scripts between those two script name... while i also use his method too with addition adding # in front of script name will disable it)

    for your reference...

    $RGSS_SCRIPTS[scriptindex][0] => some number... code size / number of character??? (still not clear)

    $RGSS_SCRIPTS[scriptindex][1] => is the script name

    $RGSS_SCRIPTS[scriptindex][2] => is the script in deflated version

    $RGSS_SCRIPTS[scriptindex][3] => is the script code

    in ACE:

    load_data("Data/Scripts.rvdata2")[scriptindex][0] => same number as $RGSS_SCRIPTS[scriptindex][1]

    load_data("Data/Scripts.rvdata2")[scriptindex][1] => is the script name

    load_data("Data/Scripts.rvdata2")[scriptindex][2] => is the script code in deflated version

    it doesn't have [scriptindex][3]...

    for VX and XP i think it's only different extension... VX(rvdata) XP(rxdata??? i forgot) but all have same structure if i'm not mistaken (open for clarification :D )

    btw utilizing eval is a brilliant idea. in TDS and mine we just rewrite $RGSS_SCRIPTS content before it's interpreted by the program.

    so if you put some code in index 2 to modify index 3 content. that changes will take effect. (it interpreted sequentially). but if we put some code in index 2 to modify index 1 content. it will not take effect.

    so using eval... might open a new path that previously can't be done.

    hope this help :D .
     
    Last edited by a moderator: Jul 23, 2014
    #2
    FenixFyreX likes this.
  3. FenixFyreX

    FenixFyreX Fire Deity Veteran

    Messages:
    434
    Likes Received:
    307
    Location:
    A Volcano Somewhere
    First Language:
    English
    Thanks, I think the script's name is definitely an alteration I will consider before releasing.

    Actually, it does! I've just tested it out, and $RGSS_SCRIPTS[0][3] returns the code I've pasted above! I'm not sure if you are using an older version of the RGSS30X.dll that eB! might've changed the behavior in, but in my copy of RPG Maker VXAce, I can definitely access the inflated script data with $RGSS_SCRIPTS[index][3]. However, this is only in-game; on the hard drive, only 0, 1, and 2 exist.


    And yes, XP, VX, and Ace all share the same structure for their scripts, but are all different filetypes.


    Also, edit: I edited the script to search by name instead of id, and also fixed a nil alias of eval being called (stupid me rushing myself again).
     
    Last edited by a moderator: Jul 23, 2014
    #3
  4. estriole

    estriole Veteran Veteran

    Messages:
    1,030
    Likes Received:
    334
    First Language:
    indonesian
    no... what i mean...

    difference between

    $RGSS_SCRIPTS #<<<<< this one do have [scriptindex][3]

    and

    load_data("Data/Scripts.rvdata2")   #<<<<<< this one didn't have [scriptindex][3]

    "in case" you want to load the Scripts.rvdata2 instead of accessing RGSS_SCRIPTS variable.

    sorry if i'm not clear enough :D . :D .

    edit: in my script i use RGSS_SCRIPTS... but it's because i want to make sure no one alter the scripts

    (my scripts also serve as scripts protection from decrypter). since people can alter external files easily than

    variables that interpreted on runtime. (based on experiment by me and caitsith2)
     
    Last edited by a moderator: Jul 23, 2014
    #4
  5. Napoleon

    Napoleon Veteran Veteran

    Messages:
    869
    Likes Received:
    96
    First Language:
    Dutch
    You do know that there are already scripts that do that for Ace right? Including ones that even check for dependency scripts.

    And if you only one to disable 1 script and don't care about dependencies than ctrl+a and ctrl+q is just way faster. You want at least 'range-disabling' or dependency checks. Because I disable script A, then I crash and I have to disable script B (dependency), repeat that 12 more times or so... No fun.
     
    Last edited by a moderator: Jul 24, 2014
    #5
  6. FenixFyreX

    FenixFyreX Fire Deity Veteran

    Messages:
    434
    Likes Received:
    307
    Location:
    A Volcano Somewhere
    First Language:
    English
    @estriole - Ah, I see what you mean now. Yes, when using load_data() the 3rd index is nil; i think a simple set to Zlib::Inflate.inflate($RGSS_SCRIPTS[index][2]) would work?


    @Napoleon:


    Yes, there are other scripts that do this, and actually I didn't know about them! However, (nearly) all of them alter $RGSS_SCRIPTS; what if a script were to utilize it's functionality in some way, especially on disabled scripts? Mine simply reroutes the execution, it doesn't change the default data at all. I intended this scriptlet to be as non-intrusive as possible.


    As for the dependency thing; that is why it is prudent to not add 30 scripts into your project when you only need 5-10; I feel like it should be a developer's job to account for what scripts are installed, and by extension which ones are required by other scripts; it shouldn't be a feature for my script to automatically do that for them; that is just sweeping a problem under a rug, so to speak. If a developer can't honestly remember what scripts are necessary for another to run, I would encourage a text file or something to help manage them. It is their job to develop and manage their project (which includes their scripts); it is only my scriptlet's job to help :)


    I do agree that Ctrl + Q is quicker (technically it is 4 strokes, whereas mine is three, but the third is typing, so..), but I feel like this scriptlet is more efficient in terms of debugging, for the sole reason that you can just comment or delete this scriptlet out when you are ready to release the game.


    Besides, there is no one way to check for dependencies (I do not recognize $imported as a valid option simply because not all programmers use it). I do appreciate the feedback though, and will definitely take into consideration everything you've pointed out.
     
    Last edited by a moderator: Jul 24, 2014
    #6
  7. Napoleon

    Napoleon Veteran Veteran

    Messages:
    869
    Likes Received:
    96
    First Language:
    Dutch
    Don't get me wrong, I love free scripts. I was just pointing out that there were several in existence as it seemed you didn't know about them.

    Oh I see your script serves a slightly different purpose. The other scripts simply remove it from the entire execution by deleting them from $RGSS_SCRIPTS (which is not really used anywhere else anyway normally). You just prevent the scripts from being eval-ed but maintain the $RGSS_SCRIPTS variable instead. There is a difference yes but the difference is as good as 0 for most people I assume. Why would you need the $RGSS_SCRIPTS contents if you never plan on eval-ing them anyway?

    I don't believe it is correct to assume people to not use more than ~10 scripts. I have over 140 scripts in my project. Mainly because it's not a standard jrpg project and RPG Maker simply had pretty 0 of the features that I required (I still chose to use this engine out of budget considerations). And yes I need them all, every single one of them (custom pet system, new combat system, custom overworld system, custom lighting system, custom dating system, complete custom menu system, etc.).

    And it's not just a matter of accounting your scripts. Sometimes I need to disable a script for debugging purposes. Like I had to test an alpha lighting script but my minimap script and a few others caused it to crash. So I had to disable/enable those temporarily, and preferably really fast. There are also other cases where it may be necessary so it's not always "sweeping under a rug", sometimes it's a necessity.

    There are ways to check for dependencies without the $imported but they require a one-time configuration.

    There are some other things that can be debated but forget about it but whatever. A free script is always good and perhaps yours is more stable, easier to use, faster, or makes less of an impact on the system or you come up with something that the other scripters didn't think of. :)
     
    #7
  8. Tsukihime

    Tsukihime Veteran Veteran

    Messages:
    8,230
    Likes Received:
    3,071
    Location:
    Toronto
    First Language:
    English
    Last edited by a moderator: Jul 24, 2014
    #8
  9. estriole

    estriole Veteran Veteran

    Messages:
    1,030
    Likes Received:
    334
    First Language:
    indonesian
    some idea. how about expanding this to:

    1) not eval some of the scripts in $RGSS_SCRIPTS

    2) in game some script call to reeval the scripts that not evaled earlier.

    it could be nice to debug.

    especially if you create some Scene_ScriptDebug

    where we can enter script name that we want to reeval

    ex:

    enter script name to eval:

    #yanfly ace battle engine

    >>>>> evaling <<<<<

    like that.

    but it might need some object reinitialization scripts like the one written by Zalerinian but affect the current object instead of savefile.

    to avoid error when evaling code with Game_Actor modification for example.

    viable?
     
    #9
    FenixFyreX likes this.
  10. Tsukihime

    Tsukihime Veteran Veteran

    Messages:
    8,230
    Likes Received:
    3,071
    Location:
    Toronto
    First Language:
    English
    Last edited by a moderator: Jul 26, 2014
    #10

Share This Page