Forked from FiXato/Scripts.rvdata2-exporter.rb
Last active
February 16, 2024 13:52
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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