mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Add a script that parses component fields
This commit is contained in:
parent
e3a8d390c7
commit
37cfd514e4
1 changed files with 41 additions and 0 deletions
41
scripts/parse_components.py
Normal file
41
scripts/parse_components.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
import shlex
|
||||
import json
|
||||
|
||||
def parse_component(component):
|
||||
it = iter(component)
|
||||
name = next(it)
|
||||
fields = []
|
||||
for line in it:
|
||||
line = line.strip()
|
||||
if line.startswith("-"):
|
||||
continue
|
||||
typ, name, *range_info, desc = shlex.split(line)
|
||||
fields.append({
|
||||
"field": name,
|
||||
"typ": typ,
|
||||
"desc": desc,
|
||||
})
|
||||
#print(name, typ, desc, range_info)
|
||||
return {
|
||||
"name": name,
|
||||
"fields": fields,
|
||||
}
|
||||
|
||||
|
||||
path = "/home/quant/.local/share/Steam/steamapps/common/Noita/tools_modding/component_documentation.txt"
|
||||
|
||||
components = []
|
||||
current = []
|
||||
for line in open(path):
|
||||
if line == "\n":
|
||||
if current:
|
||||
components.append(current)
|
||||
current = []
|
||||
else:
|
||||
current.append(line)
|
||||
|
||||
assert not current
|
||||
|
||||
parsed = [parse_component(component) for component in components]
|
||||
json.dump(parsed, open("components.json", "w"), indent=None)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue