diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-08-22 15:45:06 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-08-22 15:45:06 +0200 |
commit | 9b1030cac4409b262dca73d2f0741fe78d4998ee (patch) | |
tree | 4815f2122fd6b9778d0cc0f2cedb10389157f580 /src/script/lua_api/l_client.cpp | |
parent | 2321e3da4c7f29ae06400e91e4e031777c6a5d9a (diff) | |
download | dragonfireclient-9b1030cac4409b262dca73d2f0741fe78d4998ee.tar.xz |
Added minetest.get_inventory(location)
Diffstat (limited to 'src/script/lua_api/l_client.cpp')
-rw-r--r-- | src/script/lua_api/l_client.cpp | 22 |
1 files changed, 22 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); } |