[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: loading lua scripts relative to an app's path
- From: Nick Gammon <nick@...>
- Date: Sat, 7 Oct 2006 16:38:33 +1000
On 06/10/2006, at 6:02 PM, Wesley Smith wrote:
How does eveyone determine the location of scripts relative to their
application? I've been racking my brain on this one and haven't found
a solution yet.
This has become an increasing problem as more users are using Lua in
my case, and distributing scripts for other people who may have
different directory structures.
I ended up providing an API (callable from Lua) that gave the current
directory, as well as the directory the script ran from (not
necessarily the same thing).
A related issue is that in the package.path setup, any "!" symbols
are expanded to the execution directory, but only at load time for
the package module.
That is, if you change package.path to something else, like this:
package.path = "!\?.lua"
... and then attempt to load something, you will simply get the "!"
in the filename, not the execution directory.
Personally I think it would be better to expand out the "!" every
time, otherwise you are stuck with the default paths, if you want to
use the execution directory.
- Nick