summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-03-31 07:18:05 -0400
committerDavid Thompson <dthompson2@worcester.edu>2016-03-31 07:18:05 -0400
commit4586c151ae3dc6c713cd9092cedacb882db15e00 (patch)
treecdc6e0806c2870343be92e9d2f591133ca035660
parent1977826a9f84b9e7d4db73bf2471a33d54e5061f (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.scm7
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.