Fennel sandbox
Code written while learning Fennel, in particular for the TIC-80 fantasy console.
This project is available on GitHub as well as on my website. If you're on GitHub right now, it might be more comfortable for you to browse it on my website – although I still need to take the time to add syntax highlighting 😑
Projects
- 2025-01-01 : Hello World
- 2025-01-04 : Analog Clock
Notes
Installing Fennel
I use Fennel from Debian's repositories.
sudo apt install fennel
- fennel-mode is a useful package for Emacs.
- fennel-ls is a language server for Fennel. Works out of the box for Fennel files with Eglot. I compiled it – instructions here.
Compiling the TIC-80
Clone the repo:
git clone --recursive https://github.com/nesbox/TIC-80
Follow the instructions here. Add this flag for the pro version:
DBUILD_PRO=On
. If you do, think about donating.Wrapping up:
sudo apt update && sudo apt -y install build-essential cmake git libpipewire-0.3-dev libwayland-dev libsdl2-dev ruby-dev libcurl4-openssl-dev libglvnd-dev libglu1-mesa-dev freeglut3-dev cd TIC-80/build cmake -DBUILD_SDLGPU=On -DBUILD_WITH_ALL=On -DBUILD_PRO=On .. && cmake --build . --parallel
- The executable is
build/bin/tic80
. Symlink it, for example.
Running the TIC-80 in the right directory
tic80 --fs /path/to/dir/ &
To load a game:
load game.fnl
Then it's a back and forth between Emacs and the TIC-80. Change the
Fennel file in Emacs, hit C-r
in the console.
Activate auto-revert-mode
in Emacs in case you change things
directly in the TIC-80 with the save
command (sprites, etc.).
Loading code
So far I don't know how to load Fennel code directly. So I simply
compile the Fennel file to Lua using fennel -c [file.fnl]
and then
load it like this:
(local module (require :module)) (module.myfunc)
⚠️ TIC-80 has to be started from the root directory since some scripts
reference modules from the lua/
directory.
I don't know how to group functions and macros together either. At the moment I'm simply writing Fennel macros in utils.fnl for fun. There's an interesting article about this here.
I also don't know how to create a custom indentation for my Fennel macros in Emacs.