]> git.lizzy.rs Git - minetest.git/blobdiff - src/script/lua_api/l_inventory.h
Support packing arbitrary graphs (#12289)
[minetest.git] / src / script / lua_api / l_inventory.h
index 83e8039b85c1073c52a1b94901e2df38810facaf..6a75bac0f38e4e8a4fcd080dab8462e6ec1294e0 100644 (file)
@@ -17,31 +17,25 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef L_INVENTORY_H_
-#define L_INVENTORY_H_
+#pragma once
 
-extern "C" {
-#include <lua.h>
-#include <lauxlib.h>
-}
+#include "lua_api/l_base.h"
 
-#include "inventorymanager.h"
-#include "player.h"
-#include "serverobject.h"
 #include "inventory.h"
+#include "inventorymanager.h"
+
+class RemotePlayer;
 
-#include "lua_api/l_base.h"
 /*
        InvRef
 */
 
-class InvRef
-{
+class InvRef : public ModApiBase {
 private:
        InventoryLocation m_loc;
 
        static const char className[];
-       static const luaL_reg methods[];
+       static const luaL_Reg methods[];
 
        static InvRef *checkobject(lua_State *L, int narg);
 
@@ -84,6 +78,12 @@ class InvRef
        // set_list(self, listname, list)
        static int l_set_list(lua_State *L);
 
+       // get_lists(self) -> list of InventoryLists
+       static int l_get_lists(lua_State *L);
+
+       // set_lists(self, lists)
+       static int l_set_lists(lua_State *L);
+
        // add_item(self, listname, itemstack or itemstring or table or nil) -> itemstack
        // Returns the leftover stack
        static int l_add_item(lua_State *L);
@@ -92,7 +92,7 @@ class InvRef
        // Returns true if the item completely fits into the list
        static int l_room_for_item(lua_State *L);
 
-       // contains_item(self, listname, itemstack or itemstring or table or nil) -> true/false
+       // contains_item(self, listname, itemstack or itemstring or table or nil, [match_meta]) -> true/false
        // Returns true if the list contains the given count of the given item name
        static int l_contains_item(lua_State *L);
 
@@ -100,38 +100,28 @@ class InvRef
        // Returns the items that were actually removed
        static int l_remove_item(lua_State *L);
 
-       // get_location() -> location (like minetest.get_inventory(location))
+       // get_location() -> location (like get_inventory(location))
        static int l_get_location(lua_State *L);
 
 public:
        InvRef(const InventoryLocation &loc);
 
-       ~InvRef();
+       ~InvRef() = default;
 
        // Creates an InvRef and leaves it on top of stack
        // Not callable from Lua; all references are created on the C side.
        static void create(lua_State *L, const InventoryLocation &loc);
-       static void createPlayer(lua_State *L, Player *player);
-       static void createNodeMeta(lua_State *L, v3s16 p);
        static void Register(lua_State *L);
 };
 
-class ModApiInventory
-       : public ModApiBase
-{
-public:
-       ModApiInventory();
+class ModApiInventory : public ModApiBase {
+private:
+       static int l_create_detached_inventory_raw(lua_State *L);
 
-       bool Initialize(lua_State *L, int top);
+       static int l_remove_detached_inventory_raw(lua_State *L);
 
-       static int l_create_detached_inventory_raw(lua_State *L);
        static int l_get_inventory(lua_State *L);
-private:
-       static void inventory_set_list_from_lua(Inventory *inv, const char *name,
-                       lua_State *L, int tableindex, int forcesize);
-       static void inventory_get_list_to_lua(Inventory *inv, const char *name,
-                       lua_State *L);
 
+public:
+       static void Initialize(lua_State *L, int top);
 };
-
-#endif /* L_INVENTORY_H_ */