|
13 | 13 | sys.path.append(new_home)
|
14 | 14 |
|
15 | 15 | from worlds.subnautica.Locations import Vector, location_table
|
16 |
| - from worlds.subnautica.Items import item_table, group_items |
| 16 | + from worlds.subnautica.Items import item_table, group_items, items_by_type |
17 | 17 | from NetUtils import encode
|
18 | 18 |
|
| 19 | + export_folder = os.path.join(new_home, "Subnautica Export") |
| 20 | + os.makedirs(export_folder, exist_ok=True) |
| 21 | + |
| 22 | + def in_export_folder(path: str) -> str: |
| 23 | + return os.path.join(export_folder, path) |
| 24 | + |
19 | 25 | payload = {location_id: location_data["position"] for location_id, location_data in location_table.items()}
|
20 |
| - with open("locations.json", "w") as f: |
| 26 | + with open(in_export_folder("locations.json"), "w") as f: |
21 | 27 | json.dump(payload, f)
|
22 | 28 |
|
23 | 29 | # copy-paste from Rules
|
@@ -49,17 +55,22 @@ def far_away(pos: Vector):
|
49 | 55 | "751": [location_id for location_id, location_data
|
50 | 56 | in location_table.items() if far_away(location_data["position"])],
|
51 | 57 | }
|
52 |
| - with open("logic.json", "w") as f: |
| 58 | + with open(in_export_folder("logic.json"), "w") as f: |
53 | 59 | json.dump(payload, f)
|
54 | 60 |
|
55 |
| - itemcount = sum(item_data["count"] for item_data in item_table.values()) |
| 61 | + itemcount = sum(item_data.count for item_data in item_table.values()) |
56 | 62 | assert itemcount == len(location_table), f"{itemcount} != {len(location_table)}"
|
57 |
| - payload = {item_id: item_data["tech_type"] for item_id, item_data in item_table.items()} |
| 63 | + payload = {item_id: item_data.tech_type for item_id, item_data in item_table.items()} |
58 | 64 | import json
|
59 | 65 |
|
60 |
| - with open("items.json", "w") as f: |
| 66 | + with open(in_export_folder("items.json"), "w") as f: |
61 | 67 | json.dump(payload, f)
|
62 |
| - with open("group_items.json", "w") as f: |
| 68 | + |
| 69 | + with open(in_export_folder("group_items.json"), "w") as f: |
| 70 | + # encode to convert set to list |
63 | 71 | f.write(encode(group_items))
|
64 | 72 |
|
65 |
| - print(f"Subnautica exports dumped to {new_home}") |
| 73 | + with open(in_export_folder("item_types.json"), "w") as f: |
| 74 | + json.dump(items_by_type, f) |
| 75 | + |
| 76 | + print(f"Subnautica exports dumped to {in_export_folder('')}") |
0 commit comments