Question:
I have a program in Lua. This is the structure of the files:
|Programa
|-Main.lua
|-config.lua
|--------functions
|-functions.lua
Through functions.lua
, I want to require
config.lua
. Is there any way?
Already tried:
require "../config"
require "..\\config"
Answer:
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.