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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Lovingsoul1337
Prole
Posts: 32
Joined: Fri Feb 21, 2020 1:26 pm

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

Post 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
MrFariator
Party member
Posts: 243
Joined: Wed Oct 05, 2016 11:53 am

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

Post 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.
User avatar
pgimeno
Party member
Posts: 2575
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

Yeah, dots are used for module names in require(). Normal love.filesystem functions use slashes "/".
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests