lua-users home
lua-l archive

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

I have a lua interpreter embedded in my program and want to execute
some scripts.
The scripts are located in folder "scripts". One script requires
another like this:

1.script ("scripts/myscript.lua"):
2.script ("scripts/base.lua"):

Now when I call my executable from within the "script" directory,
everything is fine since "." is in the Lua load path.
"executable myscript.lua"

But when I call it from anywhere else, the require "base" is not found:
"executable scripts/myscript.lua"
run-error - [string "script/myscript.lua"]:1: module 'base' not found..

In ruby I can resolve this issue by adding the directory of the
myscript.lua file to the load path:

$:.unshift File.dirname(__FILE__)
Can anybody tell me how I this is done in Lua?