Good your alive
🙂 Hopefully your studies are going well
I figured how to get LFS to scan Troops Battle Event Page however its probably sloppy... extract_page kept throwing an error on list and well I made it work
Spoiler
module LanguageFileSystem TROOP_EVENT_PREFIX = "Troop Events/" #-------------------------------------------------------------------------- # * Extracting the text content of all maps and map events #-------------------------------------------------------------------------- def extract_events... # Extract and convert all common events common_events = load_data("Data/CommonEvents.rvdata2") common_events.each { |ce| extract_page(COMMON_EVENT_PREFIX, ce.id, ce.name, ce, 0, dl_file, db_file) if ce } save_data(common_events, EXTRACTED_DIR_NAME + "/Data/CommonEvents.rvdata2") # Extract and convert all troop events troop_events = load_data("Data/Troops.rvdata2") troop_events.each { |te| next unless te.respond_to?('pages') te.pages.each_with_index { |page, page_id| extract_page(TROOP_EVENT_PREFIX, te.id, te.name, page, page_id, dl_file, db_file) if te } } save_data(troop_events, EXTRACTED_DIR_NAME + "/Data/Troops.rvdata2") ensure dl_file.close db_file.close end end
This code can sort the data, update it with another file, or extract only key entries... scope creep is a pain
It was meant only as an update function however as it rebuilds the file sorting was added and I found only having the key entries helped to figure out what data Google Translate ate... As I questioned some of the sorting techniques this creates a new file where a real person can compare with the original using WinMerge or equivalent.
Usage:Script Call
LanguageFileSystem.update_rvtext_file(RVTEXT File To Update, Update File (Nil To Exclude), Sorted (False To Skip), OnlyKeys (False To Include All Data), TrueUpdate (True To Update Original RVTEXT File), SuppressMSG (False To Show Message))
LanguageFileSystem.update_rvtext_file("DatabaseTextEnglish.rvtext", "TranslationUpdatesEnglish.txt", true, false, false, false)
Generates "DatabaseTextEnglish.rvtext_updated" with matching entries from "TranslationUpdatesEnglish.txt" updated and sorted alphanumerically containing all data along with a backup of the original
LanguageFileSystem.update_rvtext_file("DatabaseTextEnglish.rvtext", "TranslationUpdatesEnglish.txt", true, false, true, false)
Generates "DatabaseTextEnglish.rvtext" with matching entries from "TranslationUpdatesEnglish.txt" updated and sorted alphanumerically containing all data along with a backup of the original
LanguageFileSystem.update_rvtext_file("DatabaseTextEnglish.rvtext", nil, true, true, false, true)
Generates "DatabaseTextEnglish.rvtext_onlykeys" sorted alphanumerically containing only key entries along with a backup of the original while not displaying the end message
Update File Must Contain Keys From Main RVTEXT File. It wasn't designed to append data though thinking on it that might be a nice feature...
Spoiler
Code:
module LanguageFileSystem... #-------------------------------------------------------------------------- # * Update a rvtext file with an update file, sort it, or only extract keys #-------------------------------------------------------------------------- def self.update_rvtext_file(filename2, filename1 = nil, sorted = true, onlykeys = false, trueupdate = true, suppressmsg = false) a1 = [] # Used In Update From filename1 a2 = [] # Used For RVTEXT filename2 a3 = [] # Used For RVTEXT Update Of filename2 versioncheck_database_file(filename2) if filename2.start_with?("Database") if filename1 != nil # Update Provided File.open(filename1) { |f| # Read Update File line_name = nil line = "" f.each_line { |l| if m = STRING_ID.match(l) if !l.start_with?("<<face:") && !l.start_with?("<<position:") && !l.start_with?("<<background:") && !l.start_with?("<<scroll_speed:") && !l.start_with?("<<no_fast") a1 << [line_name, line.rstrip] if line_name line_name = m[1] line = "" else line += l end else line += l end } a1 << [line_name, line.rstrip] if line_name } end File.open(filename2) { |f| # Read RVTEXT File line_name = nil line = "" f.each_line { |l| if m = STRING_ID.match(l) if !l.start_with?("<<face:") && !l.start_with?("<<position:") && !l.start_with?("<<background:") && !l.start_with?("<<scroll_speed:") && !l.start_with?("<<no_fast") a2 << [line_name, line.rstrip] if line_name line_name = m[1] line = "" else line += l end else line += l end } a2 << [line_name, line.rstrip] if line_name } if filename1 != nil # Update Provided #Search Update Matched Entries a1.each {|x| a2[a2.index(a2.detect{|aa| aa.include?(x[0])})][1] = x[1] if a2.index(a2.detect{|aa| aa.include?(x[0])}) != nil } a1 = [] #It has lived a good life end if sorted #Sort Entries # maps/ a3 += a2.select {|x| x[0].start_with?("maps/")}.sort_by{|x| s1 = x[0].split('/') s1[1] = s1[1].rjust(7, "0") s1 = s1.join("/") } # actors/ a3 += a2.select {|x| x[0].start_with?("actors/")}.sort_by{|x| s1 = x[0].split('/') s1[1] = s1[1].rjust(7, "0") s1 = s1.join("/") } # classes/ a3 += a2.select {|x| x[0].start_with?("classes/")}.sort_by{|x| s1 = x[0].split('/') s1[1] = s1[1].rjust(7, "0") s1 = s1.join("/") } # skills/ a3 += a2.select {|x| x[0].start_with?("skills/")}.sort_by{|x| s1 = x[0].split('/') s1[1] = s1[1].rjust(7, "0") s1 = s1.join("/") } # items/ a3 += a2.select {|x| x[0].start_with?("items/")}.sort_by{|x| s1 = x[0].split('/') s1[1] = s1[1].rjust(7, "0") s1 = s1.join("/") } # weapons/ a3 += a2.select {|x| x[0].start_with?("weapons/")}.sort_by{|x| s1 = x[0].split('/') s1[1] = s1[1].rjust(7, "0") s1 = s1.join("/") } # armors/ a3 += a2.select {|x| x[0].start_with?("armors/")}.sort_by{|x| s1 = x[0].split('/') s1[1] = s1[1].rjust(7, "0") s1 = s1.join("/") } # enemies/ a3 += a2.select {|x| x[0].start_with?("enemies/")}.sort_by{|x| s1 = x[0].split('/') s1[1] = s1[1].rjust(7, "0") s1 = s1.join("/") } # states/ a3 += a2.select {|x| x[0].start_with?("states/")}.sort_by{|x| s1 = x[0].split('/') s1[1] = s1[1].rjust(7, "0") s1 = s1.join("/") } # system/ a3 += a2.select {|x| x[0].start_with?("system/")}.sort_by(&:first) # types/ a3 += a2.select {|x| x[0].start_with?("types/")}.sort_by(&:first) # terms/ a3 += a2.select {|x| x[0].start_with?("terms/")}.sort_by(&:first) # constants/Vocab/ a3 += a2.select {|x| x[0].start_with?("constants/Vocab/")}.sort_by(&:first) # All Other Events a3 += a2.select {|x| x[0].include?("/Page ") && !x[0].start_with?("Common Events/") && !x[0].start_with?("Troop Events/")}.sort_by{|oe| s1 = oe[0].split(':') s2 = s1[1].split('/') s2[0] = s2[0].rjust(7, "0") s1[1] = s2.join('/') s1 = s1.join(":") } # Common Events/ a3 += a2.select {|x| x[0].start_with?("Common Events/")}.sort_by{|ce| s1 = ce[0].split('/') s2 = s1[1].split(':') s2[0] = s2[0].rjust(7, "0") s1[1] = s2.join(':') s1 = s1.join("/") } # Troop Events/ a3 += a2.select {|x| x[0].start_with?("Troop Events/")}.sort_by{|te| s1 = te[0].split('/') s2 = s1[1].split(':') s2[0] = s2[0].rjust(7, "0") s1[1] = s2.join(':') s1 = s1.join("/") } else a3 = a2 # Yes I'm lazy end a2 = [] #It has lived a good life header = nil content = nil File.open(filename2) { |f| header, sep, content = f.read.partition("\n") } # Backup Old Version File.open(filename2 + "_backup", "w") { |backup| backup.write(header+"\n") backup.write(content) } # Write Updated Version if onlykeys addition = "_onlykeys" else addition = "_updated" end addition = "" if trueupdate && !onlykeys File.open(filename2+addition, "w") { |f| f.write(header+"\n") if !header.include?("<<") f.write("\n") if header.include?("<<") f.write("\n") if header.include?("# LFS DATABASE VERSION") a3.each {|x| f.write("<<"+x[0]+">>\n") if !onlykeys f.write(x[1]+"\n\n") if !x[1].empty? end } } if !suppressmsg msgbox "RVTEXT has been updated.\n" + "The updated file was renamed to '#{filename2}#{addition}'\n" + "A backup file was renamed to '#{filename2}_backup'" end end