"require" in higher directories

3

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 give require to config.lua . Is there any way?

I've tried:

require "../config"
require "..\config"
    
asked by anonymous 20.11.2014 / 19:11

1 answer

1

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

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

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

    
20.11.2014 / 19:19