take – "require" in top directories


I have a program in Lua. This is the structure of the files:


Through functions.lua , I want to require config.lua . Is there any way?

Already tried:

require "../config"
require "..\\config"


Before require you must set the path of the package, say in which files to look for the module:

package.path = package.path .. ";../config.lua"
require "config"

I put it on GitHub for future reference .

Note that the usage is similar to what is done with operating systems path . You add a new path to what already exists so you don't lose the others.

Scroll to Top