Page 2 of 2

Re: Dynamically Reloading Lua Files

Posted: Thu Oct 04, 2012 8:42 pm
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