iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> Story Dialogue Extractor, For spellchecking your story
Rhidian
post Jan 27 2013, 04:04 AM
Post #1



Group Icon


Type: Coder
Alignment: Chaotic Neutral




Story Dialogue Extractor v2.7
By Rhidian


Version Log:
2.6 - Base release
2.7 - Added Map name to the output/individual file names in order for you to find the map with text more easily

Introduction
You're content having a nice demo out containing a good amount of gameplay, when all of a sudden you are informed by a player that there is a spelling error in one of the maps.

With the thousands of events with dialogue within your project, how do you go about finding it? Clicking every page in every event on every map will take forever...

Enter the Story Dialogue Extractor. This handy little script, with a single command, can automatically go through every page in every event in every map for you and write the dialogue to a text file. You can then load the text file in your word editor of choice and ctrl + f to find the spelling error.


Features
- Ability to extract all the dialogue text from individual maps or every map
- For all map extraction, can write to multiple files separated by map, or into a single file
- Formatted to help you find the actual event on the map after locating the error in the text file

Sample Output
For all maps into a single file:
(Old version 2.6 output)
Spoiler:
CODE
--------------------------
Map 1|Event 1- EV001|Page 1

--------------------------
Map 1|Event 2- EV002|Page 1

Hello! I am the first actor
saying something on the first map

This is my second line. There is about
to be a branched choice


-----
Map 1| Event 2- EV002|Page 2
When [What choice?]

The choice you just did of course.
Why don't you try again?


-----
Map 1| Event 2- EV002|Page 2
When [Maybe this one]

Branched dialogue within a branch
within branches


-----
Map 1| Event 2- EV002|Page 2
When [No, probably this one]

Hopefully this script
makes getting the dialogue out
easier


-----
Map 1| Event 2- EV002|Page 2
When [This one?]

Yes, this choice.
Reminder: This is
from the first
choice made

--------------------------
Map 1|Event 2- EV002|Page 2

And this is the beginning
of my second page

--------------------------
Map 1|Event 3- EV003|Page 1

Hello there
I am the second talking actor
on the map

For your information
Event 1 was the event
used to trigger the script

Which is why it doesn't have dialogue

--------------------------
Map 2|Event 1- EV001|Page 1

This text comes from the
second map

I am the first event here
Event ID 001,
with the name EV001

--------------------------
Map 2|Event 2- RandomName|Page 1

I am the second
event on the
second map

My ID is 002, but
my Name is
RandomName


(Version 2.7 output)
Spoiler:
CODE
--------------------------
Map 1- TestMap|Event 1- EV001|Page 1

--------------------------
Map 1- TestMap|Event 2- EV002|Page 1

Hello! I am the first actor
saying something on the first map

This is my second line. There is about
to be a branched choice


-----
Map 1- TestMap| Event 2- EV002|Page 2
When [What choice?]

The choice you just did of course.
Why don't you try again?


-----
Map 1- TestMap| Event 2- EV002|Page 2
When [Maybe this one]

Branched dialogue within a branch
within branches


-----
Map 1- TestMap| Event 2- EV002|Page 2
When [No, probably this one]

Hopefully this script
makes getting the dialogue out
easier


-----
Map 1- TestMap| Event 2- EV002|Page 2
When [This one?]

Yes, this choice.
Reminder: This is
from the first
choice made

--------------------------
Map 1- TestMap|Event 2- EV002|Page 2

And this is the beginning
of my second page

--------------------------
Map 1- TestMap|Event 3- EV003|Page 1

Hello there
I am the second talking actor
on the map

For your information
Event 1 was the event
used to trigger the script

Which is why it doesn't have dialogue

--------------------------
Map 2- MAP002|Event 1- EV001|Page 1

This text comes from the
second map

I am the first event here
Event ID 001,
with the name EV001

--------------------------
Map 2- MAP002|Event 2- RandomName|Page 1

I am the second
event on the
second map

My ID is 002, but
my Name is
RandomName


How to Use
-Place contents of the script below Materials and above Main in the Script Editor.
-Place an event on a map of interest for individual extraction, or any map for all-map extraction

For Individual Map Extraction
-Within the script area of the event, enter this:
CODE
extractor = Text_Extractor.new
extractor.extract_text


For All Maps Extraction to Multiple Files
-Within the script area of the event, enter this:
CODE
extractor = Text_Extractor.new
extractor.extract_text_all_maps


