-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.lua
31 lines (24 loc) · 818 Bytes
/
main.lua
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
do --simple compatibilty layer
bit = bit or bit32
end
local function getCurrentScriptFolder(level)
return debug.getinfo(level + 1, "S").source:gsub("^@", ""):gsub("[%w_%.]-%.lua", "")
end
local includePath = getCurrentScriptFolder(1)
local function injectRequireLoader()
package.path = package.path .. ";" .. includePath .. "?.lua"
end
injectRequireLoader()
local function canLoadFile(path)
return not not(loadfile(path))
end
function loadClass(class)
local folderPath = getCurrentScriptFolder(2)
local path = folderPath .. class:gsub("%.", "\\") .. ".lua"
if canLoadFile(path) then
local s, e = folderPath:find(includePath, 1, true)
return require("classes." .. folderPath:sub(e+1):gsub("classes\\", ""):gsub("\\", ".") .. class)
end
return require("classes." .. class)
end
class = require "class"