lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of steve donovan
> Sent: woensdag 19 maart 2014 7:29
> To: Lua mailing list
> Subject: Re: "Include" lua-file
> 
> On Wed, Mar 19, 2014 at 5:36 AM,  <meino.cramer@gmx.de> wrote:
> > Is it possible to create an "include" for lua the clean way without
> > modifying the lua installations settings like library-paths?
> 
> You can modify the global package.path yourself, if you know your own
> directory:
> 
> package.path = mydir..'/?.lua;'..package.path
> 
> Then require 'a4msdata.lua' works as you want.
> 
> So the problem is how to find the directory of your script...look at
> arg[0] and extract its path.
> 
> require_here() in pl.app works like this (Penlight)

You may also try the datafile module [1] by Hisham. It loads relative from the calling script, from a config directory, or the LuaRocks tree (file in the 'copydirectories' element of the rockspec). It works on a similar concept as the loaders used by require().

Thijs

[1] https://github.com/hishamhm/datafile