For All Maps Extraction to a single file
-Within the script area of the event, enter this:
CODE
extractor = Text_Extractor.new
extractor.extract_text_all_maps_single_file


-After putting the command in the script area of the event for any extraction type, enter the playtest and activate the event
-You should see "Text extraction complete" after it is done
-The text files will be located in the same area the save-games are located in
-For safety, exit the playtest and remove the event after use

Demo
Old version 2.6
Attached File  StoryTextExtraction.rar ( 231.91K ) Number of downloads: 29


Version 2.7
Attached File  StoryTextExtraction.rar ( 231.96K ) Number of downloads: 62


Demo includes the Project, so you can see how the event is scripted
To activate extraction, activate the chest on the map


Script

Old Version 2.6
Spoiler:

CODE
#----------------------------------------------------------------------------
#   Event Dialogue Extractor v2.6
#   Author: Rhidian
#
#   Feel free to reuse/modify any portion of this script
#   Giving credit is always nice
#----------------------------------------------------------------------------
#   !!!!!!!WARNING!!!!!!!!
#   This script should be used in development only
#   and any events associated with this script removed after use
#
#   Instructions:
#   On any map, place an event, then go to it's command area
#
#   (For single map extraction from the map the event is on)
#   In the command area, copy/paste
#
#    extractor = Text_Extractor.new
#   extractor.extract_text
#
#
#
#   (For all maps extraction into multiple files)
#   In the command area, copy/paste
#
#   extractor = Text_Extractor.new
#   extractor.extract_text_all_maps
#
#
#   (For all maps extraction into a single file)
#    In the command area, copy/paste
#    
#   extractor = Text_Extractor.new
#   extractor.extract_text_all_maps_single_file
#
#   Then go to that map and interact with the event
#   Unseen to you, the game will then cycle through the maps of choice and
#   Extract the "Show Text" options in the events to a Text file
#   Named after the Map_ID the map is on or to Dialogue Text All Maps.txt
#   For the all maps to single file option
#  
#   For safety, it is recommended to exit the playtest and
#   Remove the triggering event after use, as there may be
#   Unintended consequences to the playtest from loading every map
#   and reading every event.
#----------------------------------------------------------------------------

module StoryExtractor
  MAP_ID_MAX = 100   #Change this to be greater than the max # of maps you have
  
  
end

class Game_Event < Game_Character
  attr_reader   :name     #Event Name
  attr_reader   :pages    #Event Pages
  
  alias event_name_pages_initialize initialize
  def initialize(map_id, event)
    event_name_pages_initialize(map_id, event)
    @name = @event.name
    @pages = @event.pages    
  end
end


class Text_Extractor  
  
  def initialize
    @all_maps = false
  end
  
  def setup(event)
    @map_id = $game_map.map_id        # Memorize map ID
    @original_event_id = event.id     # Memorize event ID
    @event_id = event.id              # Memorize event ID
    @pages = event.pages  
    @name = event.name
    @count = 1
    for page in @pages
      @file.write("--------------------------\n")
      @file.write("Map " + @map_id.to_s() + "|Event " + @event_id.to_s() + "- " + event.name + "|Page " + @count.to_s() + "\n\n")
      #Writes the text of the individual map
      @index = 0                        # Initialize index
      @list = page.list
      @count += 1
      printText
    end
  end

  #Extracts dialogue text from all maps
  #Refer to instructions above, use with caution
  def extract_text_all_maps
    begin
      @all_maps = true              #Switch so it only outputs finish msg once
      original_id = $game_map.map_id
      map_id = 1
      
      for map_id in 1..StoryExtractor::MAP_ID_MAX       #Arbitrary number, make sure it's higher than your
        $game_map.setup(map_id) #total map count, as it will automatically
        extract_text            #exit this loop after there are no more maps
        map_id += 1
      end
    rescue
      ensure
      $game_map.setup(original_id)
      @all_maps = false                   #Finished extracting from all maps
      print "Text extraction complete"
    end
  end
  
  def extract_text_all_maps_single_file
    begin
      @all_maps = true
      original_id = $game_map.map_id
      map_id = 1
      filename = "Dialogue Text All Maps.txt"
      @file = File.open(filename, "w")
      for map_id in 1..StoryExtractor::MAP_ID_MAX
        
        $game_map.setup(map_id)
        for event in $game_map.events.values
          setup(event)
        end
      end
    rescue
    ensure
      $game_map.setup(original_id)
      @all_maps = false
      print "Text Extraction complete"
      @file.close  unless @file == nil
      
    end
  end
  
  
  
  #Extracts text from a single map
  def extract_text
    begin
      filename = "Map" + $game_map.map_id.to_s() + " Text.txt"
      @file = File.open(filename, "w")
            
      for event in $game_map.events.values  # For every event on the map
        setup(event)
      end    
      
    rescue IOError => e
      ensure
      print "Text extraction complete" unless @all_maps
      @file.close unless @file == nil
    end
  end
  
  #Does the actual file writing
  def printText
    while @index < @list.size-1 do
      if @list[@index].code == 101 #Show Text command
        @index += 1        
        while @list[@index].code == 401       # Text data
          @file.write(@list[@index].parameters[0] + "\n")
          @index += 1
        end
        @file.write("\n")      
      else
        if @list[@index].code == 402          #When [Choice]
          @file.write("\n-----\n")
          @file.write("Map " + @map_id.to_s() + "| Event " + @event_id.to_s() + "- " + @name + "|Page " + @count.to_s() + "\nWhen [" + @list[@index].parameters[1] + "]\n\n")
        end
      
        @index += 1
      end #End If
      
    end #End While
    
  end  
end



Version 2.7 (with Map name)
Spoiler:
CODE
#----------------------------------------------------------------------------
#   Event Dialogue Extractor v2.7
#   Author: Rhidian
#
#   Feel free to reuse/modify any portion of this script
#   Giving credit is always nice
#----------------------------------------------------------------------------
#   !!!!!!!WARNING!!!!!!!!
#   This script should be used in development only
#   and any events associated with this script removed after use
#
#   Instructions:
#   On any map, place an event, then go to it's command area
#
#   (For single map extraction from the map the event is on)
#   In the command area, copy/paste
#
#    extractor = Text_Extractor.new
#   extractor.extract_text
#
#
#
#   (For all maps extraction into multiple files)
#   In the command area, copy/paste
#
#   extractor = Text_Extractor.new
#   extractor.extract_text_all_maps
#
#
#   (For all maps extraction into a single file)
#    In the command area, copy/paste
#    
#   extractor = Text_Extractor.new
#   extractor.extract_text_all_maps_single_file
#
#   Then go to that map and interact with the event
#   Unseen to you, the game will then cycle through the maps of choice and
#   Extract the "Show Text" options in the events to a Text file
#   Named after the Map_ID the map is on or to Dialogue Text All Maps.txt
#   For the all maps to single file option
#  
#   For safety, it is recommended to exit the playtest and
#   Remove the triggering event after use, as there may be
#   Unintended consequences to the playtest from loading every map
#   and reading every event.
#----------------------------------------------------------------------------

module StoryExtractor
  MAP_ID_MAX = 100   #Change this to be greater than the max # of maps you have
  
  
end

class Game_Event < Game_Character
  attr_reader   :name     #Event Name
  attr_reader   :pages    #Event Pages
  
  alias event_name_pages_initialize initialize
  def initialize(map_id, event)
    event_name_pages_initialize(map_id, event)
    @name = @event.name
    @pages = @event.pages    
  end
end

class Game_Map
  def map_name
    data = load_data('Data/MapInfos.rvdata')
    return data[@map_id].name
  end
end

