Hi! I was attempting to play around with the Chickadee example vat in the community-garden repo. I’m having a bit of trouble, though, and I’m probably just misunderstanding something
Here’s my attempt at the moment:
(define-module (community-garden test-chickadee-vat)
#:use-module (community-garden chickadee-vat)
#:use-module (goblins)
#:use-module (goblins vat)
#:use-module (oop goops)
#:use-module (chickadee)
#:use-module (chickadee scripting)
#:use-module (chickadee graphics text)
#:use-module (chickadee math vector))
(define (^artist bcom)
(lambda ()
;;(display "Drawing...")
(draw-text "Hello world!" (vec2 260.0 240.0))))
(define-class <chickadee-vat-test> ()
(vat #:accessor vat)
(started #:accessor started? #:init-value #f)
(artist #:accessor artist))
(define-method (start (self <chickadee-vat-test>))
(define (draw alpha)
(if (started? self)
(script
(with-vat (vat self)
($ (artist self))))))
(define (update dt)
(update-agenda 1))
(define (load)
(script
(slot-set! self 'vat (make-chickadee-vat))
(vat-start! (vat self))
(slot-set! self 'artist
(with-vat (vat self)
(spawn ^artist)))
(slot-set! self 'started #t)))
(run-game #:draw draw #:update update #:load load))
(define tester (make <chickadee-vat-test>))
(start tester)
I’m trying to have actors that are able to draw on the screen when requested, as I described in a previous forum post. The game window opens, and while I’m able to see the “Drawing…” message that my artist
actor prints if I uncomment that, the text is never drawn.
I wasn’t sure if I needed to make the method call to my artist
object in a script
(the “Hello world” program on the Chickadee site does not) but if I don’t I get an error as follows:
Backtrace:
In ice-9/boot-9.scm:
1752:10 12 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
11 (apply-smob/0 #<thunk 7f8e05912300>)
In ice-9/boot-9.scm:
724:2 10 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
619:8 9 (_ #(#(#<directory (guile-user) 7f8e05915c80>)))
In ice-9/boot-9.scm:
2836:4 8 (save-module-excursion _)
4388:12 7 (_)
In chickadee.scm:
414:11 6 (run-game #:window-title _ #:window-width _ # _ # _ # _ …)
In chickadee/game-loop.scm:
96:26 5 (run-game* #:init _ #:update _ #:render _ #:time _ # _ # …)
43:8 4 (call-with-error-handling _ _)
97:28 3 (_)
In chickadee.scm:
388:10 2 (render-sdl-opengl 0.002672420290764435)
In goblins/vat.scm:
213:2 1 (call-with-vat #<vat chickadee> _)
In unknown file:
0 (_ (script) #<procedure 7f8e05859c00 at chickadee/scrip…>)
ERROR: In procedure abort: Abort to unknown prompt
But I’m wondering if the use of script
is what’s resulting in nothing being displayed here, because the return value of a script
call is a handle to the script. So if drawing relies on the return value of draw-text
, that could be the culprit.