From 9b1030cac4409b262dca73d2f0741fe78d4998ee Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 22 Aug 2020 15:45:06 +0200 Subject: Added minetest.get_inventory(location) --- src/script/common/c_content.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/script/common/c_content.cpp') diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 44b638ba7..9efa2c57f 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -1306,6 +1306,20 @@ void push_tool_capabilities(lua_State *L, lua_setfield(L, -2, "damage_groups"); } +/******************************************************************************/ +void push_inventory(lua_State *L, Inventory *inventory) +{ + std::vector lists = inventory->getLists(); + std::vector::iterator iter = lists.begin(); + lua_createtable(L, 0, lists.size()); + for (; iter != lists.end(); iter++) { + const char* name = (*iter)->getName().c_str(); + lua_pushstring(L, name); + push_inventory_list(L, inventory, name); + lua_rawset(L, -3); + } +} + /******************************************************************************/ void push_inventory_list(lua_State *L, Inventory *inv, const char *name) { -- cgit v1.2.3