@Zarty55
I think you may be misunderstanding what's going on. Here's a step by step of what happens in your example:
- The program starts
- You add your lurker.postswap assignment into the love.update() function
- The change is detected, lurker.preswap is called
- The hotswap occurs, main.lua is loaded and executed -- the new love.update() function (among the others) is set but is not run yet
- The (unchanged) lurker.postswap function is called
- Love enters the next frame and calls the new love.update() function, the assignment to lurker.postswap you added inside this function takes place.
This is the intended behaviour of lurker. To do what you're trying to do you could stick your assignment right in the file's body (outside of any function), that means when the hotswap occurs and the file is loaded and executed the assignment will take place immediately.
Ranguna259 wrote:Is all the code yours or did take some of it from somewhere else ?
Yes, I wrote it myself, you can check out the history, source and tests on the github -- some functions, eg lume.distance() use the standard approach and so are basically the same as nearly every other implementation of a distance function. I'm unsure what the intent of your question was?
MGinshe wrote:this is absolutely awesome. i've used Cupid before (which is really really nice) but it didn't have any functionality to limit how often it checks for modifications - it's also confusing as all hell to read, so i left it the hooked/protected functions thing sounds really interesting.
I had a little play around with using the same wrapping technique cupid uses for catching errors in the love callbacks -- I did have to do a little extra work because of the nature of the hotswapping but it seems to be working well so far! This means that if you introduce an error which only occurs in a call to love.update() the error is caught, if you fix the error the program will continue where it left off, with the new file in place.
Hopefully I can get the feature finished some time this evening and push the updates, I'll make a post to this thread when it's all updated and uploaded.
MGinshe wrote: i wrote a small threaded implementation of lurker. would be more than happy to upload if you want
I was put off using threads as I was unsure of how well hotswapping might work when we bring threads into the mix, I also wanted to keep thing simple and maintain compatibility with both love 0.8.0 and 0.9.0. You should definitely upload your version, it'd be interesting to take a look -- in addition, if you wanted to continue supporting a threaded version, you could fork the lurker repo on github and create a lurker-threaded repo or something to that effect.