Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch transcript Excluding Merge-Ins
This is equivalent to a diff from 5a79e2775f to f3e9d0e3d8
|
2025-11-09
| ||
| 06:39 | Standardize on "clock tower". check-in: c0b8c078da user: flutter tags: trunk | |
| 06:20 | Install fennel searcher thing in input.fnl, so we can require transcript. Leaf check-in: f3e9d0e3d8 user: flutter tags: transcript | |
| 06:09 | Merge trunk. check-in: 0e419ecc1b user: flutter tags: transcript | |
| 06:07 | Use "current", not "tip", to make zip file. current is the currently checked out version. tip is the most recent version on any branch. https://fossil-scm.org/home/doc/trunk/www/checkin_names.wiki#special check-in: 5a79e2775f user: flutter tags: trunk, day-9 | |
| 05:43 | Fix bug where you can generate cat food twice check-in: 7295f36d35 user: wow tags: trunk | |
Changes to input.fnl.
1 2 3 4 5 6 7 8 9 10 11 |
tonumber {}; return require("fennel").install().eval([==[
;; The first and last lines of this file make it a Lua/Fennel polyglot program,
;; suitable for loading with love.thread.newThread, which expects a Lua file.
;; This file reads lines from the default input file (stdin) and pushes the
;; read lines (and any errors) onto the love event queue. It stops reading
;; after the first nil line it reads (which may be the result of an error, or
;; simply EOF).
;; We will have been provided, by love.thread.newThread, a name to attach to
;; the events we push.
| > > > > > > > > > > > > > > > > | > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
tonumber {}; return require("fennel").install().eval([==[
;; The first and last lines of this file make it a Lua/Fennel polyglot program,
;; suitable for loading with love.thread.newThread, which expects a Lua file.
;; This file reads lines from the default input file (stdin) and pushes the
;; read lines (and any errors) onto the love event queue. It stops reading
;; after the first nil line it reads (which may be the result of an error, or
;; simply EOF).
(local fennel (require :fennel))
(fennel.install)
(set debug.traceback fennel.traceback)
(fn make_love_searcher [env]
(fn [module-name]
(let [path (.. (module-name:gsub "%." "/") ".fnl")]
(if (love.filesystem.getInfo path)
(values (fn [...]
(let [code (love.filesystem.read path)]
(fennel.eval code {: env} ...)))
path)))))
(table.insert package.loaders (make_love_searcher _G))
(table.insert (. fennel "macro-searchers") (make_love_searcher "_COMPILER"))
;; We will have been provided, by love.thread.newThread, a name to attach to
;; the events we push.
(local (event-name run-id) ...)
(assert event-name)
(assert run-id)
(local transcript (require :transcript))
(transcript.install run-id)
(require "love.event")
(var ok true)
(fn handle [...]
;; Push the io.read results with the event name we were given.
(love.event.push event-name ...)
|
| ︙ | ︙ |
Changes to main.fnl.
1 2 3 4 5 6 7 8 9 | ;; By the way, if you don't like goto statements, don't read this. (local fennel (require :fennel)) (set debug.traceback fennel.traceback) ;; A table of update functions that will be exported by the game module. We'll ;; call each of these functions with the delta time in each call to ;; love.update. (var updaters nil) | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 | ;; By the way, if you don't like goto statements, don't read this. (local transcript (require :transcript)) (local run-id (transcript.install)) (local fennel (require :fennel)) (set debug.traceback fennel.traceback) ;; A table of update functions that will be exported by the game module. We'll ;; call each of these functions with the delta time in each call to ;; love.update. (var updaters nil) |
| ︙ | ︙ | |||
27 28 29 30 31 32 33 | ;; read input. (assert (coroutine.resume co)) ;; Start the stdin-reading thread, which pushes an event for each line of ;; input. This is run in a thread so that it is non-blocking. Instruct the ;; thread to tag its events with the event name :input, which we have ;; installed a handler for just above. (let [input-thread (love.thread.newThread "input.fnl")] | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
;; read input.
(assert (coroutine.resume co))
;; Start the stdin-reading thread, which pushes an event for each line of
;; input. This is run in a thread so that it is non-blocking. Instruct the
;; thread to tag its events with the event name :input, which we have
;; installed a handler for just above.
(let [input-thread (love.thread.newThread "input.fnl")]
(input-thread:start :input run-id)))
(lambda love.update [dt]
;; Run all the updater functions exported by the game module.
(each [key update (pairs updaters)]
(if (not (update dt))
;; The update function returned false, indicating that it's no longer
;; needed. Remove it from the table.
(tset updaters key nil))))
|
Added transcript.fnl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
;; Override print, io.write, and io.read calls to log timestamped interaction
;; to a file.
(local fennel (require :fennel))
(local FILENAME "transcript.txt")
(require "love.math")
(require "love.timer")
(local start-time (love.timer.getTime))
(lambda record [run-id what s]
(let [now (love.timer.getTime)
dt (- now start-time)
rec (string.format "%s\t%.3f\t%s\t%s\n"
run-id dt what
(fennel.view s {:one-line? true :line-length math.huge :escape-newlines? true}))]
(assert (love.filesystem.append FILENAME rec))))
(lambda install [?run-id]
(let [run-id (or ?run-id (string.format "%07x" (love.math.random 0xfffffff)))]
(local print print)
(lambda transcript-print [...]
(each [_ s (ipairs (if (next [...]) [...] [""]))]
(record run-id "print" s))
(print ...))
(set _G.print transcript-print)
(local io-write io.write)
(lambda transcript-io-write [...]
(each [_ s (ipairs [...])]
(record run-id "write" s))
(io-write ...))
(set _G.io.write transcript-io-write)
(local io-read io.read)
(lambda transcript-io-read [...]
(let [res [(io-read ...)]]
(each [_ s (ipairs res)]
(record run-id "read" s))
(unpack res)))
(set _G.io.read transcript-io-read)
run-id))
{: install}
|
Added untranscript.fnl.
> > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
;; ./fennel-1.6.0 untranscript.fnl < transcript.txt
(local fennel (require :fennel))
(var prev-run-id nil)
(each [line (io.lines)]
(let [(run-id dt what s) (string.match line "^([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)$")
s (fennel.eval s)]
(assert run-id)
(if (not= run-id prev-run-id)
(print (string.format "\n=== %s ===\n" run-id)))
(set prev-run-id run-id)
(case what
"print" (print s)
"write" (io.write s)
"read" (print s))))
|