conlang-heonian/lessons.lua
UndeadMaelys 38fb2f7a51 lesson
2022-03-31 10:09:28 +02:00

37 lines
843 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
function lessonPause()
print("\nInput anything to continue")
io.read()
print(scrollTerminalUp(4))
end