8-bitsy builds, allow :game.files to override filename
This commit is contained in:
parent
16a6830b20
commit
d5714f14d4
BIN
8Bitsy.dsk
BIN
8Bitsy.dsk
Binary file not shown.
|
@ -4,8 +4,7 @@
|
|||
|
||||
(local files (util.hot-table ...))
|
||||
|
||||
(local filename "game/game.json")
|
||||
|
||||
(local default-filename "bitsy/game.json")
|
||||
|
||||
(local encoded-tile-fields [:gfx :mask])
|
||||
(fn convert [tile field method]
|
||||
|
@ -42,21 +41,24 @@
|
|||
:table (lume.clone v)
|
||||
_ v))
|
||||
|
||||
(fn files.load []
|
||||
(fn filename [] (or files.filename default-filename))
|
||||
(fn files.load [?filename]
|
||||
(when ?filename (set files.filename ?filename))
|
||||
(set files.game
|
||||
(if (util.file-exists filename)
|
||||
(let [game (util.readjson filename)]
|
||||
(if (util.file-exists (filename))
|
||||
(let [game (util.readjson (filename))]
|
||||
(each [k v (pairs game)]
|
||||
(tset game k (lume.map v #(deserialize k (clone $1)))))
|
||||
game)
|
||||
{:tiles [] :portraits [] :font [] :levels []}))
|
||||
files.game)
|
||||
|
||||
(fn files.save []
|
||||
(fn files.save [?filename]
|
||||
(when ?filename (set files.filename ?filename))
|
||||
(let [game {}]
|
||||
(each [k v (pairs files.game)]
|
||||
(tset game k (lume.map v #(serialize k (clone $1)))))
|
||||
(util.writejson filename game)))
|
||||
(util.writejson (filename) game)))
|
||||
|
||||
(fn new-cache [game key]
|
||||
(let [spritegen (match key
|
||||
|
@ -77,6 +79,9 @@
|
|||
(each [key cache (pairs files.tilecaches)]
|
||||
(cache:load (. files.game key)))))
|
||||
|
||||
(fn files.module []
|
||||
(or files.game.module (: (filename) :match "^[^/]+")))
|
||||
|
||||
(when (= files.game nil)
|
||||
(files.load))
|
||||
|
||||
|
|
5
game/init.fnl
Normal file
5
game/init.fnl
Normal file
|
@ -0,0 +1,5 @@
|
|||
(local files (require :game.files))
|
||||
(local util (require :lib.util))
|
||||
|
||||
(util.reload (files.module))
|
||||
|
Loading…
Reference in a new issue