Guest User

RGSS(X) Script Disabler - FenixFyreX

a guest
Jul 22nd, 2014
239
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  2. # Script Disabler v1.0.0
  3. # FenixFyreX
  4. # RPG Maker XP, VX, and VXAce
  5. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  6. # This script allows the user to disable scripts by id; more specifically, the
  7. # ScriptsToDisable array below includes scripts to disable at runtime that need
  8. # to be disabled so as to debug a project without actually deleting the script.
  9. #
  10. # This script needs to be placed ABOVE ALL CUSTOM SCRIPTS to function; it does
  11. # not work if it isn't the VERY first custom script installed.
  12. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  13. # CONFIG
  14. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  15. # These are ids, starting from 0, which are placed immediately AFTER the script
  16. # entry Scene_Gameover, so Scene_Gameover is -1, the one after is 0, and so on.
  17. # This will ignore the Main script (you can't disable it).
  18.  
  19. ScriptsToDisable = []
  20.  
  21. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  22. # PLEASE DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING.
  23. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  24. # For The Curious Scripter - How It Works
  25. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  26. # RPG Maker's internals call eval() to execute the scripts in the database; thus
  27. # I've overriden it to ignore eval'ing the script should it's index be found in
  28. # the config below. It "undefines" my alias to eval when the Main script is
  29. # reached.
  30. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  31.  
  32. GameOverIndex = $RGSS_SCRIPTS.index($RGSS_SCRIPTS.find {|a| a[1] == "Scene_GameOver" })
  33.  
  34. binding = self
  35. alias eval_disable_alot_of_scripts eval
  36. def eval(code, *argv)
  37.   if code.is_a?(String) && $RGSS_SCRIPTS.any? {|a| a[3] == code }
  38.     if code.include?("rgss_main { SceneManager.run }")
  39.       eval("def eval(*argv); eval_disable_alot_of_scripts(*argv); end", binding)
  40.     else
  41.       index = $RGSS_SCRIPTS.index($RGSS_SCRIPTS.find {|s| s[3] == code })
  42.       if ScriptsToDisable.include?(index - GameOverIndex)
  43.         code = ""
  44.       end
  45.     end
  46.   end
  47.   eval_ex(code, *argv)
  48. end
  49.  
  50. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  51. # END SCRIPT
  52. #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
RAW Paste Data