Rpg Maker Scripts Storing Algorithm for Scripters
#4
I have completed your script; It can now be used to 1. Write scripts from Scripts.rxdata to individual script files and 2. Reconstitute the scripts from the individual scripts saved from the first use.

The resultant Scripts.rxdata is in fact a perfect binary match for the original, sharing the same md5sum and sha512sum. Note, this is only because the dumped scripts were not edited; but, obviously, if you make changes to the script it will affect the output of the final scriptfile. I only state the fact its identical because it proves the process is perfect.
Code:
#!/usr/bin/env ruby
require 'zlib'
def load_data(filename)
  File.open(filename, "rb") { |f|
    obj = Marshal.load(f)
  }
end

def save_data(obj, filename)
  File.open(filename, "wb") { |f|
    Marshal.dump(obj, f)
  }
end

def dump_script(scriptfile, scriptindex)
  script = load_data(scriptfile)
  script.each { |s|
    file = File.open(s.at(1), 'wb')
    file.write(Zlib::Inflate.inflate(s.at(2)))
    file.close
    s.delete_at(2)
    save_data(script, scriptindex)
  }
end
def assemble_scripts(scriptindex, scriptfile)
  index = load_data(scriptindex)
  index.each { |s|
    file = File.readlines(s.at(1))
    s.push(Zlib::Deflate.deflate(file.join))
    save_data(index, scriptfile)
  }
end
Usage:
dissassemble_scripts("Scripts.rxdata", "ScriptIndex.dat") will write out all the scripts in Scripts.rxdata into individual script text files and save an index file as ScriptIndex.dat
assemble_scripts("ScriptIndex.dat", "Scripts.rxdata") will reconstitute the (edited, if so desired) scripts using the index we saved as ScriptIndex.dat and save the reconstituted file as Scripts.rxdata; I've not tested with a file named Scripts.rxdata actually existing, so not sure if it will work (I had deleted the file after disassembly in order to make sure I wasn't simply seeing the original Scripts.rxdata and assuming success)
[Image: cautionary.png]
Reply }


Messages In This Thread
RE: Rpg Maker Scripts Storing Algorithm for Scripters - by hanetzer - 03-15-2014, 01:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Steam on Linux & RPG Maker Series kyonides 0 1,950 02-21-2023, 10:59 PM
Last Post: kyonides
   Install RPG Maker on a Linux KDC 6 14,664 08-29-2019, 03:33 AM
Last Post: KDC
   Installing RPG Maker XP, VX, or VX Ace Under PlayOnLinux: The Complete Guide! hanetzer 5 17,812 05-15-2016, 11:00 PM
Last Post: Francexi
   RPG Maker XP Basics: A tutorial for newbies. Bolt 0 6,084 12-23-2008, 02:11 AM
Last Post: Bolt
   Facesets with no need for scripts! Emily_Konichi 0 3,233 12-07-2008, 04:28 AM
Last Post: Emily_Konichi



Users browsing this thread: 1 Guest(s)