Author Topic: Extract scripts  (Read 5546 times)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20015
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Extract scripts
« on: June 25, 2009, 01:09:54 AM »
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.

Code: [Select]
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:

Code: [Select]
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.
« Last Edit: June 29, 2009, 10:39:35 AM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline Sally

  • Sallygirl :P
  • Chaos User
  • ******
  • Posts: 1283
  • LV: 12
  • Gender: Female
    • View Profile
Re: Extract scripts
« Reply #1 on: June 25, 2009, 01:38:54 AM »
Yeah i can see why this is usefull, but i like it with many, so i wont use it :P

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: Extract scripts
« Reply #2 on: June 25, 2009, 01:58:33 AM »
Doesnt this in a way backup all of your scripts? I find it really useful

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: Extract scripts
« Reply #3 on: June 29, 2009, 06: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.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20015
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Extract scripts
« Reply #4 on: June 29, 2009, 10: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.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: Extract scripts
« Reply #5 on: June 29, 2009, 10:42:59 AM »
Blizz you're a mind reader!!!