add the ability to define default questions ahead of time
This commit is contained in:
parent
af27461d8c
commit
8e5f1d5264
3 changed files with 20 additions and 4 deletions
11
game/meta/debug.fnl
Normal file
11
game/meta/debug.fnl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(require :game.meta.mapinspector)
|
||||
|
||||
(local Timeline (require :vat.timeline))
|
||||
(local {: defmethod} (require :lib.multimethod))
|
||||
|
||||
(defmethod Timeline.question :keys
|
||||
(fn [_ vat tick]
|
||||
(let [keys (icollect [key down (pairs vat.env.love.keyboard.keys)] (when down key))]
|
||||
(table.sort keys)
|
||||
keys)))
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
(local gamemode (require :game.meta.mode))
|
||||
(local vats (require :game.meta.vats))
|
||||
(require :game.meta.mapinspector)
|
||||
(require :game.meta.debug)
|
||||
|
||||
(modes:register :game gamemode)
|
||||
(fn open-view [view]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
(local {: defmulti} (require :lib.multimethod))
|
||||
|
||||
(local Timeline {})
|
||||
(set Timeline.__index Timeline)
|
||||
|
||||
|
|
@ -74,7 +76,8 @@
|
|||
inspectors []]
|
||||
(icollect [_ inspect (ipairs (self.vat:__inspectors)) &into inspectors]
|
||||
(inspector.make-proxy inspect #$1.vat Timeline.Snapshot.actions))
|
||||
(table.insert inspectors {:label :answers :inspect (fn [form state val] (inspector.proxy form state val.answers))})
|
||||
(icollect [key _ (pairs self.answers) &into inspectors]
|
||||
{:label (.. :answer: key) :inspect (fn [form state val] (inspector.proxy form state (. val.answers key)))})
|
||||
inspectors))})
|
||||
|
||||
(let [{: textbutton} (require :editor.imgui)
|
||||
|
|
@ -109,8 +112,10 @@
|
|||
(self:insert-snapshot isnap vat (+ prev-snap.src-steplim stepcount) (+ prev-snap.tick 1))
|
||||
(self:build-snapshots isnap (when count (- count 1))))))))
|
||||
|
||||
(fn Timeline.question [self key f]
|
||||
(tset self.questions key f)
|
||||
(set Timeline.question (defmulti #$1 :question ...))
|
||||
|
||||
(fn Timeline.ask [self key ?f]
|
||||
(tset self.questions key (or ?f #(self.question key $...)))
|
||||
(each [_ snap (ipairs self.snapshots)]
|
||||
(self:calculate-answer key snap)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue