Extract scripts

Started by Blizzard, June 24, 2009, 07:09:54 pm

Previous topic - Next topic

Blizzard

June 24, 2009, 07:09:54 pm Last Edit: June 29, 2009, 04:39:35 am by Blizzard
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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Sally

Yeah i can see why this is usefull, but i like it with many, so i wont use it :P

G_G

Doesnt this in a way backup all of your scripts? I find it really useful

G_G

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.

Blizzard

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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Blizz you're a mind reader!!!