-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain3.lua
54 lines (51 loc) · 1.09 KB
/
main3.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
--$Name:МЕТАПАРСЕР$
local oreset = std.reset
function std.reset(s, fname, ...)
if fname then
local dir = fname:gsub("^(.+[\\/])[^\\/]+$", "%1");
std.DICT_FILE = dir.."/dict.mrd";
std.SOURCES_DIRS = { dir };
end
return oreset(s, fname, ...)
end
obj {
nam = '@select';
act = function(s, t)
gamefile("games/"..t.."/main3.lua", true)
end;
}
local function get_name(f)
local i = 1
for l in f:lines() do
l = l:gsub('\r', '')
if l:find("^[ \t]*--[ \t]*%$Name:") then
local nam = l:gsub("^--[ \t]*--[ \t]*%$Name:([^%$]+)%$?$", "%1");
return nam
end
i = i + 1
if i > 10 then
break
end
end
end
room {
title = "Выбор игры";
nam = 'main';
dsc = function(s)
local games = {}
for d in std.readdir("games") do
if d ~= '.' and d ~= '..' then
local f = io.open("games/"..d.."/main3.lua", "r")
if f then
local name = get_name(f) or d
table.insert(games, {d, name})
f:close()
end
end
end
table.sort(games, function(a, b) return a[2] < b[2] end)
for _, v in ipairs(games) do
pn("{@select ", v[1], "|", v[2], "}");
end
end;
}