Rpg Maker Scripts Storing Algorithm for Scripters
#1
Hello. I'm explained the RMXP/VX/VXA scripts.rxdata structure and want to explain it to all.

It has an array structure.

Firstly, it's unique script ID. (??) (I wanna check more..)
Secondly, it's script name.
Thirdly, it's Zlib compressed script source.

For Example :

Script.rxdata =
[
[23333439, "*First script", Zlib["source_code_of_script1"]],
[39283232, "*Second script", Zlib["source_code_of_script2"]]
]

The algorithm is not fully checked. It's works with unpacking. I'm not test it with packing too.
If you want to build scripts.rxdata use 0 as first argument :)
The second and third is 100 % checked.
I must check the first unique ID generation :)
I'll add it so soon.

Nice working.

Some practice :

Content Hidden

Nice working.
Reply }
#2
As always this is an entirely too useful script; I've used it to load the entire Scripts.rxdat into my irb session. As a monument to the eternity of the internet here is the script:
Code:
require 'zlib'
def save_data(obj, filename)
  File.open(filename, "wb") { |f|
    Marshal.dump(obj, f)
  }
end

def load_data(filename)
  File.open(filename, "rb") { |f|
    obj = Marshal.load(f)
  }
end
script = load_data("Data/Scripts.rxdata")
script.each {|s| TOPLEVEL_BINDING.eval(Zlib::Inflate.inflate(s.at(2)))  }
Something along these lines must be embedded into the RGSS dll or Game.exe; This is what starts the actual Ruby Game Process.
[Image: cautionary.png]
Reply }
#3
Heyo!
Been fiddling with this for the sake of the ReGaL engine, and made a bit of what I'd call an improvement to it; instead of one large text file, It now dumps to individual files for each script; my code (thanks for the start Narzew):
Code:
def save_script(scriptfile='Data/Scripts.rxdata')
  script = load_data(scriptfile)
  script.each {|s|
    file = File.open(s.at(1), 'wb')
    file.write(Zlib::Inflate.inflate(s.at(2)))
    file.close
  }
end
Next I'll see about writing a script to reconstitute the individual files into the Scripts.rxdata file
[Image: cautionary.png]
Reply }
#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 }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Steam on Linux & RPG Maker Series kyonides 0 1,960 02-21-2023, 10:59 PM
Last Post: kyonides
   Install RPG Maker on a Linux KDC 6 14,723 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,867 05-15-2016, 11:00 PM
Last Post: Francexi
   RPG Maker XP Basics: A tutorial for newbies. Bolt 0 6,091 12-23-2008, 02:11 AM
Last Post: Bolt
   Facesets with no need for scripts! Emily_Konichi 0 3,242 12-07-2008, 04:28 AM
Last Post: Emily_Konichi



Users browsing this thread: 1 Guest(s)