diff options
author | David Thompson <dthompson2@worcester.edu> | 2016-03-31 07:18:05 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2016-03-31 07:18:05 -0400 |
commit | 4586c151ae3dc6c713cd9092cedacb882db15e00 (patch) | |
tree | cdc6e0806c2870343be92e9d2f591133ca035660 | |
parent | 1977826a9f84b9e7d4db73bf2471a33d54e5061f (diff) |
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.
-rw-r--r-- | sly/live-reload.scm | 7 |
1 files 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. |