11# LuaHotLoader
22
3- ![ version 1.2] ( https://img.shields.io/badge/version-1.2-green.svg )
3+ <p >
4+ <a href="https://github.com/ReFreezed/LuaHotLoader/releases/latest">
5+ <img src="https://img.shields.io/github/release/ReFreezed/LuaHotLoader.svg" alt="">
6+ </a>
7+ <a href="https://github.com/ReFreezed/LuaHotLoader/blob/master/LICENSE.txt">
8+ <img src="https://img.shields.io/github/license/ReFreezed/LuaHotLoader.svg" alt="">
9+ </a>
10+ </p >
411
5- <!--  -->
6- <!--  -->
12+ ** LuaHotLoader ** is a Lua library for hot-loading files, including modules.
13+ Works with * LuaFileSystem * or [ * LÖVE * ] ( https://love2d.org/ ) 0.10+.
714
8- Hot-load any file, including Lua modules.
9- Works with * LuaFileSystem* or [ * LÖVE* ] ( https://love2d.org/ ) (including 11.0 and 0.10).
15+ - [ Basic usage] ( #basic-usage )
16+ - [With LuaFileSystem](#with-luafilesystem)
17+ - [In LÖVE](#in-lÖve)
18+ - [ Documentation] ( http://refreezed.com/luahotloader/docs/ )
19+ - [ Help] ( #help )
1020
11- - [ Usage with LuaFileSystem] ( #usage-with-luafilesystem )
12- - [ Usage in LÖVE] ( #usage-in-lÖve )
13- - [ API] ( #api )
1421
1522
23+ ## Basic usage
1624
17- ## Usage with LuaFileSystem
1825
19- ``` lua
20- local hotLoader = require (" hotLoader" )
21- local duckImagePath = " duck.jpg"
26+ ### With LuaFileSystem
2227
23- -- Initial loading of resources (optional).
24- hotLoader .load (duckImagePath )
28+ ``` lua
29+ local hotLoader = require (" hotLoader" )
30+ local duckPath = " duck.jpg"
2531
2632-- Program loop.
27- local lastTime = os.time ()
33+ local lastTime = os.clock ()
2834
2935while true do
30- local currentTime = os.time ()
36+ local currentTime = os.clock ()
3137
32- -- Allow hotLoader to reload module and resource files that have been updated.
38+ -- Allow the library to reload module and resource files that have been updated.
3339 hotLoader .update (currentTime - lastTime )
3440
3541 -- Show if debug mode is enabled.
@@ -39,14 +45,15 @@ while true do
3945 end
4046
4147 -- Show size of duck image.
42- local duckImageData = hotLoader .load (duckImagePath )
43- print (" Duck is " .. (# duckImageData ).. " bytes" )
48+ local duckData = hotLoader .load (duckPath )
49+ print (" Duck is " .. (# duckData ).. " bytes" )
4450
4551 lastTime = currentTime
4652end
4753```
4854
49- ## Usage in LÖVE
55+
56+ ### In LÖVE
5057
5158``` lua
5259local hotLoader = require (" hotLoader" )
@@ -56,18 +63,15 @@ local player = {
5663}
5764
5865function love .load ()
59- -- Tell hotLoader to load .png files using love.graphics.newImage().
66+ -- Tell the library to load .png files using love.graphics.newImage().
6067 hotLoader .setLoader (" png" , love .graphics .newImage )
6168
62- -- Note: hotLoader automatically adds common loaders in LÖVE, including
69+ -- Note: The library automatically adds common loaders in LÖVE, including
6370 -- for .png files. You can call hotLoader.removeAllLoaders() to undo this.
64-
65- -- Do the initial loading of resources (optional).
66- hotLoader .load (player .imagePath )
6771end
6872
6973function love .update (dt )
70- -- Allow hotLoader to reload module and resource files that have been updated.
74+ -- Allow the library to reload module and resource files that have been updated.
7175 hotLoader .update (dt )
7276end
7377
8690
8791
8892
89- ## API
93+ ## Documentation
94+
95+ - [ Website] ( http://refreezed.com/luahotloader/docs/ )
96+ - [ The source code] ( preprocess.lua )
97+
98+
99+
100+ ## Help
101+
102+ Got a question?
103+ If the [ documentation] ( http://refreezed.com/luahotloader/docs/ ) doesn't have the answer,
104+ look if someone has asked the question in the [ issue tracker] ( https://github.com/ReFreezed/LuaHotLoader/issues?q=is%3Aissue ) ,
105+ or [ create a new issue] ( https://github.com/ReFreezed/LuaHotLoader/issues/new ) .
90106
91- Check the [ source code] ( hotLoader.lua ) for more info.
92107
93- ``` lua
94- hotLoader .allowExternalPaths ()
95- hotLoader .disableDefaultLoader ()
96- hotLoader .getCheckingInterval ()
97- hotLoader .getCustomLoader ()
98- hotLoader .getDefaultLoader ()
99- hotLoader .getLoader ()
100- hotLoader .getLogformat ()
101- hotLoader .hasLoaded ()
102- hotLoader .hasRequired ()
103- hotLoader .isAllowingExternalPaths ()
104- hotLoader .load ()
105- hotLoader .log ()
106- hotLoader .preload ()
107- hotLoader .prerequire ()
108- hotLoader .removeAllCustomLoaders ()
109- hotLoader .removeAllLoaders ()
110- hotLoader .require ()
111- hotLoader .resetCheckingState ()
112- hotLoader .setCheckingInterval ()
113- hotLoader .setCustomLoader ()
114- hotLoader .setDefaultLoader ()
115- hotLoader .setLoader ()
116- hotLoader .setLogformat ()
117- hotLoader .unload ()
118- hotLoader .unrequire ()
119- hotLoader .update ()
120- ```
0 commit comments