[Script] Text Extraction Generator

Share resources for RPG Maker XP. Uploads must be your own work or have permission to share. Do not share game rips.
Post Reply
User avatar
DerVVulfman
Posts: 31
Joined: Sat Dec 08, 2018 4:25 am
Location: PG, Maryland
Contact:

[Script] Text Extraction Generator

Post by DerVVulfman » Sun Dec 16, 2018 4:36 am

Text Extraction Generator

Version: 1.1





Introduction
This script is designed to search throughout your RPGMaker XP's project to to find and record all normally created text dialog to a file. it will search through both the common event database and through each map and map event, recording all texts to a file. The output file created will be entitled "Text Extractor.txt" within your project's folder.

Each line will include the Common Event ID or Map/Event/Page number before listing the text. With this, the report may be able to help proof-readers before a project is released.




Script

Code: Select all

#==============================================================================
# ** Text Extraction Generator
#------------------------------------------------------------------------------
#    version 1.1
#    by DerVVulfman
#    10-08-2014
#    RGSS and ReGaL Compliant
#==============================================================================
#
#  INTRODUCTION:
#
#  This script is designed to search throughout your RPGMaker XP's project to
#  to find and record all  normally created text dialog  to a file.   it will
#  search through both the common event database and through each map and map
#  event,  recording all texts  to a file.   The output file created  will be 
#  entitled "Text Extractor.txt" within your project's folder.
#
#  Each line will include the Common Event ID or Map/Event/Page number before
#  listing the text.  With this, the report may be able to help proof-readers
#  before a project is released.
#
#
#------------------------------------------------------------------------------
#
#  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.
#
#
#==============================================================================



#==============================================================================
# ** Text_Extractor
#------------------------------------------------------------------------------
#  This is a module that extracts dialog and text from both map events and
#  common events.
#==============================================================================

module Text_Extractor
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------  
  def self.main
    f = File.new("Text Extractor.txt",  "w+")
    f.puts "TEXT EXTRACTION LIST"
    f.puts ""
    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
    @common_list = load_data("Data/CommonEvents.rxdata")
    @map_list    = load_data("Data/MapInfos.rxdata")
    @troop_list  = load_data("Data/Troops.rxdata") 
  end  
  #--------------------------------------------------------------------------
  # * Common Events Database Search
  #--------------------------------------------------------------------------
  def self.search_resource_common(file)
    return if @common_list.nil?
    counter = 0
    for event in @common_list
      next if event.nil?
      name = event.name
      list = event.list
      counter += 1
      header = counter.to_s + ") "+ name
      search_resource_page_item(file, header, 15, list)
    end
  end
  #--------------------------------------------------------------------------
  # * Troop Database Search
  #--------------------------------------------------------------------------
  def self.search_resource_troop(file)
    tcounter = 0
    for troop in @troop_list
      next if troop.nil?
      tcounter += 1
      counter = 0
      for page in troop.pages.reverse
        counter += 1
        id = tcounter
        name = troop.name
        list = page.list
        header = id.to_s + ") " +  name + " / Pg: " + counter.to_s + " "
        search_resource_page_item(file, header, 25, list)        
      end
    end
  end  
  #--------------------------------------------------------------------------
  # * Map Database Search
  #--------------------------------------------------------------------------
  def self.search_resource_map(file)
    for map in @map_list
      # 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
        counter = 0
        # Sort through Event Pages
        for page in event[1].pages.reverse
          counter += 1
          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, 25, 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]
    for list_item in list
      if [101, 401].include?(list_item.code)
        unless list_item.parameters == ''
          file.puts temp_text + " <Text:>     " + (list_item.parameters).to_s
          temp_text = "                         "    
          temp_text = temp_text[0, sized]
        end
      elsif list_item.code == 102
        unless list_item.parameters == ''
          corey = list_item.parameters[0]
          for c in corey
            file.puts temp_text + " <Choices:>  " + c.to_s
            temp_text = "                         "
            temp_text = temp_text[0, sized]
          end
        end
      end
    end
    file.puts ""
  end
end



#----------------------------------------------------------------------------
# * Execution Command
#----------------------------------------------------------------------------
  Text_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.





Credits

Inspiration for the system, and suggestion to include both common events and show choices text by yamina-chan. And to Kain_Nobel for pointing out a brief lack of battlesystem text that needed to be added.





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.
Image

Post Reply