local FolderLoader = Object:extend() local BeastFile = require "classes.beastfile" function FolderLoader.getAllDatas(value) local folderLoader = FolderLoader(value) return folderLoader:getDatas() end function FolderLoader:new(value) self.folder = "data/" .. value.folder self.data = {} self.data.nom = value.nom self.data.list = {} self.files = {} for _, filename in ipairs(utils.scandir(self.folder)) do local file = utils.split(filename, ".", true) if (file[2] == "beast") then table.insert(self.files, BeastFile(self.folder, filename)) else print("[WARNING] Unknown extension " .. file[2] .. " for " .. filename) end end end function FolderLoader:prepareJson() for _, file in ipairs(self.files) do table.insert(self.data.list, file:prepareJson()) end end function FolderLoader:getDatas() self:prepareJson() return self.data end return FolderLoader