31 lines
734 B
Lua
31 lines
734 B
Lua
-- Source https://stackoverflow.com/a/11130774
|
|
function scandir(directory)
|
|
local directory = directory or ""
|
|
local i, t, popen = 0, {}, io.popen
|
|
local pfile = popen('ls "'..directory..'"')
|
|
for filename in pfile:lines() do
|
|
i = i + 1
|
|
t[i] = filename
|
|
end
|
|
pfile:close()
|
|
return t
|
|
end
|
|
|
|
function getFormattedLessonNames(directory)
|
|
local t = scandir(directory)
|
|
for i=1, #t do
|
|
t[i] = colorTextBackground(COLOR.Black,"\n#" .. i .. " " .. colorText(COLOR.HighBlue,string.gsub(t[i],".lua","")))
|
|
end
|
|
return t
|
|
end
|
|
|
|
function lesson(number)
|
|
number = tonumber(number)
|
|
local t = scandir(dir.."/lessons/")
|
|
if t[number] then
|
|
dofile("lessons/"..t[number])
|
|
else
|
|
print("lesson not found")
|
|
end
|
|
end
|