Skip to content

Commit

Permalink
fix: potential typo/scope fixes (#77)
Browse files Browse the repository at this point in the history
* fix: potential typo/scope fixes

* fix log message for killer tomato becoming tomato

* fix: fennel aware tracebacks

See https://sr.ht/~benthor/absolutely-minimal-love2d-fennel/#fennel-aware-stack-traces

* DRY-ify fennel loader

---------

Co-authored-by: Sam Pagenkopf <[email protected]>
  • Loading branch information
winny- and 44100hertz authored Sep 19, 2024
1 parent 3b3fed5 commit 9c4ba54
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/actors/killer-tomato.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@

(fn kt.on-death [s actor]
(when (< (love.math.random) 0.2)
(dungeon.spawn-actor s :tomato actor.pos
(dungeon.log (.. "The Killer Tomato became docile!")))))
(do
(dungeon.spawn-actor s :tomato actor.pos)
(dungeon.log "The Killer Tomato became docile!"))))

kt
2 changes: 1 addition & 1 deletion src/actors/tomato.fnl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(local tomato {})

(fn tomato.spawn [s pos]
{: kind
{:kind "tomato"
:name "tomato"
: pos
:color [1 0 0]
Expand Down
22 changes: 9 additions & 13 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,20 @@
local fennel = require("lib.fennel")
local make_love_searcher = function(env)
return function(module_name)
local path = module_name:gsub("%.", "/") .. ".fnl"
if love.filesystem.getInfo(path) then
return function(...)
local code = love.filesystem.read(path)
return fennel.eval(code, {env=env}, ...)
end, path
end
path = module_name:gsub("%.", "/") .. "/init.fnl"
if love.filesystem.getInfo(path) then
return function(...)
local code = love.filesystem.read(path)
return fennel.eval(code, {env=env}, ...)
end, path
for _, filename in ipairs({".fnl", "/init.fnl"}) do
local path = module_name:gsub("%.", "/") .. filename
if love.filesystem.getInfo(path) then
return function(...)
local code = love.filesystem.read(path)
return fennel.eval(code, {env=env, filename=path}, ...)
end
end
end
end
end

table.insert(package.loaders, make_love_searcher(_G))
table.insert(fennel["macro-searchers"], make_love_searcher("_COMPILER"))
debug.traceback = fennel.traceback

require("game")

0 comments on commit 9c4ba54

Please sign in to comment.