Dear list,<div><br></div><div>I just wrote the code below. The issue is that I don't really like switching to the repl every time to read my debugging (display) prints, so I created this stuff to be able to print to the scene itself. This works quite well, so far, I'll add it to me .fluxus.scm On the positive side; it's faster than switching and more fun too. It also scales, depending on the size of the message. On the downside; the scaling and translating it does probably only works for my own set screen-size (1024 x 768) and camera settings (the default). Also; it seems that I can't parent this to the camera. New messages will be in the right spot but moving the camera will ruin that and I didn't want to add a task. Worse; I added to-string conversion for most stuff I'm likely to encounter but there must be a lot more, like procedures. There might be a better way for that. It's also quite limited, with no new-line and only a single message at a time, though this message may be a list if messages.</div>
<div><br></div><div>I looked into catching the errors that end up in the repl as well, to print those in a different colour, but it seems that you need to register some sort of "port" construct and it was all a bit beyond me. That does sound like a fun thing to think about, though.</div>
<div><br></div><div>Still, this works well enough for me right now to add it to my .fluxus.scm and test it for a while, might be useful for others too.</div><div><br></div><div>(print stuff); prints stuff, or at least gives it a go</div>
<div>(clear-print); gets the printed stuff out of the way</div><div>debug-colour; sets the colour and transparency for this printing </div><div><br></div><div>That's it. </div><div><br></div><div>Yours,</div><div>Kas.</div>
<div><br></div><div><div><div><br></div><div><br></div><div>(define debug-print #f)</div><div>(define debug-colour (vector 1 1 1 .7))</div><div><br></div><div><br></div><div>(define (to-string msg)</div><div>    (let ((output "unknown type"))</div>
<div>        (when (string? msg) (set! output msg))</div><div>        (when (symbol? msg) (set! output (symbol->string msg)))</div><div>        (when (number? msg) (set! output (number->string msg)))</div><div>        (when (boolean? msg) (set! output (if msg "#t" "#f")))</div>
<div>        </div><div>        (when (list? msg)</div><div>            (set! output "( ")</div><div>                (for ((x (in-range 0 (length msg))))</div><div>                    (set! output (string-append output (to-string (list-ref msg x)) " ")))</div>
<div>                (set! output (string-append output ")")))</div><div>        (when (vector? msg)</div><div>            (set! output "#( ")</div><div>                (for ((x (in-range 0 (vector-length msg))))</div>
<div>                    (set! output (string-append output (to-string (vector-ref msg x)) " ")))</div><div>                (set! output (string-append output ")")))</div><div><br></div><div>        output))</div>
<div><br></div><div><br></div><div>(define (clear-print)</div><div>    (when (number? debug-print) (destroy debug-print))</div><div>    (set! debug-print #f))</div><div><br></div><div>(define (print msg)</div><div>    (let*(</div>
<div>            ( output (to-string msg))</div><div>            (s (min 1 (/ 6 (string-length output))))) </div><div>    (with-state</div><div>        </div><div>        (concat (minverse (get-camera-transform)))</div><div>
        (hint-ignore-depth)</div><div>        (hint-depth-sort)</div><div>        (hint-unlit)        </div><div>        (colour debug-colour)</div><div>        </div><div>        (texture (load-texture "font.png"))</div>
<div>        </div><div>        (translate (vector -1.05 (* .7 s) -1.1))</div><div>        </div><div>        (scale s)</div><div>        (when (number? debug-print) (destroy debug-print))</div><div>        (set! debug-print (build-text output)))))</div>
<div><br></div><div><br></div><div>;let's test!</div><div>(clear)</div><div>(build-cube)</div><div><br></div><div>(print (list 1 (list 2 3) #f "fluxus" 'test (time) time (vector 4 5)))</div></div></div><div>
<br></div>