diff options
| author | 2023-11-20 09:15:53 +0800 | |
|---|---|---|
| committer | 2023-11-20 09:15:53 +0800 | |
| commit | 7894ed73f929c6676242da3a1c3bd11d78d8e711 (patch) | |
| tree | a4890b78f8e8abcbfb2ec53422eea63604424a65 | |
| parent | 4c08ec908bfaba35c6055ee273a0768ba6749089 (diff) | |
| download | HydroRoll-7894ed73f929c6676242da3a1c3bd11d78d8e711.tar.gz HydroRoll-7894ed73f929c6676242da3a1c3bd11d78d8e711.zip | |
feat: 实现在 lua 脚本中调用被注册的 Python 同步函数与类
| -rw-r--r-- | tests/lua_in_python.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/lua_in_python.py b/tests/lua_in_python.py index 34deaab..eec2042 100644 --- a/tests/lua_in_python.py +++ b/tests/lua_in_python.py @@ -9,4 +9,27 @@ except ImportError: except ImportError: import lupa -print(f"Using {lupa.LuaRuntime().lua_implementation} (compiled with {lupa.LUA_VERSION})")
\ No newline at end of file +print( + f"Using {lupa.LuaRuntime().lua_implementation} (compiled with {lupa.LUA_VERSION})" +) + +from lupa import LuaRuntime + +lua = LuaRuntime(unpack_returned_tuples=True) +import asyncio + +async def get_Dice_Dir(): + import os + await asyncio.sleep(1) + return os.path.dirname(os.path.abspath(__file__)) + + +lua.globals().getDiceDir = get_Dice_Dir + +print( + lua.eval( + """\ + getDiceDir() + """ + ) +) |
