livecoding library for LÖVE
Go to file
2025-01-21 14:35:54 -03:00
.vscode feat: add VSCode settings for Lua diagnostics configuration 2025-01-21 14:35:54 -03:00
conf.lua feat: new example patch 2024-03-09 23:17:48 +01:00
divider.lua feat: add divider module for visual separation in the game 2024-12-03 19:21:24 +01:00
LICENSE docs: 📄 updated license 2024-03-09 23:18:18 +01:00
lick-1.0-0.rockspec chore: 📦 rename rockspec file and update version to 1.0-0 2024-12-08 21:52:53 +01:00
lick.lua refactor: ♻️ set sleeptime to 0.001 2024-12-08 21:50:11 +01:00
main.lua feat: add load function to main.lua for initialization 2025-01-21 14:22:41 -03:00
Makefile feat: add Makefile for simplified project execution 2024-12-03 19:21:24 +01:00
README.md docs: 📖 update README to specify copying lick.lua into the project 2024-12-27 20:18:22 +01:00

livecoding library for LÖVE

This is a small live coding library for LÖVE.

Overview

The livecoding library for LÖVE provides a simple and efficient way to live code in the LÖVE framework. It allows developers to see changes in their code in real-time without restarting the application. This is achieved by monitoring file changes and reloading the necessary files automatically.

Key Features

  • Automatic Reloading: Watches for changes in your source files and reloads them as needed.
  • Error Handling: Redirects errors to the command line or displays them on the screen, making debugging easier.
  • Customizable: Offers several optional parameters to customize the behavior of the live coding environment.
  • Compatibility: Tested and works seamlessly with LÖVE 11.5.

How It Works

The library overrides the default love.run function to include file watching capabilities. When a file change is detected, it reloads the file and optionally calls love.load to reset the game state. Errors encountered during the reload process are captured and displayed either in the console or on the screen, depending on the configuration.

Getting Started

To use the livecoding library, simply copy lick.lua into your project and require it in your own main.lua file and set the desired parameters. The library will handle the rest, ensuring that your changes are reflected in real-time.

Optional Parameters

  • lick.files = {"main.lua", "anotherfile.lua"} -- list of files to watch, default is {"main.lua"}
  • lick.debug = true -- displays errors in love window
  • lick.reset = true -- calls love.load every time you save the file, if set to false it will only be called when starting LÖVE
  • lick.clearFlag = false -- overrides the clear() function in love.run
  • lick.sleepTime = 0.001 -- sleep time in seconds, default is 0.001
  • lick.showReloadMessage = true -- show message when a file is reloaded
  • lick.chunkLoadMessage = "CHUNK LOADED" -- message to show when a chunk is loaded
  • lick.updateAllFiles = false -- include all .lua files in the directory and subdirectories in the watchlist for changes
  • lick.clearPackages = false -- clear all packages in package.loaded on file change

Example main.lua

lick = require "lick"
lick.reset = true -- reload love.load every time you save

function love.load()
    circle = {}
    circle.x = 1
end

function love.update(dt)
    circle.x = circle.x + dt*5
end

function love.draw(dt)
    love.graphics.circle("fill", 400+100*math.sin(circle.x), 300, 16,16)
end