Created
July 23, 2020 11:51
-
-
Save noobanidus/7948054bfffbdaf3afd9ce6152112d09 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env python | |
import os, sys, json | |
def main (args): | |
file_input = None | |
if len(args) == 3 and "pyython" in args[0].lower(): | |
if "packs" in args[1].lower(): | |
file_input = args[2] | |
elif len(args) == 2 and "packs" in args[0].lower(): | |
file_input = args[1] | |
if file_input == None or not file_input.lower().endswith("dungeondraft_map"): | |
print("Usage: python3 packs.py file.dungeondraft_map") | |
if not os.path.exists(file_input): | |
print("Usage: python3 packs.py file.dungeondraft_map") | |
print("File does not exist: " + file_input) | |
with open(file_input) as o: | |
data = json.load(o) | |
packs = set() | |
for level, values in data["world"]["levels"].items(): | |
for obj in values["objects"]: | |
if obj["texture"].startswith("res://packs/"): | |
packs.add(obj["texture"].split("/")[3]) | |
pack_names = set() | |
for pack_id in packs: | |
for pack_info in data["header"]["asset_manifest"]: | |
if pack_id.lower() == pack_info["id"].lower(): | |
pack_names.add(pack_info["name"]) | |
print("Asset packs used in the map '" + file_input + "':") | |
for pack_name in pack_names: | |
print(" - " + pack_name) | |
if __name__=="__main__": | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment