GubiD 62 Posted February 26, 2013 (edited) Export Messages to File Version: 1.0Author: GubiDDate: Feb 25, 2013 DescriptionThis script grants you the ability to export the message text from every single message box in your game. This is helpful for many reasons. Spell check Grammar check Does it flow well? ScreenshotsThere is nothing to really screenshot??Instructions Place this script in your project anywhere above main. At the top of the script, set ENABLED = true At next game launch all the messages within will be exported to MAP folders with EVENT.txt files for each event with messaging. If no message text was found, then no file is created. Script #------------------------------------------------------------------ # Object #------------------------------------------------------------------ class Object def string? return false end end #----------------------------------------------------------------- # String #------------------------------------------------------------------ class String def string? true end end #------------------------------------------------------------------ module Export_Messages #------------------------------------------------------------------ # Enabled - When true, data will export. Otherwise no. #------------------------------------------------------------------ ENABLED = false #------------------------------------------------------------------ # Maps File - File in which contains the map information #------------------------------------------------------------------ MapsFile = "./Data/MapInfos.rvdata2" #------------------------------------------------------------------ # Event Messages Folder #------------------------------------------------------------------ EVENT_MESSAGES_FOLDER = "./Messages/" #------------------------------------------------------------------ # Make Folder Name (from map ID and MAP) #------------------------------------------------------------------ def self.make_folder_name(id, map) return sprintf("%03d_%s", id, map.name); end #------------------------------------------------------------------ # Export Messages #------------------------------------------------------------------ # This exports all the events messaging in the game on every map #------------------------------------------------------------------ def self.export_messages maps = load_data(MapsFile) if !Dir.exist?(EVENT_MESSAGES_FOLDER) Dir.mkdir(EVENT_MESSAGES_FOLDER) end for id in 1...maps.size+1 mapFile = sprintf("Data/Map%03d.rvdata2", id) mapInfo = maps[id] map = load_data(mapFile) rescue next foldername = EVENT_MESSAGES_FOLDER + make_folder_name(id, mapInfo) if !Dir.exist?(foldername) Dir.mkdir(foldername) end for event_id in map.events.keys event = map.events[event_id] for i in 0...event.pages.size filename = sprintf("%s/%03d_%s_%02d.txt", foldername, event_id, event.name, i+1) if File.exist?(filename) File.delete(filename) end file = File.new(filename, 'a') #open file in append mode file.write(sprintf("%03d %s Page_%02d", event_id, event.name, i+1)) write_linebreak(file) page = event.pages event_string_data = build_event_string_data(page) file.write(event_string_data) file.close if event_string_data == "" File.delete(filename) end end end end print "Finished Exporting messages to file\n" end #------------------------------------------------------------------ # Construct message string data #------------------------------------------------------------------ def self.build_event_string_data(page) save_string = [] @index = 0 #------------------------------------------------------------------ # Walk list and check each item. # Since choices already sort items for us, no additional sort is needed. #------------------------------------------------------------------ while page.list[@index] != nil event_data = page.list[@index] indent = "\t " * event_data.indent if ([101, 401].include?(event_data.code)) s = event_data.parameters[0] save_string << indent + "[MESSAGE]" + s unless s == "" elsif [402].include?(event_data.code) for s in event_data.parameters save_string << indent + "[CHOICE]" + s if s.string? end elsif [404].include?(event_data.code) save_string << indent + "[END_CHOICE]" end @index += 1 end return save_string.join("\n") end #------------------------------------------------------------------ # Write Linebreak #------------------------------------------------------------------ def self.write_linebreak(file) file.write("\r\n") end if ENABLED export_messages end end Credit No credit is needed unless you want to.Thanks Feldherren for requesting itSupportPost in this thread or PM me.Known Compatibility IssuesI am unaware of any scripts it doesn't work with; if you find any, post in this thread.DemoN/AAuthor's NotesI created this script because Feldherren requested the ability to dump all messages to file quickly. Not only for spell checking but other checks as well. Terms of UseNon-Commercial or Commercial free. Have fun and enjoy it. Edited February 26, 2013 by GubiD 8 CT Bolt, JmT, randomstranger and 5 others reacted to this Share this post Link to post Share on other sites
Erthia 1 Posted February 26, 2013 Great work, this will be extremely useful. Share this post Link to post Share on other sites
CT Bolt 23 Posted February 26, 2013 Wow, I would have never even thought of such a thing. Brilliant, simply brilliant. I will surely use this for checking spelling & grammar. Share this post Link to post Share on other sites
kory_toombs 0 Posted December 30, 2017 Game crashes on start up if you enable. Share this post Link to post Share on other sites
roninator2 188 Posted December 31, 2017 (edited) Possibly because there is a part missing. Line 69 page = event.pages page = event.pages[i] Just tried it myself. Works great. Edited December 31, 2017 by roninator2 Needed to code box Share this post Link to post Share on other sites