s_inventory.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include "cpp_api/s_base.h"
  18. struct MoveAction;
  19. struct ItemStack;
  20. class ScriptApiDetached
  21. : virtual public ScriptApiBase
  22. {
  23. public:
  24. /* Detached inventory callbacks */
  25. // Return number of accepted items to be moved
  26. int detached_inventory_AllowMove(
  27. const MoveAction &ma, int count,
  28. ServerActiveObject *player);
  29. // Return number of accepted items to be put
  30. int detached_inventory_AllowPut(
  31. const MoveAction &ma, const ItemStack &stack,
  32. ServerActiveObject *player);
  33. // Return number of accepted items to be taken
  34. int detached_inventory_AllowTake(
  35. const MoveAction &ma, const ItemStack &stack,
  36. ServerActiveObject *player);
  37. // Report moved items
  38. void detached_inventory_OnMove(
  39. const MoveAction &ma, int count,
  40. ServerActiveObject *player);
  41. // Report put items
  42. void detached_inventory_OnPut(
  43. const MoveAction &ma, const ItemStack &stack,
  44. ServerActiveObject *player);
  45. // Report taken items
  46. void detached_inventory_OnTake(
  47. const MoveAction &ma, const ItemStack &stack,
  48. ServerActiveObject *player);
  49. private:
  50. bool getDetachedInventoryCallback(
  51. const std::string &name, const char *callbackname);
  52. };