class Text_Extractor  
  
  def initialize
    @all_maps = false
  end
  
  def setup(event)
    @map_id = $game_map.map_id        # Memorize map ID
    @map_name = $game_map.map_name
    @original_event_id = event.id     # Memorize event ID
    @event_id = event.id              # Memorize event ID
    @pages = event.pages  
    @name = event.name
    @count = 1
    for page in @pages
      @file.write("--------------------------\n")
      @file.write("Map " + @map_id.to_s() + "- " + @map_name + "|Event " + @event_id.to_s() + "- " + event.name + "|Page " + @count.to_s() + "\n\n")
      #Writes the text of the individual map
      @index = 0                        # Initialize index
      @list = page.list
      @count += 1
      printText
    end
  end

  #Extracts dialogue text from all maps
  #Refer to instructions above, use with caution
  def extract_text_all_maps
    begin
      @all_maps = true              #Switch so it only outputs finish msg once
      original_id = $game_map.map_id
      map_id = 1
      
      for map_id in 1..StoryExtractor::MAP_ID_MAX       #Arbitrary number, make sure it's higher than your
        $game_map.setup(map_id) #total map count, as it will automatically
        extract_text            #exit this loop after there are no more maps
        map_id += 1
      end
    rescue
      ensure
      $game_map.setup(original_id)
      @all_maps = false                   #Finished extracting from all maps
      print "Text extraction complete"
    end
  end
  
  def extract_text_all_maps_single_file
    begin
      @all_maps = true
      original_id = $game_map.map_id
      map_id = 1
      filename = "Dialogue Text All Maps.txt"
      @file = File.open(filename, "w")
      for map_id in 1..StoryExtractor::MAP_ID_MAX
        
        $game_map.setup(map_id)
        for event in $game_map.events.values
          setup(event)
        end
      end
    rescue
    ensure
      $game_map.setup(original_id)
      @all_maps = false
      print "Text Extraction complete"
      @file.close  unless @file == nil
      
    end
  end
  
  
  
  #Extracts text from a single map
  def extract_text
    begin
      filename = "Map" + @map_name + " Text.txt"
      @file = File.open(filename, "w")
            
      for event in $game_map.events.values  # For every event on the map
        setup(event)
      end    
      
    rescue IOError => e
      ensure
      print "Text extraction complete" unless @all_maps
      @file.close unless @file == nil
    end
  end
  
  #Does the actual file writing
  def printText
    while @index < @list.size-1 do
      if @list[@index].code == 101 #Show Text command
        @index += 1        
        while @list[@index].code == 401       # Text data
          @file.write(@list[@index].parameters[0] + "\n")
          @index += 1
        end
        @file.write("\n")      
      else
        if @list[@index].code == 402          #When [Choice]
          @file.write("\n-----\n")
          @file.write("Map " + @map_id.to_s() + "- " + @map_name + "| Event " + @event_id.to_s() + "- " + @name + "|Page " + @count.to_s() + "\nWhen [" + @list[@index].parameters[1] + "]\n\n")
        end
      
        @index += 1
      end #End If
      
    end #End While
    
  end  
end


Compatibility
Script should work with all other scripts
However, this script will not extract dialogue entered through methods other than the Show_Text command

Credit and Thanks
- Author: Rhidian
-???nOBodY??? for showing how to get the map name

This post has been edited by Rhidian: Jan 27 2013, 02:24 PM
Go to the top of the page
 
+Quote Post
   
???nOBodY???
post Jan 27 2013, 10:10 AM
Post #2


moogles + nightmares + coffee = Scripting Psychopathic Tendency
Group Icon


Type: Coder
Alignment: Chaotic Neutral




How'd it go from WIP to v2.6 all-of-a-sudden? lol. I remember finding a script like this made by Zeriab a while back, but the two scripts are definitely coded very differently (just from looking at the output xd). Regardless, it's an honorable contribution. Kudos! *tips hat*


--------------------
*The Master List Update Project is currently up-to-date with the latest scripts for that dream project!
*By entering the RGSS2/Ruby Scripting section, you are agreeing to abide by The Coder's Creed.

My Scripts
Spoiler:

ACK Script Requests
Spoiler:

Scripts
Stat Change Formulas
GTBS Ziifee's spin menu Submenus
GTBS Weapon Unleash
GTBS Enemy Status
Attack Command Submenu
Jump To (X,Y)
BGM/BGS Fadein
Window_Message - Pop Text
Spell Management Menu
Melee Mastery Management Menu
Ghost List
Save / Autoload
Some Popup v2.9 => v2.91
Scene_StringEntry v1.02
Scene_StringEntry: More Than 24-Character Input
Scene_StringEntry: Scrolling Character Input Window
Scene_StringEntry: Typing Input
MA's Quest Journal - Accept Quest Add-On (internal)
MA's Quest Journal - Accept Quest Add-On (external)
Easy-to-Add Extra Ziifee Spin Commands
Scrolling Battle Message
Non-Differentiating Enemies
Quest Item Drops
(VX) FP Conditional Drops
FFTA World Map HUD bugfix
RSSBS / SSS - Wereforms patch
Death Counterattack
Targetting Extension

My Heart (Resources)
Spoiler:

Projects
Project AMBROSIA
*something generically clever*

Support these:
Spoiler:







Awards:
Spoiler:

Go to the top of the page
 
+Quote Post
   
Rhidian
post Jan 27 2013, 01:22 PM
Post #3



