Skip to content

A fennel module that exposes mock functions for the love2d API in Fennel

License

Notifications You must be signed in to change notification settings

tupini07/fennel-love2d-api

Repository files navigation

fennel-love2d-api

Fennel is a great language, and (in my opinion) more ergonomic than Lua. Among other things it supports interactive development via its REPL, which provides nice autocompletion, interactive execution, and documentation search. However, this functionality is lacking when working on a Love2d project, mainly because the Love2d API is provided as a global variable when in a Love2d execution environment.

This repo provides a file that contains a set of mocks functions provided by Love2d. These mock functions don't really do anything but they do use the same names and documentation as the original Love2d ones. This allows you to import the api file and have all the nice REPL features except for interactive execution.

Demo

love-api demo

How it works

This project is composed of a simple Fennel script that reads the Love2d API definition from love2d-community/love-api, and then generates a Fennel file that contains all the mock functions, using the appropriate names and documentation.

When you require this file, it will first check if the file is being executed in a Love2d enviroment (this is done by checking if _G.love is not nil), and if it is then the actual _G.love reference is returned instead of the mocks. This has the effect that you can use the mocks during development (from the REPL) and the real Love2d functions will be used when running the actual game.

How to use

Just grab the latest release from Releases and put it somewhere in your project.

Once that's done just require it where you need the Love2d api and that's it! See a very minimal example here.

About

A fennel module that exposes mock functions for the love2d API in Fennel

Topics

Resources

License

Stars

Watchers

Forks

Languages