Lume is a library containing a collection of functions geared towards game development. Check out the Readme file for a list of what it includes.
I've also written a small module named lurker which makes use of the lume.hotswap() function. The module detects changes in lua files in the project's directory and automatically calls the hotswap function on changed files. I've uploaded a video which shows it in action.
Both should be compatible with LÖVE 0.8.0 and 0.9.0.
Let me know what you think and if you find any issues.
Lume & Lurker : Utility functions and auto-hotswapping
Lume & Lurker : Utility functions and auto-hotswapping
Last edited by rxi on Fri Mar 07, 2014 1:41 pm, edited 1 time in total.
Re: Lume : A Collection of functions geared towards gamedev
This is extremely useful (lurker). It works perfectly on my somewhat complex project, although I'll have to do a bit of extra work to change values of already spawned objects, but I think it's worth it!
Re: Lume : A Collection of functions geared towards gamedev
Just looked the functions, seems pretty nice. I'll probably add to my game, and still have to test the lurker thing, looks awesome!
Re: Lume : A Collection of functions geared towards gamedev
hotswapping, where have you been all of my life.
Thanks for sharing with us Rxi, very nice!
Thanks for sharing with us Rxi, very nice!
Re: Lume : A Collection of functions geared towards gamedev
@adnzzzzZ
Really nice to see it in someone else's project (on a different platform, too)! Though my little demo video just focused on the love.update() function, I did write the lume.hotswap() function with larger projects in mind; I tested it on a couple of the proper-sized LÖVE projects and didn't find a case where it wouldn't work as expected. As far as I know no one has written hotswapping for Lua this way before.
That being said it won't work out well in some cases, but those cases tend to be things like image cache modules which reset their cache when they're reloaded. This didn't seem like much of a problem, as it would be unlikely that you would ever want to hotswap something like an image cache.
@Zarty55 @Helvecta
Let me know how you get along with it if you try it out!
Really nice to see it in someone else's project (on a different platform, too)! Though my little demo video just focused on the love.update() function, I did write the lume.hotswap() function with larger projects in mind; I tested it on a couple of the proper-sized LÖVE projects and didn't find a case where it wouldn't work as expected. As far as I know no one has written hotswapping for Lua this way before.
That being said it won't work out well in some cases, but those cases tend to be things like image cache modules which reset their cache when they're reloaded. This didn't seem like much of a problem, as it would be unlikely that you would ever want to hotswap something like an image cache.
@Zarty55 @Helvecta
Let me know how you get along with it if you try it out!
Re: Lume : A Collection of functions geared towards gamedev
Wow! The lurker is REALLY awesome. I have maded changes in my code and it didn't even restarted the game, that thing is just... Wow! It's freaking awesome!
One thing that would be nice, is that it could have a "catchChange" and "applyChange". Then we could detect changes inside love.errhand and restart the game when there's a change in the code.
Also, I tend to save my code a lot, even when it's not necessary (Like I'm halfway typing a function and I save) maybe it could detect typing errors and wait to apply the changes? Oh man, this is so awesome!
I had some ideas for lume, but I forgot them haha. When I remember I will surely post them here!
Edit: A callback when lurker change things would be nice too, so we could reset window state when the conf.lua or the love.load(Which in some cases wouldn't be a good idea really) changes.
I'm just really excited at this, sorry for throwing things at you like this.
Edit2: I just realized there's more stuff in the github... Oh god, this is embarrasing hahaha :p
Edit3: Sorry... Again ._.' Saw that everything I suggested is already implemented.
One thing that would be nice, is that it could have a "catchChange" and "applyChange". Then we could detect changes inside love.errhand and restart the game when there's a change in the code.
Also, I tend to save my code a lot, even when it's not necessary (Like I'm halfway typing a function and I save) maybe it could detect typing errors and wait to apply the changes? Oh man, this is so awesome!
I had some ideas for lume, but I forgot them haha. When I remember I will surely post them here!
Edit: A callback when lurker change things would be nice too, so we could reset window state when the conf.lua or the love.load(Which in some cases wouldn't be a good idea really) changes.
I'm just really excited at this, sorry for throwing things at you like this.
Edit2: I just realized there's more stuff in the github... Oh god, this is embarrasing hahaha :p
Edit3: Sorry... Again ._.' Saw that everything I suggested is already implemented.
Re: Lume : A Collection of functions geared towards gamedev
Haha, I'm liking the enthusiasm @Zarty55.
Edit: You made your 3rd edit while I was typing my reply, so I'm not sure if any of it is relevant now.
Could you try and expand on what you meant by this? Lume already aborts gracefully if you accidentally code an error (and lurker prints out that the hotswap failed to the console), but this only works for syntax errors. Any mistakes that can't be detected when the file is loaded -- such as indexing a nil value in a function that hasn't been called yet -- raises an error when the function is called. I assume you're suggesting a work around using love.errhand for this? I haven't had a chance to play with love.errhand yet. Additionally, I'm unsure how it might work, for example, once love.errhand has been called I don't believe there would be a way of jumping back to the point where the error was raised, and so at best all it could do is restart the program -- this is basically what you are forced to do as it is. Do let me know if I am mistaken, though, as a solution besides being a bit careful would be nice!Zarty55 wrote:One thing that would be nice, is that it could have a "catchChange" and "applyChange". Then we could detect changes inside love.errhand and restart the game when there's a change in the code.
That's what the lurker.preswap and lurker.postswap callback functions are for, I'm not sure if your second edit meant you already spotted them or not. For window-state changes which would require love.load() to be called again, the game would be restarted anyway, in which case closing and opening the game isn't much different to that.Zarty55 wrote:A callback when lurker change things would be nice too, so we could reset window state when the conf.lua or the love.load(Which in some cases wouldn't be a good idea really) changes.
Edit: You made your 3rd edit while I was typing my reply, so I'm not sure if any of it is relevant now.
Re: Lume : A Collection of functions geared towards gamedev
Did you take a look at the way Cupid (https://love2d.org/wiki/Cupid) handles errors? I don't understand anything about what's going on under the hood in either Cupid or your library, but in Cupid the error handling is done pretty nicely I think.
Re: Lume : A Collection of functions geared towards gamedev
I did spot it haha.rxi wrote:-snip-
I was just trying to more lazy than I am by trying to make the game to reopen itself when there's a error and something changed... For that I would just copy the current love.errhand and add that part in the "while true..." in the end. Even though I don't know if it would work, that's a whole new level of lazyness for me hahaha :p
Now that I took a better look at it I already saw that almost everything is in lurker. But still, would be nice to detect changes in the environment without changing anything.
Oh, playing a little bit with lurker.postswap I've noticed a kinda strange behavior. When I change lurker.postswap and lurker reloads(The game, not that I changed it inside the lurker.lua), it calls a old version of the postswap function. Any workaround to this?
Re: Lume : A Collection of functions geared towards gamedev
Ah, just had a peek at it. It looks like it's wrapping the love callback functions with it's own, then calling whatever the love functions were in protected mode so that it can catch any raise errors -- this becomes a bit more difficult when hotswapping is involved, as if you hotswap a module that sets the callback function (like setting love.update() in main.lua, and hotswapping main.lua) it would overwrite the wrapping.adnzzzzZ wrote:Did you take a look at the way Cupid (https://love2d.org/wiki/Cupid) handles errors? I don't understand anything about what's going on under the hood in either Cupid or your library, but in Cupid the error handling is done pretty nicely I think.
This doesn't mean it is impossible -- in fact, it just occurred to me I could check the wrapped functions and re-wrap them if they've been overwritten every time a hotswap occurs. I'll still have to give this a bit more thought and let it float around in my mind a bit before I have a go at implementing it, but I can't off the top of my head see any major issues that would occur with this.
Who is online
Users browsing this forum: Ahrefs [Bot] and 15 guests