diff options
author | Lukas Pioch <lukas@zgow.de> | 2017-07-28 12:11:07 +0200 |
---|---|---|
committer | Lukas Pioch <lukas@zgow.de> | 2017-08-27 14:54:40 +0200 |
commit | c171b272d96453f1a9d13d4623ac4bd3aa7d19e8 (patch) | |
tree | 32828d71b3de14de7489b080f07066dcf49e913e /src/Bindings/ManualBindings.cpp | |
parent | Implement anvil chunk sparsing (diff) | |
download | cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.gz cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.bz2 cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.lz cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.xz cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.zst cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.zip |
Diffstat (limited to 'src/Bindings/ManualBindings.cpp')
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index c87e9ed20..b6ef2b275 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -3967,6 +3967,62 @@ static int tolua_cEntity_GetSpeed(lua_State * tolua_S) +static int tolua_cBookContent_GetPages(lua_State * tolua_S) +{ + // cBookContent::GetPages() -> table of strings + + cLuaState L(tolua_S); + if (!L.CheckParamSelf("cBookContent")) + { + return 0; + } + + cBookContent * BookContent = reinterpret_cast<cBookContent *>(tolua_tousertype(tolua_S, 1, nullptr)); + L.Push(BookContent->GetPages()); + return 1; +} + + + + + +static int tolua_cBookContent_SetPages(lua_State * tolua_S) +{ + // cBookContent::SetPages(table) + + cLuaState L(tolua_S); + if ( + !L.CheckParamSelf("cBookContent") || + !L.CheckParamTable(2)) + { + return 0; + } + + cBookContent * BookContent = reinterpret_cast<cBookContent *>(tolua_tousertype(tolua_S, 1, nullptr)); + + // Convert the input table into AStringVector: + AStringVector Pages; + int NumPages = luaL_getn(L, 2); + Pages.reserve(static_cast<size_t>(NumPages)); + for (int i = 1; i <= NumPages; i++) + { + lua_rawgeti(L, 2, i); + AString Page; + L.GetStackValue(-1, Page); + if (!Page.empty()) + { + Pages.push_back(Page); + } + lua_pop(L, 1); + } + BookContent->SetPages(Pages); + return 0; +} + + + + + void cManualBindings::Bind(lua_State * tolua_S) { tolua_beginmodule(tolua_S, nullptr); @@ -4194,6 +4250,11 @@ void cManualBindings::Bind(lua_State * tolua_S) tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, nullptr); tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cBookContent"); + tolua_function(tolua_S, "GetPages", tolua_cBookContent_GetPages); + tolua_function(tolua_S, "SetPages", tolua_cBookContent_SetPages); + tolua_endmodule(tolua_S); + BindNetwork(tolua_S); BindRankManager(tolua_S); BindWorld(tolua_S); |