Last active
August 29, 2015 14:20
-
-
Save KazKoboDev/e4c6c8ee83482a696b1c to your computer and use it in GitHub Desktop.
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
# How to use this file | |
# 1) Run gem install 'json' on the command line to install the json dependency | |
# 2) Place this file in your Starbound linux32 or linux64 directory | |
# 3) Run it on the command line using 'ruby read_contexts.rb coord' without qoutes (make sure you're in the linux32/linux64 directory) | |
require 'fileutils' | |
require 'json' # gem install 'json' | |
abort("Only 1 arguement may be specified") if ARGV.length > 1 | |
unless ARGV.empty? | |
ARGV.each do |arg| | |
if m = /(\-?\d+)\_(\-?\d+)\_(\-?\d+)\_(\d{1,2})\_(\d{1,2})/.match(arg) | |
@coord = {"planet" => m[4].to_i, "location" => [m[1].to_i, m[2].to_i, m[3].to_i], "satellite" => m[5].to_i} | |
else | |
abort("Coordinate must be in x_y_z_planet_satellite format to be valid, put 0 if no satellite") | |
end | |
end | |
end | |
Dir.glob("#{File.expand_path('..')}/giraffe_storage/universe/*.clientcontext").each do |file| | |
system("./dump_versioned_json #{file} context_dump.json") | |
dump = JSON.parse(File.open('context_dump.json').read) | |
if @coord.nil? | |
puts dump # Just print output | |
else | |
if dump["__content"]["celestialLog"]["currentWorld"] == @coord | |
FileUtils.rm(file) | |
end | |
end | |
end | |
FileUtils.rm("context_dump.json") # Clean up leftover |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment