Hotloading module

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
clofresh
Citizen
Posts: 87
Joined: Sun Jul 26, 2009 4:21 pm
Contact:

Hotloading module

Post by clofresh »

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:

Code: Select all

require('module').load('game')
game.lua:

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
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.
----------------------------------------
Sluicer Games
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests