Setting LUA_PATH

This is such a simple question, but it doesn’t seem to work for me.

I want to set the path that LUA uses to look for modules (.lua files) as described here: http://www.thijsschreijer.nl/blog/?p=1025

So I can use module.lua from main without using the explicit path require(SubDir.moduleA) syntax, but rather just require(module.luaA) because I want moduleB to be able to use moduleA directly

top

|

  • main.lua

-SubDir

  |

  |- moduleA.lua

  |-moduleB.lua

Reason is I have two projects, and I want them to use some shared code.

I got round this for now by creating a symbolic link for each file - not very nice, but seems to work.

If you want to use the same code across multiple projects it might be best to shove the code in a Git repo and then just use it as a submodule.

I don’t think the Lua install that comes built-in to Corona behaves like stand-alone installs of Lua. You probably can’t make use of LUA paths like that.

You didn’t tell us:  OS X or Windows?  

I am a Windows user and use a single instance of SSK in almost all projects via a ‘junction’

This is what I have in a batch file for creating the junction as needed:

mklink /j .\ssk2 X:\Work\00\_CurentProjects\Corona\SSK2\ssk2

I suggest you gather all your common scripts under a single folder like I do with SSK.  Similarly, I have junctions for images/, sounds/, etc.

These folders have way more content that I use in any one release, but by having a consistent super-set of dev assets I can quickly get up and running while prototyping.

For example, I have another batch file with this in it:

rmdir ssk2 rmdir images rmdir sounds mklink /j .\ssk2 X:\Work\00\_CurentProjects\Corona\SSK2\ssk2 mklink /j .\images X:\C\_CommonResources\images mklink /j .\sounds X:\C\_CommonResources\sounds

OSX, deploy HTML5.

I think so, the Corona is special tweaked version of LUA.

Might do something like you describe here.

I got round this for now by creating a symbolic link for each file - not very nice, but seems to work.

If you want to use the same code across multiple projects it might be best to shove the code in a Git repo and then just use it as a submodule.

I don’t think the Lua install that comes built-in to Corona behaves like stand-alone installs of Lua. You probably can’t make use of LUA paths like that.

You didn’t tell us:  OS X or Windows?  

I am a Windows user and use a single instance of SSK in almost all projects via a ‘junction’

This is what I have in a batch file for creating the junction as needed:

mklink /j .\ssk2 X:\Work\00\_CurentProjects\Corona\SSK2\ssk2

I suggest you gather all your common scripts under a single folder like I do with SSK.  Similarly, I have junctions for images/, sounds/, etc.

These folders have way more content that I use in any one release, but by having a consistent super-set of dev assets I can quickly get up and running while prototyping.

For example, I have another batch file with this in it:

rmdir ssk2 rmdir images rmdir sounds mklink /j .\ssk2 X:\Work\00\_CurentProjects\Corona\SSK2\ssk2 mklink /j .\images X:\C\_CommonResources\images mklink /j .\sounds X:\C\_CommonResources\sounds

OSX, deploy HTML5.

I think so, the Corona is special tweaked version of LUA.

Might do something like you describe here.