- Joined
- Dec 29, 2012
- Messages
- 869
- Reaction score
- 97
- First Language
- Dutch
- Primarily Uses

I counted 140+ scripts in my project. Obviously script compatibility debugging becomes an issue at some point. Or I commission a new script and then it bugs in my project because one of my own scripts may not be compatible.
Outcommenting over a 100 scripts every time that happens is such a waste of time and sadly Ace has no way to turn scripts on/off so I came up with a script to do that.
You have to add your script to the $scripts = [] array and you have to add these 2 lines:
if !$imported || ($imported[:nap_script_boss] && Script_Boss.script_enabled?
It seems rather complicated but it does save me a LOT of time. I can now disable entire batches of scripts and not worry about any crashes. I repeat this until the script works and then I know what script(s) caused the incompatibility. Or are there better solutions?
Full script:
#-----------------------------------------------------------------------------=beginWhy:I got so tired of [ctrl]+[q]'ing entire scripts or adding 'if true/false end'to them to enable/disable them. It get's worse when they have dependencies.About:When a script is enabled while one or more of it's dependencies are disabledthen this script will either enable all those depenencies or just disable thescript (and then all scripts that have that script as a dependency).Instructions:- Place this script on before any other script that is listed here.- Add a new entry to: $scripts = []- Add the 2 lines listed below around your script.Copy-Paste stuff:if !$imported || ($imported[:nap_script_boss] && Script_Boss.script_enabled?
REPLACE_ME))# <your entire script goes here>end # Script BossLicense:- All rights reserved (for now). (Currently not released)=end#-----------------------------------------------------------------------------$imported ||= {}$imported[:nap_script_boss] = 2.00#===============================================================================# Script Reporting & Enable/Disable Preferences#===============================================================================module Script_Boss ON_MISSING_DEPENDENCY_ACTION = :disable # possible values: :enable, :disable REPORT_ENABLED_DEPENDENCIES = true REPORT_DISABLED_DEPENDENCIES = true REPORT_ENABLED_SCRIPTS = false REPORT_DISABLED_SCRIPTS = true # - Array of scripts that you need enabled. # - Everything else will be disabled. But dependencies will be enabled as well # of course. # - ALWAYS_ENABLED entries are still enabled. DISABLE_ALL_EXCEPT = [] # Disables the scripts by index. Excluding ALWAYS_ENABLED entries. # value: [min, max] DISABLE_RANGE = [] DISABLE_CATEGORIES = [] # Disables all scripts from these categories. ALWAYS_ENABLED entries are still enabled. ALWAYS_ENABLED = [:nap_ev_text, :set_win_size, :skip_title_scrn, :khas_lighting_v2, :route_helper, :event_finetuning] # list of keys that are always enabled no matter what. REPORT_SCRIPT_INDEX = -1 # -1 disables it. Set to a value to retrieve the name of the script for the specified value.end#===============================================================================# Class SBoss#===============================================================================class SBoss attr_reader :key, :category, :req_scripts attr_accessor :enabled def initialize(key, script_enabled, category, *req_scripts) raise if script_enabled.class == Array @key = key; @enabled = script_enabled; @category = category; @req_scripts = req_scripts end # Transforms the @req_scripts from keys into actual SBoss classes def translate_req_scripts return if @req_scripts.empty? translated = [] req_scripts.each { |k| req = $scripts.find{ |s| s.key == k} raise "ERROR: Required script '#{k}' for '#{@key}' not found while translating!" if req.nil? translated << req } @req_scripts = translated end def enable_req_scripts(key = nil) # If the dev doesn't want to enable the dependencies then disable the script that requires them instead. if Script_Boss:
N_MISSING_DEPENDENCY_ACTION == :disable req_scripts.each { |req| if !req.enabled @enabled = false print "■ Disabled: '#{@key}' because it requires '#{req.key}'.\n" if Script_Boss::REPORT_DISABLED_DEPENDENCIES return end } return end return if key == @key # return if it is starting to loop (found itself again) req_scripts.each { |req| if !req.enabled req.enabled = true print "■ Enabled: '#{req.key}' because '#{@key}' requires it.\n" if Script_Boss::REPORT_ENABLED_DEPENDENCIES end key = @key if key.nil? # If it's the first in the recursive-tree then set the value to the 'initial caller'. req.enable_req_scripts(key) } endend#===============================================================================# Script Settings#===============================================================================# Turning on/off scripts happens here.SKIP_TITLE = true$scripts = [ SBoss.new
fix_passability, true, :bugfix), SBoss.new
fix_f12, true, :bugfix), SBoss.new
fix_text_cache, true, :bugfix), SBoss.new
nap_inifile, true, :core), SBoss.new
unlimited_resolution, true, :misc, :nap_inifile), SBoss.new
set_win_size, true, :misc), SBoss.new
fulscreen_pp, true, :misc), SBoss.new
event, true, :core), SBoss.new
event_hook, true, :core, :event), SBoss.new
initialization, false, :core, :event_hook), SBoss.new
perm_cache, false, :core, :event_hook, :nap_map_overlay), SBoss.new
nap_map_overlay, false, :misc), SBoss.new
generic_audio, false, :misc), SBoss.new
nap_core, true, :core), SBoss.new
point, true, :core), SBoss.new
nap_npc_rnd, false, :misc), SBoss.new
rectangle, true, :core,
oint), SBoss.new
sprite_ani, true, :core, :rectangle), SBoss.new
settings_mgr, true, :core, :event_hook, :achievement), SBoss.new
nap_image, true, :misc), SBoss.new
magazines, true, :misc, :settings_mgr, :nap_core), SBoss.new
alien_shooter, false, :minigame, :rectangle), SBoss.new
telephone, true, :menu), # <snip> SBoss.new
fps, true, :debug),] # Do not edit/remove this character#===============================================================================# Enable / Disable scripts based on preferences#===============================================================================module Script_Boss # Set script dependency class references $scripts.each { |s| s.translate_req_scripts } $scripts.each_with_index { |s, i| if !s.enabled s.enabled = true if ALWAYS_ENABLED.include?(s.key) next end if !DISABLE_ALL_EXCEPT.empty? s.enabled = false if !DISABLE_ALL_EXCEPT.include?(s.key) next end if !DISABLE_RANGE.empty? s.enabled = false if i.between?(DISABLE_RANGE[0], DISABLE_RANGE[1]) next end if !DISABLE_CATEGORIES.empty? s.enabled = false if DISABLE_CATEGORIES.include?(s.category) end } # Enable Dependencies $scripts.each { |s| s.enable_req_scripts if s.enabled } #============================================================================= # Report enabled/disabled dependencies (if applicable) #============================================================================= if REPORT_ENABLED_SCRIPTS || REPORT_DISABLED_SCRIPTS $scripts.each{ |s| if s.enabled print "* Enabled: '#{s.key}.\n" if REPORT_ENABLED_SCRIPTS elsif REPORT_DISABLED_SCRIPTS print "» Disabled: '#{s.key}.\n" end } end #============================================================================= # End Reporting #============================================================================= enabled = 0; disabled = 0 $scripts.each{ |s| s.enabled ? enabled += 1 : disabled += 1 } enabled_perc = (enabled / (enabled.to_f + disabled)).round(2) print "=============================================================================\n" print "[#{ ('■' * (enabled_perc * 10)).ljust(10) }] #{(enabled_perc * 100).to_i}% #{enabled} enabled and #{disabled} disabled scripts out of #{enabled + disabled} total.\n" print "=============================================================================\n" print "Script at index #{REPORT_SCRIPT_INDEX}: #{$scripts[REPORT_SCRIPT_INDEX].key} \n" if REPORT_SCRIPT_INDEX != -1 #============================================================================= # Script_Boss.script_enabled?(key) #============================================================================= def self.script_enabled?(script_symbol) script = $scripts.find { |s| s.key == script_symbol} raise "[Line:#{__LINE__}] Script not added to Script Boss array: #{script_symbol}" if script.nil? return script.enabled endend # module Script_Boss#===============================================================================# ■ End of Script ■#===============================================================================
Last edited by a moderator:


