There is an include folder, located next to the *.love file and containing other folders, which in turn may contain a meta.lua file. How to organize the passage of these folders and the connection @ execution of this file?

  • I connect scripts using dofile for example dofile scripts // anAL.lua - Marlin AK

2 answers 2

I use the lua-path library. It uses the LuaFileSystem. So you can only use it.

 local path = require "path" path.each('meta.lua', function(p) local fn = assert(loadstring(p)) fn() end, {recurse=true}) 
  • Can I get documentation? - Vidoom
  • All that is available can be found at github.com/moteus/lua-path . - moteus
  • Strange ... I can not call half the functions. Even from your example gives: attempt to call field 'each' (a nil value) - Vidoom
  • For Lua 5.1 you need to install bit32. - moteus
  • So this is the whole problem. Then LOVE2D does not run the library, because it has its own parser, not a system one. Therefore, I needed a solution on pure Lua. I took the library itself and put it in the folder with the project, I could not call the function - Vidoom

You can recurse using the built-in ex library

  require 'ex' local function CheckDir(curpath,d) local fullname = (curpath.."\\"..d.name):gsub("\\$","") print(fullname) for entry in os.dir(fullname) do if entry["type"]=="directory" then CheckDir(fullname, entry) end if entry["type"]=="file" then if entry.name=="meta.lua" then assert(loadfile( fullname .."\\" ..entry.name)) () end end end end local pathname = os.currentdir() local init = { ["type"]="directory", name="" } CheckDir( pathname, init ) 

In 5.1 lies here .. \ Lua \ 5.1 \ clibs \ ex.dll