07-20-2020, 06:58 PM
Variable Extraction Generator
Version: 1.0
Version: 1.0
Introduction
This script is designed to search throughout your RPGMaker XP's project to find and record all used RPGMaker XP variables to a file. It will search through both the common event database and through each map and map event, and the troop database recording all variables used to a file. The output file will be named "Variable Extractor.txt" within your project's folder.
Each line will include the Common Event ID, Map/Event/Page number or Troop ID/Page number before listing the variable. With this, the report may be able to help organize their system during game creation.
Script
The Script
Code:
#==============================================================================
# ** Variable Extraction Generator
#------------------------------------------------------------------------------
# version 1.0
# by DerVVulfman
# 07-20-2020
# RGSS and ReGaL Compliant
#==============================================================================
#
# INTRODUCTION:
#
# This script is designed to search throughout your RPGMaker XP's project to
# find and record all used RPGMaker XP variables to a file. It will search
# through both the common event database and through each map and map event,
# and the troop database recording all variables used to a file. The output
# file will be named "Variable Extractor.txt" within your project's folder.
#
# Each line will include the Common Event ID, Map/Event/Page number or Troop
# ID/Page number before listing the variable. With this, the report may be
# able to help organize their system during game creation.
#
#
#------------------------------------------------------------------------------
#
# INSTRUCTIONS:
#
# * Insert below your scripts.
# * Run project.
# * Read report when you're done.
#
#
#------------------------------------------------------------------------------
#
# CREDITS:
#
# Inspiration for the system, and suggestion to include both common events
# and show choices text by yamina-chan. Additional suggestion of Troops
# Database text made by Kain_Nobel.
#
#
#------------------------------------------------------------------------------
#
# NOTE:
#
# It only searches through the common event page within the database and the
# events within the map systems. It does not search through custom scripts.
#
#
#==============================================================================
#==============================================================================
# ** Variable_Extractor
#------------------------------------------------------------------------------
# This is a module searches through all map events, common events and troop
# database content to generate a textfile list of all used RMXP variables for
# game developer review.
#==============================================================================
module Variable_Extractor
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def self.main
# Create Header
f = File.new("Variable Extractor.txt", "w+")
f.puts "VARIABLE EXTRACTION LIST"
f.puts ""
# Gain Data Resources
set_resource_database
f.puts "COMMON EVENT PORTION:"
f.puts ""
search_resource_common(f)
f.puts ""
f.puts "MAP LIST PORTION:"
f.puts ""
search_resource_map(f)
f.puts ""
f.puts "BATTLESYSTEM PORTION:"
f.puts ""
search_resource_troop(f)
f.close
end
#--------------------------------------------------------------------------
# * Project Database Values
#--------------------------------------------------------------------------
def self.set_resource_database
@variable_list = load_data("Data/System.rxdata")
@common_list = load_data("Data/CommonEvents.rxdata")
@map_list = load_data("Data/MapInfos.rxdata")
@troop_list = load_data("Data/Troops.rxdata")
@enemy_list = load_data("Data/Enemies.rxdata")
end
#--------------------------------------------------------------------------
# * Common Events Database Search
#--------------------------------------------------------------------------
def self.search_resource_common(file)
text_width_size = 25
return if @common_list.nil?
counter = 0
for event in @common_list
next if event.nil?
name = event.name
trigger = event.trigger
list = event.list
counter += 1
header = counter.to_s + ") "+ name
search_resource_page_item(file, header, text_width_size, list)
end
end
#--------------------------------------------------------------------------
# * Troop Database Search
#--------------------------------------------------------------------------
def self.search_resource_troop(file)
file.puts "Troop Content:"
file.puts ""
text_width_size = 25
tcounter = 0
for troop in @troop_list
next if troop.nil?
tcounter += 1
counter = 0
for page in troop.pages
counter += 1
id = tcounter
name = troop.name
name = name.slice(0,10)
condition = page.condition
list = page.list
header = id.to_s + ") " + name + " / Pg: " + counter.to_s + " "
search_resource_page_item(file, header, text_width_size, list)
end
end
end
#--------------------------------------------------------------------------
# * Map Database Search
#--------------------------------------------------------------------------
def self.search_resource_map(file)
text_width_size = 25
for map in @map_list.sort
# Get map ID
id = map[0]
# Get Individual Map Data
map_data = load_data(sprintf("Data/Map%03d.rxdata", id))
# Set map event data
events = {}
for i in map_data.events.keys
events[i] = map_data.events[i]
end
# Sorth through Event Array
for event in events.sort
counter = 0
# Sort through Event Pages
for page in event[1].pages.reverse
counter += 1
condition = page.condition
had_content = false
if condition.variable_valid == true
had_content = true
i == condition.variable_id
header = id.to_s + ") EV: " + (event[0]).to_s + " / Pg: " +
counter.to_s + " "
temp_text = header + " "
temp_text = temp_text[0, text_width_size]
variable_text = "#" + condition.variable_id .to_s
variable_text = variable_text + " / " +
@variable_list.variables[condition.variable_id]
file.puts temp_text + " <Variable:> " + variable_text
temp_text = " "
temp_text = temp_text[0, text_width_size]
end
file.puts "" if had_content == true
list = page.list
header = id.to_s + ") EV: " + (event[0]).to_s + " / Pg: " +
counter.to_s + " "
# Sort through event list options
search_resource_page_item(file, header, text_width_size, list)
end
end
end
end
#--------------------------------------------------------------------------
# * Page List Search (whether troop or map pages)
#--------------------------------------------------------------------------
def self.search_resource_page_item(file, header, sized, list)
temp_text = header + " "
temp_text = temp_text[0, sized]
had_content = false
# Cycle through items
for list_item in list
# If Conditional Branch
if [111].include?(list_item.code)
# If conditional is variable
if list_item.parameters[0] == 1
# File value of Switch
variable_val = list_item.parameters[1]
variable_text = "#" + variable_val.to_s
variable_text = variable_text + " / " +
@variable_list.variables[variable_val]
file.puts temp_text + " <Event List:> " + variable_text
temp_text = " "
temp_text = temp_text[0, sized]
had_content = true
end
# If Control Switch
elsif [122].include?(list_item.code)
# Loop for group control
for i in list_item.parameters[0] .. list_item.parameters[1]
# File value of Switch
variable_text = "#" + i.to_s
variable_text = variable_text + " / " + @variable_list.variables[i]
file.puts temp_text + " <Event List:> " + variable_text
temp_text = " "
temp_text = temp_text[0, sized]
had_content = true
end
end
end
file.puts "" if had_content == true
end
end
#----------------------------------------------------------------------------
# * Execution Command
#----------------------------------------------------------------------------
Variable_Extractor.main
#----------------------------------------------------------------------------
Instructions
Too simple. Install it under your scripts and run the game. It does the search for you and makes a report in your project's folder.
Compatibility
Designed for use with RPGMaker XP and currently with the Beta version of the ReGaL gaming system in the works.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links