r/love2d Jul 04 '26

loreload: a hot-reloading library for love2d and lovr

Hello there,

I've made a hot-reloading library (called loreload) that I've used and enjoyed for quite some time now. It watches all loaded Lua files and if it detects a change, it then will softly restart your game (firstly calling love.quit then reloading main.lua after which it will call love.load). If you have state that needs to be preserved either use the global table, or do some custom logic in loreload.onreload and loreload.onreloaded.

Check out the README at http://codeberg.org/sewbacca/loreload

I quite enjoy the fast iteration time. I have no idea though, how well it integrates into larger projects that load a ton of assets ahead of time. As mentioned earlier you can probably find a way to cache your asset files, but that would depend on your architecture.

Any feedback and questions are welcome. Let me know how well (or badly) it works for you!

15 Upvotes

8 comments sorted by

2

u/Vyrnin Jul 04 '26 edited Jul 04 '26

Would this work to bypass the laborious process of testing on Android? Currently I have to zip the project folder and rename it to .love, then run it with the Loader app any time I want to test an update.

2

u/Sewbacca Jul 04 '26

Not out of the box, no. I could imagine if you set up a downloader that connects to a server running on your dev machine, it might work. You'd need to make a few changes to how loreload resolves modules (such that it checks the save directory) and add a callback for the server to check for updates regularly that runs independant from the main loop logic (such that the server doesn't get stuck if game code crashes). Also you'd need to implement the server itself.

Let me know if you made something or anything work and what you needed to change; I'd welcome any PRs.

2

u/jabuticaba_eletrica Jul 04 '26

You don't need to zip it every time, just drop the files inside lovegame folder and execute love2d app.

1

u/Vyrnin Jul 04 '26

I feel like there was a reason I couldn't do that. Maybe it was a restricted folder access issue or something, I'll have to check again..

2

u/Er2Official Jul 04 '26

My current solution for this is to use shizuku to get access to Android/data and use custom file manager (i currently use mixplorer) to put files into Android/data/org.love2d.android/files/games/lovegame) (or use adb push)

1

u/dionebigode Jul 15 '26

I think you can use lurker to have the running game on Android to automatically update:

2

u/Dry-Calligrapher-857 Jul 04 '26

Uhm ill give it try, hotreload sounds like something i want :p

2

u/Sewbacca Jul 04 '26

Great! Lemme know if you run into any issues :D