Skip to content

Commit 9c4ba54

Browse files
winny-44100hertz
andauthored
fix: potential typo/scope fixes (#77)
* 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]>
1 parent 3b3fed5 commit 9c4ba54

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

src/actors/killer-tomato.fnl

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636

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

4243
kt

src/actors/tomato.fnl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(local tomato {})
22

33
(fn tomato.spawn [s pos]
4-
{: kind
4+
{:kind "tomato"
55
:name "tomato"
66
: pos
77
:color [1 0 0]

src/main.lua

+9-13
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,20 @@
33
local fennel = require("lib.fennel")
44
local make_love_searcher = function(env)
55
return function(module_name)
6-
local path = module_name:gsub("%.", "/") .. ".fnl"
7-
if love.filesystem.getInfo(path) then
8-
return function(...)
9-
local code = love.filesystem.read(path)
10-
return fennel.eval(code, {env=env}, ...)
11-
end, path
12-
end
13-
path = module_name:gsub("%.", "/") .. "/init.fnl"
14-
if love.filesystem.getInfo(path) then
15-
return function(...)
16-
local code = love.filesystem.read(path)
17-
return fennel.eval(code, {env=env}, ...)
18-
end, path
6+
for _, filename in ipairs({".fnl", "/init.fnl"}) do
7+
local path = module_name:gsub("%.", "/") .. filename
8+
if love.filesystem.getInfo(path) then
9+
return function(...)
10+
local code = love.filesystem.read(path)
11+
return fennel.eval(code, {env=env, filename=path}, ...)
12+
end
13+
end
1914
end
2015
end
2116
end
2217

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

2622
require("game")

0 commit comments

Comments
 (0)