-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
54 lines (45 loc) · 1.99 KB
/
init.lua
File metadata and controls
54 lines (45 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- This script should only be called after conf.lua e.g. in main.lua nad beyond (Not in conf.lua, see preload.lua for that)
local PATH_RAW = ...
local PATH = PATH_RAW:match("^(.*)%.init$") or ...
PATH = PATH .. "."
local attemptError = function(errorMessage)
error(errorMessage, 3)
assert(false, errorMessage) -- if error was overridden, try to use assert
return errorMessage -- fallback, try to return the error
end
if PATH_RAW:find("[[/\\]") then
local errorMessage = "MintMousse: You called require('%s'). "..
"Invalid path format, please use dot-notion (e.g. libs.mintmousse) instead of file paths. " ..
"Use `.` (periods) in place of `/` (forward slash) or `\\` (back slash). "
return attemptError(errorMessage:format(PATH_RAW))
end
require(PATH .. "setupLove")
if not love.isThread and not love.handlers then
-- is Main thread; Inside conf.lua
local errorMessage = "MintMousse: You called require('%s') inside of conf.lua. " ..
"The library requires that you use require('%s') in conf.lua, " ..
"and use require('%s') in main.lua or later. "
return attemptError(errorMessage:format(PATH_RAW, PATH .. "preload", PATH_RAW))
end
PATH_RAW = nil
-- Run preload if it hasn't been ran yet, or just grab the result
local mintmousse = require(PATH .. "preload")
if love.isThread then
return mintmousse
end
-- is Main thread
-- These love values can't be changed in conf; so we have to delay their addition until we get to main
if mintmousse.REPLACE_DEFAULT_ERROR_HANDLER then
local errorHandler = require(PATH .. "errorhandler")
love.errorhandler = errorHandler
end
local eventManager = require(PATH .. "eventManager")
love.handlers[mintmousse.THREAD_RESPONSE_QUEUE_ID] = function(enum, ...)
if enum == "MintMousseJSEvent" then
eventManager.jsEvent(...)
else
mintmousse._logger:warning("Unhandled MintMousse event!", enum)
end
end
mintmousse._logger:info("Successfully loaded MintMousse")
return mintmousse