1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 809 210 194 156 # CONTENT_SAND 80a 123 123 123 # CONTENT_COBBLE 80b 199 199 199 # CONTENT_STEEL 80c 183 183 222 # CONTENT_GLASS 80d 219 202 178 # CONTENT_MOSSYCOBBLE 80e 70 70 70 # CONTENT_GRAVEL 80f 204 0 0 # CONTENT_SANDSTONE 810 0 215 0 # CONTENT_CACTUS 811 170 50 25 # CONTENT_BRICK 812 104 78 42 # CONTENT_CLAY 813 58 105 18 # CONTENT_PAPYRUS 814 196 160 0 # CONTENT_BOOKSHELF 815 205 190 121 # CONTENT_JUNGLETREE 816 62 101 25 # CONTENT_JUNGLEGRASS 817 255 153 255 # CONTENT_NC 818 102 50 255 # CONTENT_NC_RB 819 200 0 0 # CONTENT_APPLE default:stone 128 128 128 default:stone_with_coal 50 50 50 default:water_flowing 39 66 106 default:torch 255 255 0 default:water_source 39 66 106 default:sign_wall 117 86 41 default:chest 128 79 0 default:furnace 118 118 118 default:fence_wood 103 78 42 default:rail 162 119 53 default:ladder 154 110 40 default:lava_flowing 255 100 0 default:lava_source 255 100 0 default:dirt_with_grass 107 134 51 default:tree 86 58 31 default:leaves 48 95 8 default:dirt_with_grass_and_footsteps 102 129 38 default:mese 178 178 0 default:dirt 101 84 36 default:wood 104 78 42 default:sand 210 194 156 default:cobble 123 123 123 default:steelblock 199 199 199 default:glass 183 183 222 default:mossycobble 219 202 178 default:gravel 70 70 70 default:sandstone 204 0 0 default:cactus 0 215 0 default:brick 170 50 25 default:clay 104 78 42 default:papyrus 58 105 18 default:bookshelf 1/* Minetest Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #pragma once #include "lua_api/l_base.h" #include "inventory.h" #include "inventorymanager.h" class RemotePlayer; /* InvRef */ class InvRef : public ModApiBase { private: InventoryLocation m_loc; static const char className[]; static const luaL_Reg methods[]; static InvRef *checkobject(lua_State *L, int narg); static Inventory* getinv(lua_State *L, InvRef *ref); static InventoryList* getlist(lua_State *L, InvRef *ref, const char *listname); static void reportInventoryChange(lua_State *L, InvRef *ref); // Exported functions // garbage collector static int gc_object(lua_State *L); // is_empty(self, listname) -> true/false static int l_is_empty(lua_State *L); // get_size(self, listname) static int l_get_size(lua_State *L); // get_width(self, listname) static int l_get_width(lua_State *L); // set_size(self, listname, size) static int l_set_size(lua_State *L); // set_width(self, listname, size) static int l_set_width(lua_State *L); // get_stack(self, listname, i) -> itemstack static int l_get_stack(lua_State *L); // set_stack(self, listname, i, stack) -> true/false static int l_set_stack(lua_State *L); // get_list(self, listname) -> list or nil static int l_get_list(lua_State *L); // 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); // room_for_item(self, listname, itemstack or itemstring or table or nil) -> true/false // 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, [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); // remove_item(self, listname, itemstack or itemstring or table or nil) -> itemstack // Returns the items that were actually removed static int l_remove_item(lua_State *L); // get_location() -> location (like get_inventory(location)) static int l_get_location(lua_State *L); public: InvRef(const InventoryLocation &loc); ~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, RemotePlayer *player); static void createNodeMeta(lua_State *L, v3s16 p); static void Register(lua_State *L); }; class ModApiInventory : public ModApiBase { private: static int l_create_detached_inventory_raw(lua_State *L); static int l_remove_detached_inventory_raw(lua_State *L); static int l_get_inventory(lua_State *L); public: static void Initialize(lua_State *L, int top); };