1
0
Fork
You've already forked LICK
0
forked from usysrc/LICK
live coding kit for LÖVE
  • Lua 99.9%
  • Makefile 0.1%
2026年01月22日 20:03:21 +01:00
.lickignore update: .lickignore documentation 2026年01月08日 11:54:50 -06: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.1-0.rockspec update: rockspec file updated to a new version. 1.1.0 2026年01月06日 15:12:41 -06:00
lick.lua Added debugPrint function and updated debug print statements to make printing to the console more cohesive 2026年01月15日 16:59:48 -06:00
main.lua add: basic testing framework and unit tests for newly added features. 2026年01月14日 12:44:31 -06:00
Makefile feat: add Makefile for simplified project execution 2024年12月03日 19:21:24 +01:00
README.md update: README documentation now includes new features. Updating default file extensions back to ".lua" 2026年01月13日 16:32:56 -06:00
testing.lua add: basic testing framework and unit tests for newly added features. 2026年01月14日 12:44:31 -06:00
tests.lua add: basic testing framework and unit tests for newly added features. 2026年01月14日 12:44:31 -06:00

livecoding library for LÖVE

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

Overview

LICK allows developers to reload in their changed code without restarting the application. It monitors file changes and reloads 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.
  • Ignore Patterns: Support for a .lickignore file to exclude files from watching, similar to .gitignore.
  • Smart Package Management: Protects certain packages from being unloaded. Can customize with lick.ignorePackages.
  • Reload Callbacks: Execute custom code when files are reloaded with the lick.onReload callback.
  • 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.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 -- if true, clears the screen only when a file is modified; otherwise, clears every frame.
  • 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
  • lick.debugTextXOffset = 50 -- X offset for debug text from the center (positive moves right)
  • lick.debugTextWidth = 400 -- Maximum width for debug text
  • lick.debugTextAlpha = 0.8 -- Opacity of the debug text (0.0 to 1.0)
  • lick.debugTextAlignment = "right" -- Alignment of the debug text ("left", "right", "center", "justify")
  • lick.fileExtensions = {} -- file extensions to watch (e.g., {".lua", ".txt"}). If empty, watches all file types
  • lick.ignoreFile = ".lickignore" -- name of the ignore file (default: ".lickignore")
  • lick.mergePatterns = false -- if true, merges .lickignore patterns with built-in ignore patterns
  • lick.ignorePackages = {} -- table of package names to protect from being cleared (e.g., {mylib = true, socket = true})
  • lick.onReload = function(files) end -- callback function called after reload with list of modified files

File Ignore Patterns

LICK supports a .lickignore file to exclude files and directories from being watched. The synyax is similar to .gitignore. An example .lickignore file is included in this repository.

Creating a .lickignore File

Create a .lickignore file in your project root with patterns for files to ignore:

# Comments start with #
lick.lua
config.lua
#Ignore entire directories
assets/
temp/
# Wildcard patterns
*.txt
test_*.lua
# Recursive wildcards
**/debug/

Default Ignore Patterns

If no .lickignore file is found, LICK uses these default patterns:

# Lick Itself
lick.lua
.lickignore
# Common Lua/LOVE directories
.git/
.vscode/
.idea/
vendor/
lib/
libraries/
modules/

Set lick.mergePatterns = true to combine your .lickignore with the defaults, otherwise yours will override the default.

File Extensions

The lick.fileExtensions parameter controls which file types are watched:

-- Watch only Lua files (default behavior when updateAllFiles is true)
lick.fileExtensions = {".lua"}
-- Watch multiple file types
lick.fileExtensions = {".lua", ".txt", ".json"}
-- Watch ALL file types (leave empty)
lick.fileExtensions = {}

Protected Built-in Libraries

When lick.clearPackages = true, LICK clears the package cache on reload but protects built-in Lua and LOVE libraries from being cleared:

Default Protected Libraries:

  • string, table, math, io, os, debug, coroutine, package
  • utf8, bit, jit, ffi (if available)
  • love (all LÖVE modules)

Protecting Additional Packages

Use lick.ignorePackages to protect additional third-party libraries from being cleared:

lick.clearPackages = true
lick.ignorePackages = {
 socket = true, -- protect luasocket
 cjson = true, -- protect cjson
 ["my.custom.lib"] = true -- protect your custom library
}

This ensures stability while still allowing your custom modules to reload. Package names should match the keys used in package.loaded.

Reload Callback

The onReload callback allows you to execute custom code after files are reloaded:

lick.onReload = function(reloaded_files)
 print("Files reloaded:")
 for _, file in ipairs(reloaded_files) do
 print(" - " .. file)
 end
 -- Reset your custom modules, clear caches, etc.
 if myModule then
 myModule.reset()
 end
end

The callback receives a table containing the paths of all files that were modified.

Example main.lua

lick = require "lick"
lick.reset = true -- reload love.load every time you save
lick.updateAllFiles = true -- watch all files
lick.fileExtensions = {} -- watch all file types
lick.clearPackages = true -- clear package cache on reload
-- Protect specific third-party libraries from being cleared
lick.ignorePackages = {
 socket = true,
 json = true
}
-- Optional: callback when files reload
lick.onReload = function(files)
 print("Reloaded " .. #files .. " file(s)")
end
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