Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: set cwd for executing lua script #271

Open
emcek opened this issue Sep 17, 2024 · 0 comments
Open

Question: set cwd for executing lua script #271

emcek opened this issue Sep 17, 2024 · 0 comments

Comments

@emcek
Copy link

emcek commented Sep 17, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant