Created
March 7, 2014 21:30
-
-
Save TeddyDD/9420578 to your computer and use it in GitHub Desktop.
Updates the KSP science file to a social versions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# scupdate 2 | |
#by TeddyDD | |
#License: MIT: http://opensource.org/licenses/MIT | |
# Remember to check patch to ksp folder!!!! | |
use strict; | |
use warnings; | |
use LWP::Simple; | |
my $url = "https://docs.google.com/document/d/17Xz1yGxpiYroM8BCahs8NjOQI3DTEWl-6BDDoaEmv-E/export?format=txt"; | |
my $dwnl_filename = "ScienceDefs.txt"; | |
getstore($url,$dwnl_filename); | |
my $dwnl_filesize = -s $dwnl_filename; | |
#Path to file in ksp folder | |
my $new_filename = "C:/Program Files (x86)/Steam/SteamApps/common/Kerbal Space Program/GameData/Squad/Resources/ScienceDefs.cfg"; | |
my $new_filesize = -s $new_filename; | |
my $added = ($dwnl_filesize - $new_filesize) /1024; | |
print "Check: \n"; | |
open DOWNLOADED, "<" , $dwnl_filename or die("Can't open downloaded file."); | |
open KSPNOW, "+<" , $new_filename or die("Error with ksp science defs file."); | |
my @new_version = <DOWNLOADED>; | |
my @old_version = <KSPNOW>; | |
if (@new_version == @old_version) { | |
print "You have newest file version"; | |
close KSPNOW; | |
close DOWNLOADED; | |
exit | |
} | |
print "Updating...\n"; | |
close KSPNOW; | |
open KSPNOW, "+>", $new_filename; | |
print KSPNOW @new_version; | |
print "Updated \n"; | |
print "Added $added kb of science logs :)\n"; | |
close KSPNOW; | |
close DOWNLOADED; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment