vinylgauntlet/assets/collect.py
type-two 9a42e0eaf8 Step 7: wire FLUX sprites into the game
Chroma-key magenta -> alpha, autocrop, downscale (assets/process_sprites.py ->
public/sprites/). GameScene loads image textures instead of drawing primitives:
tiled darkened floor, crate walls, digger/poser/nerd/sound-guy/booth/pickup
sprites. Bodies sized under the 32px sprites so corridors still fit. Mechanics
verified unchanged (combat, trainspot, level flow).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 23:39:40 +10:00

34 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Copy finished FLUX assets out of MODELBEAST into assets/generated/<name>.png.
Reads queue.lock.json (job_id/name/seed written by enqueue.py), finds each
generated image in the MB asset store by its seed-based filename, and copies it
in under the friendly asset name. Run after the MB jobs finish.
/opt/homebrew/bin/uv run python assets/collect.py
"""
import json, sys, shutil
from pathlib import Path
MB = Path.home() / "MODELBEAST"
sys.path.insert(0, str(MB))
import server.db as db # noqa: E402
HERE = Path(__file__).resolve().parent
lock = json.loads((HERE / "queue.lock.json").read_text())
outdir = HERE / "generated"
outdir.mkdir(exist_ok=True)
con = db.connect()
done = missing = 0
for it in lock:
fname = f"flux_flux2-klein-4b_s{it['seed']}.png"
row = con.execute("SELECT path FROM assets WHERE name=? ORDER BY created_at DESC LIMIT 1", (fname,)).fetchone()
if row and Path(row["path"]).exists():
shutil.copy(row["path"], outdir / f"{it['name']}.png")
done += 1
else:
print(f" not ready: {it['name']}")
missing += 1
print(f"collected {done}/{len(lock)} into {outdir}" + (f" ({missing} not ready)" if missing else ""))