forked from lovetoys/lovetoys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lovetoys.lua
54 lines (43 loc) · 1.52 KB
/
lovetoys.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- Getting folder that contains our src
local folderOfThisFile = (...):match("(.-)[^%/%.]+$")
local lovetoys = require(folderOfThisFile .. 'src.namespace')
function lovetoys.debug(message)
if lovetoys.config.debug then
print(message)
end
end
local function populateNamespace(ns)
-- Requiring class
ns.class = require(folderOfThisFile .. 'lib.middleclass')
-- Requiring util functions
ns.util = require(folderOfThisFile .. "src.util")
-- Requiring all Events
ns.ComponentAdded = require(folderOfThisFile .. "src.events.ComponentAdded")
ns.ComponentRemoved = require(folderOfThisFile .. "src.events.ComponentRemoved")
-- Requiring the lovetoys
ns.Entity = require(folderOfThisFile .. "src.Entity")
ns.Engine = require(folderOfThisFile .. "src.Engine")
ns.System = require(folderOfThisFile .. "src.System")
ns.EventManager = require(folderOfThisFile .. "src.EventManager")
ns.Component = require(folderOfThisFile .. "src.Component")
end
function lovetoys.initialize(opts)
if opts == nil then opts = {} end
if not lovetoys.initialized then
lovetoys.config = {
debug = false,
globals = false
}
for name, val in pairs(opts) do
lovetoys.config[name] = val
end
populateNamespace(lovetoys)
if lovetoys.config.globals then
populateNamespace(_G)
end
lovetoys.initialized = true
else
print('Lovetoys is already initialized.')
end
end
return lovetoys