added lessons!
This commit is contained in:
30
lessons.lua
Normal file
30
lessons.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
-- 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
|
||||
Reference in New Issue
Block a user