From 4586c151ae3dc6c713cd9092cedacb882db15e00 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 31 Mar 2016 07:18:05 -0400 Subject: live-reload: Do not load asset until the game has started. * sly/live-reload.scm (watch-files): Wait for the game to start before loading the asset for the first time. --- sly/live-reload.scm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sly/live-reload.scm b/sly/live-reload.scm index bb828e8..55e89d7 100644 --- a/sly/live-reload.scm +++ b/sly/live-reload.scm @@ -43,14 +43,15 @@ polled for changes, defaulting to two seconds." (and (every file-exists? files) (reduce max 0 (map current-mtime files)))) - (let ((asset (make-signal (thunk)))) + (let ((asset (make-signal #f))) (coroutine + ;; Wait for the game to start. + (while (not (signal-ref game-started?)) (wait 1)) + (signal-set! asset (thunk)) ; initialize! (let loop ((last-mtime (max-current-mtime))) (wait polling-interval) (let ((mtime (max-current-mtime))) (when (cond - ;; Game hasn't started yet. - ((not (signal-ref game-started?)) #f) ;; Some files do not exist anymore, can't reload. ((not mtime) #f) ;; Some files were missing, but are back now. -- cgit v1.2.3