Reputation: 119
I have a visual studio project with c++ code calling lua files.
I try to load a lua module but it cannot be find. If understand correctly, package.path can be set i.a. via LUA_PATH environment variable. So before running the lua file i call a script with the lines to set the path to the parent folder of the lua module:
set LUA_PATH=%LUA_PATH%;C:\Users\xyz\lua
Then in the lua file i try to concat the search path with strings, but doesnt work:
package.path = package.path .. "./?.lua;"
edit:
output of print(package.path)
:
;C:\Users\xyz\lua;./?.lua;
but i want
;C:\Users\xyz\lua\?.lua;
edit: I forgot to the delete the semicolon at the end of LUA_PATH. Now it works without the package.path line.
Upvotes: 1
Views: 8925
Reputation: 118097
set LUA_PATH=%LUA_PATH%;C:\Users\xyz\lua
That adds a ;
infront of C:\Users\xyz\lua
unless LUA_PATH
already contains something. You might want something like this instead:
IF DEFINED LUA_PATH (
set LUA_PATH=%LUA_PATH%;
)
set LUA_PATH=%LUA_PATH%C:\Users\xyz\lua
package.path = package.path .. "./?.lua;"
That adds a ;
at the end and also adds ./
where you probably want \
so try this instead:
package.path = package.path .. "\\?.lua"
Upvotes: 1