Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: Blizzard on June 24, 2009, 07:09:54 pm

Title: Extract scripts
Post by: Blizzard on June 24, 2009, 07:09:54 pm
I don't know how useful it is for some people, but it helps me quickly compile the full RMX-OS from over 20 script slots with just one click so I thought I should share it.

file = File.open('./Data/Scripts.rxdata', 'r')
scripts = Marshal.load(file)
file.close
file = File.open('./Scripts.txt', 'w')
scripts.each {|script| file.write((Zlib::Inflate.inflate(script[2]) + "\n").gsub("\r") {''})}
file.close
exit


This one will save each script in a separate file:

file = File.open('./Data/Scripts.rxdata', 'r')
scripts = Marshal.load(file)
file.close
scripts.each {|script|
  begin
    raise if script[1] == ''
    file = File.open("./#{script[1]}.txt", 'w')
  rescue
    file = File.open("./Script #{script[0]}.txt", 'w')
  end
  file.write((Zlib::Inflate.inflate(script[2]) + "\n").gsub("\r") {''})
  file.close
}
exit


Just put it anywhere in your scripts and run the game. Don't forget to remove it from your scripts again before running the game again.
Title: Re: Extract scripts
Post by: Sally on June 24, 2009, 07:38:54 pm
Yeah i can see why this is usefull, but i like it with many, so i wont use it :P
Title: Re: Extract scripts
Post by: G_G on June 24, 2009, 07:58:33 pm
Doesnt this in a way backup all of your scripts? I find it really useful
Title: Re: Extract scripts
Post by: G_G on June 29, 2009, 12:42:43 am
Is it possible to make it extract each script into its own text file? Using it like this

Script 1
Script 2

or maybe even use the scripts name?

So it names it
Game_Temp
Game_System
etc.
Title: Re: Extract scripts
Post by: Blizzard on June 29, 2009, 04:39:45 am
I knew somebody was going to ask this earlier or later. I put it in the first post.
Since it's possible to name a script using characters that are forbidden in filenames, I had to add a little safety mechanism which will name the files using their ID.
Title: Re: Extract scripts
Post by: G_G on June 29, 2009, 04:42:59 am
Blizz you're a mind reader!!!