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

load or run #209

Open
wuxindao opened this issue Sep 27, 2024 · 2 comments
Open

load or run #209

wuxindao opened this issue Sep 27, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@wuxindao
Copy link

使用party.iroiro.luajava.Lua.load 加载一个lua文件的时候,通过lua.get无法获取一个已加载的函数
使用party.iroiro.luajava.Lua.run 可以获取一个已加载的lua文件函数
请问,使用load的方式,如果最后来统一管理和获取一个函数

@wuxindao wuxindao added the bug Something isn't working label Sep 27, 2024
@wuxindao
Copy link
Author

wuxindao commented Sep 27, 2024

lua.run(xxxx)
lua.get(xx) 这样可以获取到我想要的函数

lua.load(xxxx)
lua.get(xx) nil 无法获取

因为lua.run() 加载文件的时候是直接运行,
当我
lua.run(a.lua)
lua.run(b.lua)
但是a.lua 文件会依赖b.lua 我并不一定清楚的知晓;
这时候lua.run(a.lua)就会异常

@gudzpoz
Copy link
Owner

gudzpoz commented Oct 6, 2024

Yes, Lua.load eventually uses lua_load, and it only loads a chunk; it does not run it (lua.org/manual/5.1/manual.html#lua_load). I guess I just assume people are familiar with Lua C API and I will probably need to add more documentation to the Lua.load methods.

If your Lua files depend on one another, you should modulize your Lua code and use require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants