-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshit_db_json_to_folder.py
More file actions
105 lines (94 loc) · 2.29 KB
/
shit_db_json_to_folder.py
File metadata and controls
105 lines (94 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import json
import os
if not os.path.isdir("new"):
os.makedirs("new")
with open('_.json') as f:
asdf = json.load(f)
"""
{
"id": 1,
"map": "bhop_eazy_v2",
"type": 0,
"corner1_x": -64,
"corner1_y": -192,
"corner1_z": 49.031,
"corner2_x": 256,
"corner2_y": 192,
"corner2_z": 176.031,
"destination_x": 0,
"destination_y": 0,
"destination_z": 0,
"track": 0,
"flags": 0,
"data": 0,
"prebuilt": null,
"form": null,
"target": null
},
"""
def FillBoxMinMax(a, b):
for i in range(3):
y,u = a[i],b[i]
a[i] = float(min(y,u))
b[i] = float(max(y,u))
typesss = [
"start",
"end",
"respawn",
"stop",
"slay",
"freestyle",
"customspeedlimit",
"teleport",
"customspawn",
"easybhop",
"slide",
"airaccel",
"stage",
"notimergravity",
"gravity",
"speedmod"
]
d = {}
for row in asdf["rows"]:
mapname = row["map"].lower()
if not mapname in d:
d[mapname] = []
del row["map"]
if "prebuilt" in row: del row["prebuilt"]
if "form" in row: del row["form"]
if "target" in row: del row["target"]
## what a mess.... lmao
row["point_a"] = []
row["point_a"].append(row["corner1_x"] or 0.0)
row["point_a"].append(row["corner1_y"] or 0.0)
row["point_a"].append(row["corner1_z"] or 0.0)
del row["corner1_x"]
del row["corner1_y"]
del row["corner1_z"]
row["point_b"] = []
row["point_b"].append(row["corner2_x"] or 0.0)
row["point_b"].append(row["corner2_y"] or 0.0)
row["point_b"].append(row["corner2_z"] or 0.0)
del row["corner2_x"]
del row["corner2_y"]
del row["corner2_z"]
row["dest"] = []
row["dest"].append(float(row["destination_x"]))
row["dest"].append(float(row["destination_y"]))
row["dest"].append(float(row["destination_z"]))
del row["destination_x"]
del row["destination_y"]
del row["destination_z"]
row["type"] = typesss[row["type"]]
if row["dest"][0] == 0 and row["dest"][1] == 0 and row["dest"][2] == 0:
del row["dest"]
if row["flags"] == 0:
del row["flags"]
if row["data"] == 0:
del row["data"]
FillBoxMinMax(row["point_a"], row["point_b"])
d[mapname].append(row)
for map in d:
with open("new/" + map + ".json", "w") as f:
json.dump(d[map], f, sort_keys=True, indent='\t', separators=(',', ': '))