lupa icon indicating copy to clipboard operation
lupa copied to clipboard

Question: set cwd for executing lua script

Open emcek opened this issue 5 months ago • 0 comments

Hello, I need run local lua script (which I can't change)i.e. c:\lua_stuff\some_proj\local.lua I want use lupa. Can I pass file directly to lupa or use something like:

import lupa.luajit21 as lupa
lua = lupa.LuaRuntime()
with open('c:\\lua_stuff\\some_proj\\local.lua', 'r') as lua_file:
    lua_script = lua_file.read()
lua.execute(lua_script)
result = lua.globals().result
print(result)

But there is a problem because local.lua use relative paths so in order to run it I need be in c:\lua_stuff\ directory

PS C:\lua_stuff> lua .some_proj\local.lua

and since script do to return anything, can I check return code or something?

emcek avatar Sep 17 '24 11:09 emcek