1 /* 2 script/cpp_api/s_inventory.h 3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com> 4 */ 5 6 /* 7 This file is part of Freeminer. 8 9 Freeminer is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Freeminer is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Freeminer. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef S_INVENTORY_H_ 24 #define S_INVENTORY_H_ 25 26 #include "cpp_api/s_base.h" 27 28 struct ItemStack; 29 30 class ScriptApiDetached 31 : virtual public ScriptApiBase 32 { 33 public: 34 /* Detached inventory callbacks */ 35 // Return number of accepted items to be moved 36 int detached_inventory_AllowMove( 37 const std::string &name, 38 const std::string &from_list, int from_index, 39 const std::string &to_list, int to_index, 40 int count, ServerActiveObject *player); 41 // Return number of accepted items to be put 42 int detached_inventory_AllowPut( 43 const std::string &name, 44 const std::string &listname, int index, ItemStack &stack, 45 ServerActiveObject *player); 46 // Return number of accepted items to be taken 47 int detached_inventory_AllowTake( 48 const std::string &name, 49 const std::string &listname, int index, ItemStack &stack, 50 ServerActiveObject *player); 51 // Report moved items 52 void detached_inventory_OnMove( 53 const std::string &name, 54 const std::string &from_list, int from_index, 55 const std::string &to_list, int to_index, 56 int count, ServerActiveObject *player); 57 // Report put items 58 void detached_inventory_OnPut( 59 const std::string &name, 60 const std::string &listname, int index, ItemStack &stack, 61 ServerActiveObject *player); 62 // Report taken items 63 void detached_inventory_OnTake( 64 const std::string &name, 65 const std::string &listname, int index, ItemStack &stack, 66 ServerActiveObject *player); 67 private: 68 bool getDetachedInventoryCallback( 69 const std::string &name, const char *callbackname); 70 }; 71 72 73 74 #endif /* S_INVENTORY_H_ */ 75