Skip to content

Instantly share code, notes, and snippets.

@Dobby233Liu
Forked from FiXato/Scripts.rvdata2-exporter.rb
Last active February 16, 2024 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dobby233Liu/73c4499f7b49f8dc3eab8288dc028084 to your computer and use it in GitHub Desktop.
Save Dobby233Liu/73c4499f7b49f8dc3eab8288dc028084 to your computer and use it in GitHub Desktop.
Script to export the scripts inside the Scripts.rxdata data file to Scripts as plain text Ruby files. Deals with the invalid characters that the edgy thing that's Undertale Zero Genocide inserts in its script names.
#! /usr/bin/env ruby
# encoding: utf-8
# Script to export the scripts inside the Scripts.rxdata data file to Scripts as plain text Ruby files.
# Based on FiXato/Scripts.rvdata2-exporter.rb https://gist.github.com/FiXato/5323361
require "fileutils"
require "zlib"
class Exporter
def self.export_scripts
path = File.join("Scripts")
FileUtils.mkdir_p(path)
Marshal.load(File.binread(File.join("Data", "Scripts.rxdata"))).each.with_index do |cont, index|
id, name, code = cont
code = Zlib::Inflate.inflate(code).force_encoding("utf-8")
if id.nil? or code.size == 0
puts "[#{index}] #{id} #{name} -> (empty)"
next
end
newname = File.join(path, "#{name.gsub(/\//, "").gsub(/\\\\/, "").gsub(/\*/, "")}.rb")
puts "[#{index}] ##{id} #{name} -> #{newname}"
File.open(newname, "wb") do |f|
f.write code
end
end
rescue Exception => e
p e
end
end
Exporter.export_scripts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment