Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/refreezed/luahotloader
Lua library for hot-loading files, including modules. Works with LuaFileSystem or LÖVE.
https://github.com/refreezed/luahotloader
hotloader library love2d lua lua-library lua-module lua51 luafilesystem
Last synced: 3 months ago
JSON representation
Lua library for hot-loading files, including modules. Works with LuaFileSystem or LÖVE.
- Host: GitHub
- URL: https://github.com/refreezed/luahotloader
- Owner: ReFreezed
- License: mit
- Created: 2018-01-26T21:01:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-19T02:16:21.000Z (over 2 years ago)
- Last Synced: 2023-03-05T08:18:15.751Z (almost 2 years ago)
- Topics: hotloader, library, love2d, lua, lua-library, lua-module, lua51, luafilesystem
- Language: Lua
- Homepage: http://refreezed.com/luahotloader/
- Size: 83 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.txt
- License: LICENSE.txt
Awesome Lists containing this project
README
# LuaHotLoader
**LuaHotLoader** is a Lua library for hot-loading files, including modules.
Works with *LuaFileSystem* or [*LÖVE*](https://love2d.org/) 0.10+.- [Basic usage](#basic-usage)
- [With LuaFileSystem](#with-luafilesystem)
- [In LÖVE](#in-lÖve)
- [Documentation](http://refreezed.com/luahotloader/docs/)
- [Help](#help)## Basic usage
### With LuaFileSystem
```lua
local hotLoader = require("hotLoader")
local duckPath = "duck.jpg"-- Program loop.
local lastTime = os.clock()while true do
local currentTime = os.clock()-- Allow the library to reload module and resource files that have been updated.
hotLoader.update(currentTime-lastTime)-- Show if debug mode is enabled.
local settings = hotLoader.require("appSettings")
if settings.enableDebug then
print("DEBUG")
end-- Show size of duck image.
local duckData = hotLoader.load(duckPath)
print("Duck is "..(#duckData).." bytes")lastTime = currentTime
end
```### In LÖVE
```lua
local hotLoader = require("hotLoader")
local player = {
x = 100, y = 50,
imagePath = "player.png",
}function love.load()
-- Tell the library to load .png files using love.graphics.newImage().
hotLoader.setLoader("png", love.graphics.newImage)-- Note: The library automatically adds common loaders in LÖVE, including
-- for .png files. You can call hotLoader.removeAllLoaders() to undo this.
endfunction love.update(dt)
-- Allow the library to reload module and resource files that have been updated.
hotLoader.update(dt)
endfunction love.draw()
-- Show if debug mode is enabled.
local settings = hotLoader.require("gameSettings")
if settings.enableDebug then
love.graphics.print("DEBUG", 5, 5)
end-- Draw player image.
local playerImage = hotLoader.load(player.imagePath)
love.graphics.draw(playerImage, player.x, player.y)
end
```## Documentation
- [Website](http://refreezed.com/luahotloader/docs/)
- [The source code](hotLoader.lua)## Help
Got a question?
If the [documentation](http://refreezed.com/luahotloader/docs/) doesn't have the answer,
look if someone has asked the question in the [issue tracker](https://github.com/ReFreezed/LuaHotLoader/issues?q=is%3Aissue),
or [create a new issue](https://github.com/ReFreezed/LuaHotLoader/issues/new).