Differing paths for lua script and app

Posted by Person on Stack Overflow See other posts from Stack Overflow or by Person
Published on 2010-03-22T00:28:30Z Indexed on 2010/03/22 0:31 UTC
Read the original article Hit count: 598

Filed under:
|

My problem is that I'm having trouble specifying paths for Lua to look in.

For example, in my script I have a require("someScript") line that works perfectly (it is able to use functions from someScript when the script is run standalone.

However, when I run my app, the script fails. I believe this is because Lua is looking in a location relative to the application rather than relative to the script.

Hardcoding the entire path down to the drive isn't an option since people can download the game wherever they like so the highest I can go is the root folder for the game.

We have XML files to load in information on objects. In them, when we specify the script the object uses, we only have to do something like Content\Core\Scripts\someScript.lua where Content is in the same directory as Debug and the app is located inside Debug. If I try putting that (the Content\Core...) in Lua's package.path I get errors when I try to run the script standalone.

I'm really stuck, and am not sure how to solve this. Any help is appreciated. Thanks.

P.S. When I print out the default package.path in the app I see syntax like ;.\?.lua in a sequence like...

;.\?.lua;c:...(long file path)\Debug\?.lua; I assume the ; means the end of the path, but I have no idea what the .\?.lua means. Any Lua file in the directory?

© Stack Overflow or respective owner

Related posts about lua

Related posts about c++