Group Icon


Type: Coder
Alignment: Chaotic Neutral




Version 1.0 was basic text only from a single map. 2.0 I think was when I added the all-maps functionality. Around 2.5 was adding the branched dialogue and multiple event pages, while 2.6 was output format change plus single file functionality. What can I say, my version numberings are weird biggrin.gif

Truthfully, the script was mostly done by the time I posted the WIP version (it was around 2.5 then). I was wanting input on whether the loading all maps could be circumvented, and at the time was unsure of the effects that would have on the play test. Since I haven't seen any other way of accessing every event, I decided I may as well release the script as complete using the method I used. That, and I haven't seen evidence yet suggesting loading every map is actually harmful to the play test.

I was unaware of any similar scripts; I remember going through the master script list and not seeing such a script in the Creator tools section. Which is why I decided to script something that would help with the spellchecking of projects, since I have heard how hard that becomes with bigger projects.

Edit: I went and looked at Zeriab's Dialog System script (which is the one I think you're referring to). I believe that Zeriab's script deals with getting dialogue into the game and displaying it nicely (if I understood the framework correctly), while mine is concerned with getting dialogue out into a text file. I am now aware of a potential compatibility issue though: this script only works for text shown via the Show_Text command, and won't do a thing for dialogue shown through other means.

This post has been edited by Rhidian: Jan 27 2013, 01:43 PM
Go to the top of the page
 
+Quote Post
   
machogrubba14
post Jan 27 2013, 07:54 PM
Post #4



Group Icon


Type: Artist
Alignment: Chaotic Good




This script has amazing potential! Thank you for such a handy script! More creators need to see this!


--------------------
My Youtube Channel!
Art is the way YOU express YOUR creativity!
If you are a believer of Jesus Christ, and are 100% proud of it, put this in your sig!





*My Current Game Projects!*Check it out! XD

My way of thanking those who have helped me in the past!
<---- LOL



CHECK THESE OUT PEEPS!!!!:
Spoiler:
















Go to the top of the page
 
+Quote Post
   
flipsomel
post Jan 28 2013, 12:04 PM
Post #5


L. Khaos
Group Icon


Type: Undisclosed





2 words: Thank you!


--------------------
Go to the top of the page
 
+Quote Post
   
Nova Girl
post Mar 28 2013, 02:14 AM
Post #6



Group Icon


Type: Designer




I could use this. happy.gif I don't like it that RPG Maker don't have a spell check so this will help me a lot.
Go to the top of the page
 
+Quote Post
   
???nOBodY???
post Mar 28 2013, 08:09 AM
Post #7


moogles + nightmares + coffee = Scripting Psychopathic Tendency
Group Icon


Type: Coder
Alignment: Chaotic Neutral




Now he just needs to code an importer/injector, so you can inject those changes directly into RMVX itself (though it'd be modifying .rvdata files). biggrin.gif


--------------------
*The Master List Update Project is currently up-to-date with the latest scripts for that dream project!
*By entering the RGSS2/Ruby Scripting section, you are agreeing to abide by The Coder's Creed.

My Scripts
Spoiler:

ACK Script Requests
Spoiler:

Scripts
Stat Change Formulas
GTBS Ziifee's spin menu Submenus
GTBS Weapon Unleash
GTBS Enemy Status
Attack Command Submenu
Jump To (X,Y)
BGM/BGS Fadein
Window_Message - Pop Text
Spell Management Menu
Melee Mastery Management Menu
Ghost List
Save / Autoload
Some Popup v2.9 => v2.91
Scene_StringEntry v1.02
Scene_StringEntry: More Than 24-Character Input
Scene_StringEntry: Scrolling Character Input Window
Scene_StringEntry: Typing Input
MA's Quest Journal - Accept Quest Add-On (internal)
MA's Quest Journal - Accept Quest Add-On (external)
Easy-to-Add Extra Ziifee Spin Commands
Scrolling Battle Message
Non-Differentiating Enemies
Quest Item Drops
(VX) FP Conditional Drops
FFTA World Map HUD bugfix
RSSBS / SSS - Wereforms patch
Death Counterattack
Targetting Extension

My Heart (Resources)
Spoiler:

Projects
Project AMBROSIA
*something generically clever*

Support these:
Spoiler:







Awards:
Spoiler:

Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 20th August 2014 - 07:34 PM

RPGMakerVX.net is an Privacy Policy, Legal.