Skip to content

Commit 660e6aa

Browse files
committed
export some scripts
1 parent 699a3cd commit 660e6aa

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

frontend/scripts/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Some scripts I used for converting data. Should be run in `frontend/public`
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import json
2+
3+
# https://github.com/nottldr/outer-wilds-ventures/blob/main/src/data/assets/library.json
4+
with open('library_orig.json') as f:
5+
entries = json.load(f)['entries']
6+
7+
coords = dict()
8+
alt_sprites = dict()
9+
for e in entries:
10+
i = e['id']
11+
12+
pos = e['cardPosition']
13+
coords[i] = [pos['x'], pos['y']]
14+
15+
if e.get('altSpritePath') != None:
16+
alt_sprites[i] = e['altSpritePath'].replace('.png', '')
17+
18+
with open('coordinates.json', 'w') as f:
19+
json.dump(coords, f, sort_keys=True, indent=2)
20+
21+
with open('alt_sprites.json', 'w') as f:
22+
json.dump(alt_sprites, f, sort_keys=True, indent=2)

frontend/scripts/extract_save_keys.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import json
2+
3+
# game's save file
4+
with open('test-save.json') as f:
5+
facts = json.load(f)['shipLogFactSaves']
6+
7+
with open('save_keys.json', 'w') as f:
8+
json.dump(sorted(list(facts.keys())), f, indent=2)

frontend/scripts/load_parents.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import json
2+
3+
# https://github.com/nottldr/outer-wilds-ventures/blob/main/src/data/assets/entries.json
4+
with open('entries_orig.json') as f:
5+
entries = json.load(f)
6+
7+
parents = dict()
8+
for astro in entries:
9+
for e in astro['entries']:
10+
if "parentId" in e:
11+
parents[e['id']] = e['parentId']
12+
13+
with open('parents.json', 'w') as f:
14+
json.dump(parents, f, sort_keys=True, indent=2)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import glob
2+
import json
3+
import os
4+
5+
with open('coordinates.json') as f:
6+
entries = json.load(f)
7+
8+
ids = set(entries.keys())
9+
used = set()
10+
for path in glob.glob('sprites/*.jpg'):
11+
i = path.removeprefix('sprites/').removesuffix('.jpg')
12+
if i not in ids:
13+
os.remove(path)

0 commit comments

Comments
 (0)