Skip to content

Commit 1ea2419

Browse files
committed
Less logging.
Updated readme.
1 parent 36092f2 commit 1ea2419

File tree

3 files changed

+64
-58
lines changed

3 files changed

+64
-58
lines changed

LICENSE.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright © 2018-2022 Marcus 'ReFreezed' Thunström
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
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-
<!-- ![https://img.shields.io/github/release/ReFreezed/LuaPreprocess.svg](https://github.com/ReFreezed/LuaPreprocess/releases/latest) -->
6-
<!-- ![https://img.shields.io/github/license/ReFreezed/LuaPreprocess.svg](LICENSE.txt) -->
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

2935
while 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
4652
end
4753
```
4854

49-
## Usage in LÖVE
55+
56+
### In LÖVE
5057

5158
```lua
5259
local hotLoader = require("hotLoader")
@@ -56,18 +63,15 @@ local player = {
5663
}
5764

5865
function 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)
6771
end
6872

6973
function 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)
7276
end
7377

@@ -86,35 +90,18 @@ end
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-
```

hotLoader.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ local function ffiWindows_isWritable(fullPath)
732732
end
733733

734734
local function ffiWindows_unwatchDirectory(dirWatcher)
735-
hotLoader.log("[Windows] Unwatching directory '%s'.", dirWatcher.directory)
735+
-- hotLoader.log("[Windows] Unwatching directory '%s'.", dirWatcher.directory) -- @Incomplete: Verbose logging.
736736

737737
lookupArrayRemoveItem(ffiWindows_watchedDirectories, dirWatcher.directory, dirWatcher)
738738

@@ -793,7 +793,7 @@ local function createAndRegisterWatcher(level, watchers, id, path, value)
793793
if ffi_pointerToInt(notification) == INVALID_HANDLE_VALUE and false then
794794
ffiWindows_logLastError("FindFirstChangeNotificationW", "directory="..dir)
795795
else
796-
hotLoader.log("[Windows] Watching directory '%s'.", dir)
796+
-- hotLoader.log("[Windows] Watching directory '%s'.", dir) -- @Incomplete: Verbose logging.
797797
dirWatcher = {directory=dir, watcherCount=0, notification=notification}
798798
lookupArrayInsert(ffiWindows_watchedDirectories, dir, dirWatcher)
799799
end

0 commit comments

Comments
 (0)