-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract-love-api.lua
40 lines (35 loc) · 940 Bytes
/
extract-love-api.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
local scr = {}
local removeExtension = function(str)
return str:match("(.+)%..+")
end
local checkFirstChar = function(str)
local uppercase = str:sub(1,1):upper()
return str:sub(1,1) == uppercase
end
function scr.callScript(input, output)
local input = require(removeExtension(input))
local output = output
local file
if not love.filesystem.exists(output) then
file = love.filesystem.newFile(output)
else
love.filesystem.remove(output)
file = love.filesystem.newFile(output)
end
file:open("r")
love.filesystem.write(output, "[[\r\n")
for _,namespace in pairs(input.childs) do
local str = "love." .. tostring(_) .. "."
if namespace.childs then
for k,v in pairs(namespace.childs) do
if not checkFirstChar(tostring(k)) then
local str2 = tostring(k) .. " \r\n"
love.filesystem.append(output, str .. str2)
end
end
end
end
love.filesystem.append(output, "\r\n]]")
file:close()
end
return scr