Page 1 of 1

love.filesystem.getDirectoryItems("SimpleElementSystem.Systems")

Posted: Mon May 11, 2020 6:11 pm
by Lovingsoul1337
Hey there can you may help me ? For some reason i can't read the file and it doesnt print love

Code: Select all

local littlehelper = {}

function littlehelper.requireSystems()
  local systemTable = {}
  local systemName
  for k, v in ipairs(love.filesystem.getDirectoryItems("SimpleElementSystem.Systems")) do
    print("Love")
    systemName = "SimpleElementSystem.Systems." .. v:gsub("%.lua", "")
    table.insert(systemTable, require(systemName))
  end
return systemTable --intendation of this return good ?
end

return littlehelper
best regards

Michael

Re: love.filesystem.getDirectoryItems("SimpleElementSystem.Systems")

Posted: Mon May 11, 2020 7:28 pm
by MrFariator
As far as I know, love.filesystem paths are in the format of path/to/file only, so path.to.file doesn't work.
You may also want to be mindful of the exact casing on folder and file names; for example running code on Windows works fine if you mix the cases, but will fail when running from a .love or fused executable.

Re: love.filesystem.getDirectoryItems("SimpleElementSystem.Systems")

Posted: Mon May 11, 2020 8:04 pm
by pgimeno
Yeah, dots are used for module names in require(). Normal love.filesystem functions use slashes "/".