Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- #==============================================================================#
- # AMN - Debug - Search
- # Version 1.00
- # Author: AMoonlessNight
- # Date: 26 Nov 2018
- # Latest: 26 Nov 2018
- #==============================================================================#
- # UPDATE LOG
- #------------------------------------------------------------------------------#
- # 26 Nov 2018 - created the script
- #==============================================================================#
- # TERMS OF USE
- #------------------------------------------------------------------------------#
- # - Please credit AMoonlessNight or A-Moonless-Night
- # - Free for non-commercial and commercial use
- # - I'd love to see your game if you end up using one of my scripts
- #==============================================================================#
- This script is a debugging tool to search through the various texts throughout
- the game for a keyword of your choice.
- This could be useful for finding how many times you use a particular word, or
- finding certain words with the intention of changing them later.
- Use the following script call:
- AMN_Debug.check_ref("x", match) OR AMN_Debug.check_ref(x)
- where x is the keyword of your choice and match is either true or false.
- If match is set to true, the game will search for matched case (e.g. ExAmPlEs).
- If you leave match out, it will automatically set to false.
- Data is exported to the following file:
- ref_check x.txt
- where x is the keyword that you checked for.
- You will find it in your project's main folder after running the script call.
- Please note:
- This script does not offer options for changing the data. You must go into
- the game and do that yourself. It's purely for viewing the selected data in
- one place.
- You should remove this script upon releasing your game.
- #-------------------------------------------------------------------------------
- ** LIST OF TEXT FIELDS CHECKED:
- #-------------------------------------------------------------------------------
- ** Database:
- * Actors:
- Name
- Nickname
- Notebox
- * Classes:
- Name
- Notebox
- * Skills:
- Name
- Description
- Notebox
- Message 1
- Message 2
- * Items:
- Name
- Description
- Notebox
- * Weapons:
- Name
- Description
- Notebox
- * Armour:
- Name
- Description
- Notebox
- * Enemies:
- Name
- Description
- Notebox
- * Troops:
- * Each page:
- Comments
- Text + scrolling text
- Choices
- Script calls
- * States:
- Name
- Notebox
- Message 1
- Message 2
- Message 3
- Message 4
- * Tilesets:
- Notebox
- * Common Events:
- Name
- Comments
- Text + scrolling text
- Choices
- Script calls
- * System:
- Game title
- Currency unit
- * Terms:
- Elements
- Weapon Types
- Skill Types
- Armour Types
- Basic Status
- Parameters
- Equip Types
- Commands
- ** Maps:
- Display name
- Notebox
- * Each event:
- Name
- * Each page:
- Comments
- Text + scrolling text
- Choices
- Script calls
- =end
- #==============================================================================
- # Please do not edit below this point unless you know what you are doing.
- #==============================================================================
- module AMN_Debug
- def self.check_ref(string, match = false)
- @total_matches = 0
- result = ""
- string = match ? string : string.downcase
- fstring = string.tr('/:*?"<>|', 'x'); fstring.gsub!(/\\/, 'x')
- file_name = "ref_check " + fstring + ".txt"
- File.delete(file_name) if File.exist?(file_name)
- result << check_variable_values(string, match)
- result << $data_system.check_ref(string, match)
- groups = [$data_actors, $data_classes, $data_skills, $data_items,
- $data_weapons, $data_armors, $data_enemies, $data_troops,
- $data_states, $data_tilesets, $data_common_events]
- for group in groups
- for obj in group
- next if obj.nil?
- result << obj.check_ref(string, match)
- end
- end
- $data_mapinfos.keys.sort.each do |k|
- map = load_data(sprintf("Data/Map%03d.rvdata2", k))
- result << map.check_ref(string, match, k)
- end
- result << "\n\n Total Matches: #{@total_matches}"
- File.open(file_name, "a+") do |f|
- f << result
- end
- puts "AMN Debug - scan complete: see '#{file_name}' in your game folder."
- end
- def self.check_variable_values(string, match)
- title = "\nLocation: Variables\n"
- result = ""
- for i in 1...$data_system.variables.size
- res = scan($game_variables[i], string, match)
- result << match_vocab(" Variable #{i}", res) unless res.empty?
- end
- return title + result unless result.empty?
- return result
- end
- def self.scan(obj, string, match)
- return [] unless obj.is_a?(String)
- r = match ? obj.scan(string) : obj.downcase.scan(string)
- @total_matches += r.length
- return r
- end
- def self.array_scan(array, string, match)
- arr = []
- array.each do |i|
- r = scan(i, string, match)
- arr << r
- end
- return arr.flatten
- end
- def self.match_vocab(title, amt)
- match = amt.length > 1 ? "%d matches" %[amt.length] : "%d match" %[amt.length]
- list = "\n Word matches: " + amt.join(", ")
- sprintf("%s: %s %s\n", title, match, list)
- end
- end
- module RPG
- class System
- def check_ref(string, match)
- title = "\nLocation: Database - System\n"
- result = ""
- res = AMN_Debug.scan(@game_title, string, match)
- result << AMN_Debug.match_vocab(" Game Title", res) unless res.empty?
- #
- res = AMN_Debug.scan(@currency_unit, string, match)
- result << AMN_Debug.match_vocab(" Currency Unit", res) unless res.empty?
- #
- res = AMN_Debug.array_scan(@elements, string, match)
- result << AMN_Debug.match_vocab(" Elements", res) unless res.empty?
- #
- res = AMN_Debug.array_scan(@skill_types, string, match)
- result << AMN_Debug.match_vocab(" Skill Types", res) unless res.empty?
- #
- res = AMN_Debug.array_scan(@weapon_types, string, match)
- result << AMN_Debug.match_vocab(" Weapon Types", res) unless res.empty?
- #
- res = AMN_Debug.array_scan(@armor_types, string, match)
- result << AMN_Debug.match_vocab(" Armour Types", res) unless res.empty?
- #
- res = AMN_Debug.array_scan(@terms.basic, string, match)
- result << AMN_Debug.match_vocab(" Terms: Basic", res) unless res.empty?
- #
- res = AMN_Debug.array_scan(@terms.params, string, match)
- result << AMN_Debug.match_vocab(" Terms: Params", res) unless res.empty?
- #
- res = AMN_Debug.array_scan(@terms.etypes, string, match)
- result << AMN_Debug.match_vocab(" Terms: Equip Types", res) unless res.empty?
- #
- return title + result unless result.empty?
- return result
- end
- end
- class BaseItem
- def check_ref(string, match)
- title = "\nLocation: Database - #{self.class} ID #{@id} #{@name}\n"
- result = ""
- res = AMN_Debug.scan(@name, string, match)
- result << AMN_Debug.match_vocab(" Name", res) unless res.empty?
- #
- res = AMN_Debug.scan(@description, string, match)
- result << AMN_Debug.match_vocab(" Description", res) unless res.empty?
- #
- res = AMN_Debug.scan(@note, string, match)
- result << AMN_Debug.match_vocab(" Notebox", res) unless res.empty?
- #
- return title + result unless result.empty?
- return result
- end
- # Enemy, Class, Armour, Weapon
- end
- class Skill
- def check_ref(string, match)
- title = "\nLocation: Database - #{self.class} ID #{@id} #{@name}\n"
- result = ""
- res = AMN_Debug.scan(@name, string, match)
- result << AMN_Debug.match_vocab(" Name", res) unless res.empty?
- #
- res = AMN_Debug.scan(@description, string, match)
- result << AMN_Debug.match_vocab(" Description", res) unless res.empty?
- #
- res = AMN_Debug.scan(@note, string, match)
- result << AMN_Debug.match_vocab(" Notebox", res) unless res.empty?
- #
- res = AMN_Debug.scan(@message1, string, match)
- result << AMN_Debug.match_vocab(" Message 1", res) unless res.empty?
- #
- res = AMN_Debug.scan(@message2, string, match)
- result << AMN_Debug.match_vocab(" Message 2", res) unless res.empty?
- #
- return title + result unless result.empty?
- return result
- end
- end
- class State
- def check_ref(string, match)
- title = "\nLocation: Database - #{self.class} ID #{@id}: #{@name}\n"
- result = ""
- res = AMN_Debug.scan(@name, string, match)
- result << AMN_Debug.match_vocab(" Name", res) unless res.empty?
- #
- res = AMN_Debug.scan(@note, string, match)
- result << AMN_Debug.match_vocab(" Notebox", res) unless res.empty?
- #
- res = AMN_Debug.scan(@message1, string, match)
- result << AMN_Debug.match_vocab(" Message 1", res) unless res.empty?
- #
- res = AMN_Debug.scan(@message2, string, match)
- result << AMN_Debug.match_vocab(" Message 2", res) unless res.empty?
- #
- res = AMN_Debug.scan(@message3, string, match)
- result << AMN_Debug.match_vocab(" Message 3", res) unless res.empty?
- #
- res = AMN_Debug.scan(@message4, string, match)
- result << AMN_Debug.match_vocab(" Message 4", res) unless res.empty?
- #
- return title + result unless result.empty?
- return result
- end
- # @message1, @message2, @message3, @message4
- end
- class Tileset
- def check_ref(string, match)
- title = "\nLocation: Database - #{self.class} ID #{@id}: #{@name}\n"
- result = ""
- res = AMN_Debug.scan(@note, string, match)
- result << AMN_Debug.match_vocab(" Notebox", res) unless res.empty?
- #
- return title + result unless result.empty?
- return result
- end
- # @note
- end
- class Troop
- def check_ref(string, match)
- title = "\nLocation: Database - #{self.class} ID #{@id}: #{@name}\n"
- result = ""
- @pages.each_with_index do |pg, i|
- res = AMN_Debug.scan(pg.note, string, match)
- result << AMN_Debug.match_vocab(" Page #{i+1} Comments", res) unless res.empty?
- #
- res = AMN_Debug.scan(pg.texts, string, match)
- result << AMN_Debug.match_vocab(" Page #{i+1} Texts", res) unless res.empty?
- #
- res = AMN_Debug.scan(pg.choices, string, match)
- result << AMN_Debug.match_vocab(" Page #{i+1} Choices", res) unless res.empty?
- #
- res = AMN_Debug.scan(pg.script_calls, string, match)
- result << AMN_Debug.match_vocab(" Page #{i+1} Script Calls", res) unless res.empty?
- end
- #
- return title + result unless result.empty?
- return result
- end
- #
- end
- class CommonEvent
- def note
- @note = ""
- return @note if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && [108, 408].include?(item.code)
- note_list << item.parameters[0]
- }
- @note = note_list.join("\r\n")
- return @note
- end
- def script_calls
- @s_calls = ""
- return @s_calls if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && [355, 655].include?(item.code)
- note_list << item.parameters[0]
- }
- @s_calls = note_list.join("\r\n")
- return @s_calls
- end
- def texts
- @texts = ""
- return @texts if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && [101, 401, 105, 405].include?(item.code)
- note_list << item.parameters[0]
- }
- @texts = note_list.join("\r\n")
- return @texts
- end
- def choices
- @choices = ""
- return @choices if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && item.code == 102
- item.parameters[0].each {|s| note_list << s }
- }
- @choices = note_list.join("\r\n")
- return @choices
- end
- def check_ref(string, match)
- title = "\nLocation: Database - #{self.class} ID #{@id}: #{@name}\n"
- result = ""
- res = AMN_Debug.scan(@name, string, match)
- result << AMN_Debug.match_vocab(" Name", res) unless res.empty?
- #
- res = AMN_Debug.scan(note, string, match)
- result << AMN_Debug.match_vocab(" Comments", res) unless res.empty?
- #
- res = AMN_Debug.scan(texts, string, match)
- result << AMN_Debug.match_vocab(" Texts", res) unless res.empty?
- #
- res = AMN_Debug.scan(choices, string, match)
- result << AMN_Debug.match_vocab(" Choices", res) unless res.empty?
- #
- res = AMN_Debug.scan(script_calls, string, match)
- result << AMN_Debug.match_vocab(" Script Calls", res) unless res.empty?
- #
- return title + result unless result.empty?
- return result
- end
- # @list - A list of event commands
- end
- class Map
- def check_ref(string, match, id)
- title = "\nLocation: #{self.class} ID #{id}: #{$data_mapinfos[id].name}\n"
- result = ""
- res = AMN_Debug.scan(@display_name, string, match)
- result << AMN_Debug.match_vocab(" Display Name", res) unless res.empty?
- #
- res = AMN_Debug.scan(@note, string, match)
- result << AMN_Debug.match_vocab(" Notebox", res) unless res.empty?
- #
- @events.each_key do |ev|
- unless @events[ev].check_ref(string, match, id).empty?
- result << @events[ev].check_ref(string, match, id)
- end
- end
- #
- return title + result unless result.empty?
- return result
- # display_name, @map.note
- # @events
- end
- end
- class Event
- def check_ref(string, match, id)
- title = " MAP #{id} #{self.class} ID #{@id}: #{@name}\n"
- result = ""
- res = AMN_Debug.scan(@name, string, match)
- result << AMN_Debug.match_vocab(" Name", res) unless res.empty?
- #
- @pages.each_with_index do |pg, i|
- res = AMN_Debug.scan(pg.note, string, match)
- result << AMN_Debug.match_vocab(" Page #{i+1} Comments", res) unless res.empty?
- #
- res = AMN_Debug.scan(pg.texts, string, match)
- result << AMN_Debug.match_vocab(" Page #{i+1} Texts", res) unless res.empty?
- #
- res = AMN_Debug.scan(pg.choices, string, match)
- result << AMN_Debug.match_vocab(" Page #{i+1} Choices", res) unless res.empty?
- #
- res = AMN_Debug.scan(pg.script_calls, string, match)
- result << AMN_Debug.match_vocab(" Page #{i+1} Script Calls", res) unless res.empty?
- #
- end
- return title + result unless result.empty?
- return result
- end
- end
- end
- class Game_Actor < Game_Battler
- def check_ref(string, match)
- title = "\nLocation: Database - #{self.class} ID #{@id}: #{@name}\n"
- result = ""
- res = AMN_Debug.scan(@name, string, match)
- result << AMN_Debug.match_vocab(" Name", res) unless res.empty?
- #
- res = AMN_Debug.scan(@nickname, string, match)
- result << AMN_Debug.match_vocab(" Nickname", res) unless res.empty?
- #
- res = AMN_Debug.scan(actor.note, string, match)
- result << AMN_Debug.match_vocab(" Notebox", res) unless res.empty?
- #
- return title + result unless result.empty?
- return result
- # @name, @nickname, actor.note
- end
- end
- class RPG::Event::Page
- def note
- @note = ""
- return @note if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && [108, 408].include?(item.code)
- note_list << item.parameters[0]
- }
- @note = note_list.join("\r\n")
- return @note
- end
- def script_calls
- @s_calls = ""
- return @s_calls if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && [355, 655].include?(item.code)
- note_list << item.parameters[0]
- }
- @s_calls = note_list.join("\r\n")
- return @s_calls
- end
- def texts
- @texts = ""
- return @texts if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && [101, 401, 105, 405].include?(item.code)
- note_list << item.parameters[0]
- }
- @texts = note_list.join("\r\n")
- return @texts
- end
- def choices
- @choices = ""
- return @choices if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && item.code == 102
- item.parameters[0].each {|s| note_list << s }
- }
- @choices = note_list.join("\r\n")
- return @choices
- end
- end
- class RPG::Troop::Page
- def note
- @note = ""
- return @note if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && [108, 408].include?(item.code)
- note_list << item.parameters[0]
- }
- @note = note_list.join("\r\n")
- return @note
- end
- def script_calls
- @s_calls = ""
- return @s_calls if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && [355, 655].include?(item.code)
- note_list << item.parameters[0]
- }
- @s_calls = note_list.join("\r\n")
- return @s_calls
- end
- def texts
- @texts = ""
- return @texts if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && [101, 401, 105, 405].include?(item.code)
- note_list << item.parameters[0]
- }
- @texts = note_list.join("\r\n")
- return @texts
- end
- def choices
- @choices = ""
- return @choices if !@list || @list.size <= 0
- note_list = []
- @list.each { |item|
- next unless item && item.code == 102
- item.parameters[0].each {|s| note_list << s }
- }
- @choices = note_list.join("\r\n")
- return @choices
- end
- end
- class Game_Event < Game_Character
- attr_reader :event
- def note
- return "" if !@page || !@page.list || @page.list.size <= 0
- @page.note
- end
- def script_calls
- return "" if !@page || !@page.list || @page.list.size <= 0
- @page.script_calls
- end
- def texts
- return "" if !@page || !@page.list || @page.list.size <= 0
- @page.texts
- end
- def choices
- return "" if !@page || !@page.list || @page.list.size <= 0
- @page.choices
- end
- end
Add Comment
Please, Sign In to add comment