Hotloading module
Posted: Fri Jul 21, 2017 6:03 am
Hi!
I created a module that lets you reload your code on the fly without stopping your game. The code is on github
To set up a project to be hotloadable:
main.lua:
game.lua:
Then you can try changing the val string to something else, and pressing 'r' in the game, and it will reload the code without having to stop the game!
There's a more detailed example in the repo.
I created a module that lets you reload your code on the fly without stopping your game. The code is on github
To set up a project to be hotloadable:
main.lua:
Code: Select all
require('module').load('game')
Code: Select all
local Module = require('module')
function M.hotload(prevState)
val = 'hello'
end
function M.draw()
love.graphics.print(val)
end
function M.keyreleased(key)
if key == 'r' then
Module.hotload()
end
end
return M
There's a more detailed example in the repo.