diff --git a/docs/bindings_lua.md b/docs/bindings_lua.md index 7bf9f36b..ce3b2863 100644 --- a/docs/bindings_lua.md +++ b/docs/bindings_lua.md @@ -5,7 +5,8 @@ order: 17 --- pkpy provides a lua bridge to reuse lua bindings. -It allows you to run lua code and call lua functions in python. +It allows you to run lua code and call lua functions in python +by embed a lua virtual machine. Add `lua_bridge.hpp` and `lua_bridge.cpp` in [3rd/lua_bridge](https://github.com/blueloveTH/pocketpy/tree/main/3rd/lua_bridge) to your project. Make sure `lua.h`, `lualib.h` and `lauxlib.h` are in your include path @@ -47,6 +48,20 @@ class Table: def __setattr__(self, key, value): ... ``` +Only basic types can be passed between python and lua. +The following table shows the type mapping. +If you pass an unsupported type, an exception will be raised. + +| Python Type | Lua Type | +| ----------- | -------- | +| None | nil | +| bool | boolean | +| int | number | +| float | number | +| str | string | +| lua.Table | table | +| lua.Function| function | + ### Example ```cpp #include "lua_bridge.hpp"