Add: functions to_array, to_table, iterate

This commit is contained in:
Coder12a 2019-05-20 00:02:43 -05:00
parent 63cfeb4cb9
commit 8395ee0d41

View File

@ -271,5 +271,35 @@ function colddb.Colddb(dir)
return db
end
self.to_array = function()
local entries = {}
for k, v in pairs(minetest.get_dir_list(directory)) do
entries[#entries + 1] = v:sub(0, v:len() - 5)
end
return entries
end
self.to_table = function()
local entries = {}
for k, v in pairs(minetest.get_dir_list(directory)) do
entries[v:sub(0, v:len() - 5)] = true
end
return entries
end
self.iterate = function()
local entries = {}
for k, v in pairs(minetest.get_dir_list(directory)) do
entries[v:sub(0, v:len() - 5)] = true
end
return pairs(entries)
end
return self
end