time_guesser/TEMPLATE.md
2026-05-27 15:41:11 +01:00

1.5 KiB

L5 in Fennel template

Repo

A minimalist template for using L5 within Fennel.

L5 is built on top of LÖVE, and it provides a Processing API for Lua. It's meant for interactive artwork on the computer, aimed at artists, designers, and anyone that wants a flexible way to prototype art, games, toys, and other software experiments in code.

To use it in Fennel, we can use the Absolutely Minimal Fennel Setup for Love2D template for main.lua, but modify it to add the allowedGlobals=false option for L5 to work properly. We do this because L5 sets global variables that we want to allow and allowedGlobals=false disables that check.

fennel = require("fennel")
debug.traceback = fennel.traceback
table.insert(package.loaders,
	     function(filename)
			if love.filesystem.getInfo(filename) then
				return function(...)
					return fennel.eval(love.filesystem.read(filename), {env=_G, filename=filename, allowedGlobals=false}, ...), filename
				end
			end
	     end)

require("main.fnl")

Inside main.fnl, the other thing that we need to do is to expose the functions that L5 expects:

(set _G.setup setup)
(set _G.draw draw)

Now you can simply run love . in the root of your project directory and you should be good to go!