[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Inferring the location of a Lua script
- From: steve donovan <steve.j.donovan@...>
- Date: Fri, 30 Apr 2010 09:58:56 +0200
On Fri, Apr 30, 2010 at 8:09 AM, Stuart P. Bentley
<stuart@testtrack4.com> wrote:
> If your script is run in the same place as the application, I've heard
> Windows replaces ! or !! with the path up to the running executable.
On Unix, typically you write your Lua script like so and make it executable:
-- ltest
#!/usr/local/bin/lua
print('I am '..arg[0])
And you get exactly what you need from arg[0]
~$ ltest
I am /home/sdonovan/bin/ltest
OK, for a multi-line program, you would like to put the code (+
resources) somewhere else. So the launcher script would probably look
like
/usr/local/bin/lua /path/to/my/script.lus
in which case, arg[0] will still give you exactly what you need, after
scraping away the filename part.
So, when does one _have_ to use the debug API?
steve d.