diff options
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_client.cpp | 22 | ||||
-rw-r--r-- | src/script/lua_api/l_client.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 2306fa578..5d0ccf2e0 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -456,6 +456,27 @@ int ModApiClient::l_dig_node(lua_State *L) return 0; } +// get_inventory(location) +int ModApiClient::l_get_inventory(lua_State *L) +{ + Client *client = getClient(L); + InventoryLocation inventory_location; + Inventory *inventory; + std::string location; + + location = readParam<std::string>(L, 1); + + try { + inventory_location.deSerialize(location); + inventory = client->getInventory(inventory_location); + push_inventory(L, inventory); + } catch (SerializationError) { + lua_pushnil(L); + } + + return 1; +} + void ModApiClient::Initialize(lua_State *L, int top) { API_FCT(get_current_modname); @@ -486,4 +507,5 @@ void ModApiClient::Initialize(lua_State *L, int top) API_FCT(send_damage); API_FCT(place_node); API_FCT(dig_node); + API_FCT(get_inventory); } diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index 45c921f0d..21a540f8f 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -113,6 +113,9 @@ private: // dig_node(pos) static int l_dig_node(lua_State *L); + + // get_inventory(location) + static int l_get_inventory(lua_State *L); public: static void Initialize(lua_State *L, int top); }; |