Timer overhaul: update tests

This commit is contained in:
John McCardle 2026-01-03 22:44:53 -05:00
commit cec76b63dc
78 changed files with 521 additions and 495 deletions

View file

@ -114,7 +114,7 @@ class DemoRunner:
self.current_index = 0
self.render_wait = 0
def screenshot_cycle(runtime):
def screenshot_cycle(timer, runtime):
if self.render_wait == 0:
# Set scene and wait for render
if self.current_index >= len(self.screens):
@ -139,7 +139,7 @@ class DemoRunner:
print("Done!")
sys.exit(0)
mcrfpy.setTimer("screenshot", screenshot_cycle, 50)
self.screenshot_timer = mcrfpy.Timer("screenshot", screenshot_cycle, 50)
def run_interactive(self):
"""Run in interactive mode with menu."""

View file

@ -126,9 +126,10 @@ def setup_scene():
patrol_demo.on_key = on_keypress
# Start patrol timer
mcrfpy.setTimer("patrol", patrol_step, move_timer_ms)
global patrol_timer
patrol_timer = mcrfpy.Timer("patrol", patrol_step, move_timer_ms)
def patrol_step(runtime):
def patrol_step(timer, runtime):
"""Move entity one step toward current waypoint"""
global current_waypoint, patrol_paused

View file

@ -784,12 +784,12 @@ def run_demo():
demo_state = create_demo_scene()
# Set up exit timer for headless testing
def check_exit(dt):
def check_exit(timer, dt):
# In headless mode, exit after a short delay
# In interactive mode, this won't trigger
pass
# mcrfpy.setTimer("demo_check", check_exit, 100)
# check_exit_timer = mcrfpy.Timer("demo_check", check_exit, 100)
# Run if executed directly
@ -801,8 +801,8 @@ if __name__ == "__main__":
# If --screenshot flag, take a screenshot and exit
if "--screenshot" in sys.argv or len(sys.argv) > 1:
def take_screenshot(dt):
def take_screenshot(timer, dt):
automation.screenshot("focus_demo_screenshot.png")
print("Screenshot saved: focus_demo_screenshot.png")
sys.exit(0)
mcrfpy.setTimer("screenshot", take_screenshot, 200)
screenshot_timer = mcrfpy.Timer("screenshot", take_screenshot, 200, once=True)