Giter Site home page Giter Site logo

lurker's Introduction

Lurker

A small module which automatically hotswaps changed Lua files in a running LÖVE project.

Installation

Drop the lurker.lua and lume.lua files into an existing project and add the following line inside the love.update() function:

require("lurker").update()

Lurker will automatically detect changed files and hotswap them into the running project.

Additional Functionality

To more easily make use of additional functionality, the lurker module can be set to a variable when it is required into the project:

lurker = require "lurker"

lurker.scan()

As opposed to using the lurker.update() function -- such to avoid the overhead of repeatedly polling for file changes -- you can instead opt to trigger a scan of the directory by calling lurker.scan() manually. If the scan detects any changes a hotswap is performed.

lurker.preswap

lurker.preswap can be set to a function. This function is called before a hotswap occurs and is passed the name of the file which will be swapped. If the function returns true then the hotswap is canceled.

lurker.preswap = function(f) print("File " .. f .. " swapping...") end

lurker.postswap

lurker.postswap can be set to a function. This function is called after a hotswap occurs and is passed the name of the file which was swapped.

lurker.postswap = function(f) print("File " .. f .. " was swapped") end

lurker.protected

Dictates whether lurker should run in protected mode; this is true by default. If protected mode is disabled then LÖVE's usual error screen is used when an error occurs in a LÖVE callback function; if it is enabled then lurker's error state (which continues watching for file changes and can resume execution) is used. Changes to this variable should be made before any calls to lurker.update() are made.

lurker.quiet

Dictates what should happen if lurker tries to load a file which contains a syntax error. If it is false then lurker's error screen is shown until the syntax error is fixed; if it is true the error message is printed to the console and the program continues. lurker.quiet is false by default.

lurker.interval

The interval in seconds for how often the scan of the directory is performed. This is .5 by default.

lurker.path

The directory which is scanned for changes. This is . (The project's root) by default.

lurker's People

Contributors

rxi avatar shakesoda avatar gvx avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.