conlang-heonian/lessons.lua
2022-05-05 11:29:09 +02:00

37 lines
859 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.."/content/lessons/")
if t[number] then
dofile("content/lessons/"..t[number])
else
print("lesson not found")
end
end
function lessonPause()
print("\nInput anything to continue")
io.read()
print(scrollTerminalUp(4))
end