-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitlua.lua
71 lines (59 loc) · 1.69 KB
/
initlua.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
-- lokachops recursive loader v1
local function recursiveLoad(path)
print("recusive code loading; path " .. path)
for k, v in pairs(love.filesystem.getDirectoryItems(path)) do
local nfo = love.filesystem.getInfo(path .. "/" .. v)
if nfo.type == "directory" then
recursiveLoad(path .. "/" .. v)
else
local codeload = love.filesystem.load(path .. "/" .. v)
codeload()
end
end
end
Textures = {}
local function recursiveLoadImages(path)
for k, v in pairs(love.filesystem.getDirectoryItems(path)) do
local nfo = love.filesystem.getInfo(path .. "/" .. v)
if nfo.type == "directory" then
recursiveLoadImages(path .. "/" .. v)
else
local imga = love.graphics.newImage(path .. "/" .. v)
imga:setFilter("nearest", "nearest")
Textures[v] = {
img = imga,
w = imga:getWidth(),
h = imga:getHeight()
}
end
end
end
Sounds = {}
local function recursiveLoadSounds(path)
for k, v in pairs(love.filesystem.getDirectoryItems(path)) do
local nfo = love.filesystem.getInfo(path .. "/" .. v)
if nfo.type == "directory" then
recursiveLoadSounds(path .. "/" .. v)
else
Sounds[path .. "/" .. v] = love.audio.newSource(path .. "/" .. v, "static")
end
end
end
Shaders = {}
local function recursiveLoadShaders(path)
for k, v in pairs(love.filesystem.getDirectoryItems(path)) do
local nfo = love.filesystem.getInfo(path .. "/" .. v)
if nfo.type == "directory" then
recursiveLoadShaders(path .. "/" .. v)
else
Shaders[v] = love.graphics.newShader(path .. "/" .. v)
end
end
end
-- love.graphics.newShader(
recursiveLoadSounds("snd")
recursiveLoadImages("assets")
recursiveLoad("libs")
recursiveLoad("code")
recursiveLoadShaders("shader")
print("loading complete!")