An example Fennel project for targeting PICO-8.
Symlink the projects games directory to the PICO-8 carts directory. In my case on OSX this would be:
ln -s ~/projects/fennel-pico-8-example/games '~/Library/Application Support/pico-8/carts/games'
Install Lua:
brew install lua
This project vendors Fennel as a git submodule.
The fennel
directory is there, but empty. You must run the following commands to initialise your local configuration file, and to fetch all the data from that project:
git submodule init
git submodule update
Build the fennel
script and make it executable:
cd fennel
make
chmod +x fennel
cd ..
make
Launch PICO-8 then at the PICO-8 prompt:
load games/squashy.p8
At the PICO-8 prompt:
run
Because we are using #includes
and an external editor the token, chars and compressed limits won't display properly. In order to view their correct values type info
at the PICO-8 prompt.
One of the stricter limits PICO-8 places on its carts' code is that they must contain no more than 8192 tokens.
A token is one of:
- A literal value, such as
nil
,false
,true
, any number (e.g.123
,0xff.ff
,-3
,~1e4
), or any string (of any size). - A variable or operator
- An opening bracket
([{
- A keyword, with the exception of
end
andlocal
In particular, the following are not counted as tokens:
- The comma
,
, semicolon;
, period.
, colon:
, and double-colon::
- Closing brackets
)]}
- The
end
andlocal
keywords - The unary minus
-
and complement~
operators when applied on a numeric literal
The important one for code generated by fennel is that local
does not count to the token limit.
By defining things as a macro they don't exist at run time unless used. This means macros don't contribute to your token limit unless used.
However, because macros expand into code, macros can use up more tokens than functions if called multiple times.