From 133fdb5752555c6d3d94394f2579d9b5a27f691c Mon Sep 17 00:00:00 2001 From: Juliana Sims Date: Sat, 25 May 2024 13:29:12 -0400 Subject: [PATCH] Add activation counting to switched emitters --- modules/game/actors.scm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/game/actors.scm b/modules/game/actors.scm index 3bcd614..8fe0615 100644 --- a/modules/game/actors.scm +++ b/modules/game/actors.scm @@ -198,6 +198,7 @@ (define timer (spawn ^cell 0)) (define on? (spawn ^cell)) (define position (vector x y 0)) + (define activations (spawn ^cell 0)) (define (wire-state) (and ($ on?) (match ($ timer) @@ -217,12 +218,18 @@ (('enter obj grid-info) #f) (('exit obj grid-info) #f) (('activate grid-info) - ($ on? #t) - ($ timer 0) - ($ grid-info 'append-event `(emitter-on ,x ,y))) + (let ((k (1+ ($ activations)))) + ($ activations k) + (unless (> k 1) + ($ on? #t) + ($ timer 0) + ($ grid-info 'append-event `(emitter-on ,x ,y))))) (('deactivate grid-info) - ($ on? #f) - ($ grid-info 'append-event `(emitter-off ,x ,y))) + (let ((k (1- ($ activations)))) + ($ activations k) + (when (= k 0) + ($ on? #f) + ($ grid-info 'append-event `(emitter-off ,x ,y))))) (('wire-state grid-info from from-x from-y) (wire-state)) (('update-wire-state grid-info neighbor-grid) #f) (('alive?) #t)