Skip to content

Instantly share code, notes, and snippets.

@gabyfle
Last active April 6, 2020 17:29
Show Gist options
  • Save gabyfle/ae524dea8634e2b0247057aa386776b4 to your computer and use it in GitHub Desktop.
Save gabyfle/ae524dea8634e2b0247057aa386776b4 to your computer and use it in GitHub Desktop.
Load materials from path
--- Loads all materials in a path
-- @param string path: path to analyse
-- @return table: a table containing every materials depending on
local function loadMaterials(path)
local files, directory = file.Find(path .. '*', 'GAME')
local materials = {}
for _, dir in pairs(directory) do -- launch the function in the other directories
table.Merge(materials, loadMaterials(path .. dir .. '/'))
end
for _, f in pairs(files) do
materials[string.GetFileFromFilename(f)] = Material(path .. f)
end
return materials
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment