aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_client.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-08-22 15:45:06 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-08-22 15:45:06 +0200
commit9b1030cac4409b262dca73d2f0741fe78d4998ee (patch)
tree4815f2122fd6b9778d0cc0f2cedb10389157f580 /src/script/lua_api/l_client.cpp
parent2321e3da4c7f29ae06400e91e4e031777c6a5d9a (diff)
downloaddragonfireclient-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.cpp22
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);
}