McRogueFace/tools/capture_audio_synth_header.py
John McCardle 17664ba741 Fix capture_audio_synth_header.py for headless --exec mode
Timers never fire in --headless --exec mode (the game loop runs but
does not process the timer queue without explicit step() calls).
Replace the Timer-based screenshot with a step() loop that advances
the engine 30 ticks at 10ms each before calling automation.screenshot().

This fix was discovered and applied as part of blog post 0033 publication
(Kanboard #209 / #345).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 23:25:17 -04:00

17 lines
482 B
Python

import mcrfpy
from mcrfpy import automation
import runpy, sys, pathlib
OUT = sys.argv[1] if len(sys.argv) > 1 else "image00.png"
demo_path = (pathlib.Path(__file__).resolve().parent.parent /
"tests" / "demo" / "audio_synth_demo.py")
runpy.run_path(str(demo_path), run_name="__demo__")
# In headless --exec mode timers never fire; use step() to advance the loop.
for _ in range(30):
mcrfpy.step(0.01)
automation.screenshot(OUT)
print(f"Wrote {OUT}")
sys.exit(0)