-
-
Save FiXato/5323361 to your computer and use it in GitHub Desktop.
Script to export the scripts inside the Scripts.rvdata2 data file to Data/exported_scripts as plain text Ruby files.
If you run this script from inside RPG Maker VX Ace, I would suggest creating the Data/exported_scripts folder yourself as RGSS3 doesn't seem to support requiring FileUtils.
Based on HIRATA Yasuyuki / 平田 泰行's rvdata2_dump.rb script:
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.rvdata2 data file to Data/exported_scripts as plain text Ruby files. | |
# If you run this script from inside RPG Maker VX Ace, I would suggest creating the Data/exported_scripts folder yourself | |
# as RGSS3 doesn't seem to support requiring FileUtils. | |
# Based on HIRATA Yasuyuki / 平田 泰行's rvdata2_dump.rb script: https://gist.github.com/hirataya/1853033 | |
begin | |
require 'fileutils' | |
rescue LoadError | |
puts "Can't load fileutils; ensure that the Data/exported_scripts folder has been created" | |
end | |
class Exporter | |
def self.export_scripts | |
path = File.join("Data", "exported_scripts") | |
FileUtils.mkdir_p(path) if defined?(FileUtils) | |
counter = 0 | |
Marshal.load(File.binread(File.join("Data", "Scripts.rvdata2"))).each.with_index do |cont, index| | |
id, name, code = cont | |
code = Zlib::Inflate.inflate(code).force_encoding("utf-8") | |
next if id.nil? | |
if code.size == 0 | |
puts "Skipping [#{index}] #{id} #{name}" | |
next | |
end | |
puts "Exporting [#{index}] ##{id}: #{name} to #{File.join(path, "#{name}.rb")}" | |
File.open(File.join(path, "#{name}.rb"), "wb") do |f| | |
f.puts "# encoding: utf8" | |
f.puts "# [#{index}] #{id}: #{name}" | |
f.write code | |
end | |
counter +=1 | |
end | |
puts "#{counter} files successfully exported." | |
rescue Exception => e | |
p e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to add : require "zlib"