55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
import json
|
|
import os
|
|
|
|
PROJECT_ROOT = "/Users/davidkotnik/repos/novafarma"
|
|
LDTK_FILE = os.path.join(PROJECT_ROOT, "AutoLayers_2_stamps.ldtk")
|
|
# We will use the path found by the previous command, but for now I'll use a placeholder logic
|
|
# or just rely on the 'find' command output in my thought process to hardcode if needed,
|
|
# but better to read it dynamically or just correct the known folder structure issue.
|
|
|
|
# Hardcoding the fix because I know the issue: 'godot/characters/KAI/' needs to be 'godot/characters/KAI/kai/' probably.
|
|
# But I will wait for the `find` output to be 100% sure in a real scenario?
|
|
# No, I can write the script to search.
|
|
|
|
def main():
|
|
# Find a valid Kai image
|
|
kai_img = None
|
|
for root, dirs, files in os.walk(os.path.join(PROJECT_ROOT, "godot/characters/KAI")):
|
|
for f in files:
|
|
if f.endswith(".png") and "walk" in f:
|
|
kai_img = os.path.join(root, f)
|
|
break
|
|
if kai_img: break
|
|
|
|
if not kai_img:
|
|
# Fallback to any png
|
|
for root, dirs, files in os.walk(os.path.join(PROJECT_ROOT, "godot/characters/KAI")):
|
|
for f in files:
|
|
if f.endswith(".png"):
|
|
kai_img = os.path.join(root, f)
|
|
break
|
|
if kai_img: break
|
|
|
|
if kai_img:
|
|
rel_path = os.path.relpath(kai_img, PROJECT_ROOT)
|
|
print(f"Found Kai image: {rel_path}")
|
|
|
|
with open(LDTK_FILE, 'r') as f:
|
|
data = json.load(f)
|
|
|
|
updated = False
|
|
for ts in data['defs']['tilesets']:
|
|
if ts['identifier'] == "TS_Kai":
|
|
ts['relPath'] = rel_path
|
|
updated = True
|
|
|
|
if updated:
|
|
with open(LDTK_FILE, 'w') as f:
|
|
json.dump(data, f, indent=2)
|
|
print("LDtk updated with correct Kai path!")
|
|
else:
|
|
print("Could not find any Kai image!")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|