Add activation counting to switched emitters
This commit is contained in:
parent
049e859dac
commit
133fdb5752
1 changed files with 12 additions and 5 deletions
|
@ -198,6 +198,7 @@
|
||||||
(define timer (spawn ^cell 0))
|
(define timer (spawn ^cell 0))
|
||||||
(define on? (spawn ^cell))
|
(define on? (spawn ^cell))
|
||||||
(define position (vector x y 0))
|
(define position (vector x y 0))
|
||||||
|
(define activations (spawn ^cell 0))
|
||||||
(define (wire-state)
|
(define (wire-state)
|
||||||
(and ($ on?)
|
(and ($ on?)
|
||||||
(match ($ timer)
|
(match ($ timer)
|
||||||
|
@ -217,12 +218,18 @@
|
||||||
(('enter obj grid-info) #f)
|
(('enter obj grid-info) #f)
|
||||||
(('exit obj grid-info) #f)
|
(('exit obj grid-info) #f)
|
||||||
(('activate grid-info)
|
(('activate grid-info)
|
||||||
|
(let ((k (1+ ($ activations))))
|
||||||
|
($ activations k)
|
||||||
|
(unless (> k 1)
|
||||||
($ on? #t)
|
($ on? #t)
|
||||||
($ timer 0)
|
($ timer 0)
|
||||||
($ grid-info 'append-event `(emitter-on ,x ,y)))
|
($ grid-info 'append-event `(emitter-on ,x ,y)))))
|
||||||
(('deactivate grid-info)
|
(('deactivate grid-info)
|
||||||
|
(let ((k (1- ($ activations))))
|
||||||
|
($ activations k)
|
||||||
|
(when (= k 0)
|
||||||
($ on? #f)
|
($ on? #f)
|
||||||
($ grid-info 'append-event `(emitter-off ,x ,y)))
|
($ grid-info 'append-event `(emitter-off ,x ,y)))))
|
||||||
(('wire-state grid-info from from-x from-y) (wire-state))
|
(('wire-state grid-info from from-x from-y) (wire-state))
|
||||||
(('update-wire-state grid-info neighbor-grid) #f)
|
(('update-wire-state grid-info neighbor-grid) #f)
|
||||||
(('alive?) #t)
|
(('alive?) #t)
|
||||||
|
|
Loading…
Add table
Reference in a new issue