Created
July 23, 2020 01:44
-
-
Save noobanidus/14d792e3d7fc800df70db076db2a1a3a 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