function includeAllEnts()
local directory = "entities"
local entities = love.filesystem.enumerate(directory)
for i, e in ipairs(entities) do
require(e)
end
end
function includeAllEnts()
local directory = "entities"
local entities = love.filesystem.enumerate(directory)
for i, e in ipairs(entities) do
require(directory .. "." .. e)
end
end
function includeAllEnts()
local directory = "entities"
local entities = love.filesystem.enumerate(directory)
for i, e in ipairs(entities) do
require(directory .. "." .. e)
end
end
I get the lua error attempt to call field 'enumerate' a nil value.
require "love.filesystem"
function includeAllEnts()
local dir = "entities"
local entities = love.filesystem.getDirectoryItems(dir)
for k, ents in ipairs(entities) do
trim = string.gsub(ents, ".lua", "")
require(trim)
end
end
function requireDirectory( dir )
dir = dir or ""
local entities = love.filesystem.getDirectoryItems(dir)
for k, ents in ipairs(entities) do
trim = string.gsub( ents, ".lua", "")
require(dir .. "/" .. trim)
end
end
Otherwise this should only require all files in the root directory, if I'm not mistaken.
I also think passing the directory as a parameter is convenient.
You don't need to require love.filesystem as well, all love modules are loaded unless deactivated in the config file.