Dynamically Reloading Lua Files

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
basicer
Prole
Posts: 1
Joined: Sat Sep 15, 2012 7:07 pm

Re: Dynamically Reloading Lua Files

Post by basicer »

This is one of the problems my cupid development library tries to solve. Ive been working on it for the past few weeks, but I haven't had a chance to document it very well. Basically you dofile cupid.lua at the top of your conf.lua file. It watches the modification times of lua files in your project and causes a reload if any of them change.

When reloading the project it uses a few of the ideas already discussed. It resets to a snapshot of _G, package.loaded tables so that require will work as expected. I personally turn off the lua based scanning and use inotify to cause cupid to reload the scripts by sending a UDP command; but this requires more setup. The code is below if anyone wants to give it a try.

https://www.dropbox.com/s/zb3y8vy016lpq63/cupid-0.6.lua
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 66 guests