detached.lua 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ---@meta
  2. ---Detached inventory callbacks
  3. -------------------------------
  4. -- Used by `minetest.create_detached_inventory`.
  5. ---@class mt.DetachedInvDef
  6. local did = {}
  7. -- Called when a player wants to move items inside the inventory.
  8. --
  9. -- * Moving items in the inventory.
  10. -- * The `allow_*` callbacks return how many items can be moved.
  11. -- * This callback triggered `before` the action.
  12. ---@param inv mt.InvRef
  13. ---@param from_list string
  14. ---@param from_index number
  15. ---@param to_list string
  16. ---@param to_index number
  17. ---@param count number
  18. ---@param player mt.PlayerObjectRef
  19. ---@return number items_allowed_count
  20. function did.allow_move(inv, from_list, from_index, to_list, to_index, count, player) end
  21. -- Called after the actual action has happened, according to what was allowed.
  22. --
  23. -- * Moving items in the inventory.
  24. -- * The `on_*` callbacks are called after the items have been placed in the inventories.
  25. -- * This callback triggered `after` the action.
  26. ---@param inv mt.InvRef
  27. ---@param from_list string
  28. ---@param from_index number
  29. ---@param to_list string
  30. ---@param to_index number
  31. ---@param count number
  32. ---@param player mt.PlayerObjectRef
  33. function did.on_move(inv, from_list, from_index, to_list, to_index, count, player) end
  34. -- Called when a player wants to put something into the inventory.
  35. --
  36. -- * Putting items to the inventory.
  37. -- * The `allow_*` callbacks return how many items can be moved.
  38. -- * This callback triggered `before` the action.
  39. ---@param inv mt.InvRef
  40. ---@param listname string
  41. ---@param index integer
  42. ---@param stack mt.Item
  43. ---@param player mt.PlayerObjectRef
  44. -- If `-1`: Allow and don't modify item count in inventory.
  45. ---@return number items_allowed_count
  46. function did.allow_put(inv, listname, index, stack, player) end
  47. -- Called after the actual action has happened, according to what was allowed.
  48. --
  49. -- * Putting items to the inventory.
  50. -- * The `on_*` callbacks are called after the items have been placed in the inventories.
  51. -- * This callback triggered `after` the action.
  52. ---@param inv mt.InvRef
  53. ---@param listname string
  54. ---@param index integer
  55. ---@param stack mt.Item
  56. ---@param player mt.PlayerObjectRef
  57. function did.on_put(inv, listname, index, stack, player) end
  58. -- Called when a player wants to take something out of the inventory.
  59. --
  60. -- * Taking items from the inventory.
  61. -- * The `allow_*` callbacks return how many items can be moved.
  62. -- * This callback triggered `before` the action.
  63. ---@param inv mt.InvRef
  64. ---@param listname string
  65. ---@param index integer
  66. ---@param stack mt.Item
  67. ---@param player mt.PlayerObjectRef
  68. -- If `-1`: Allow and don't modify item count in inventory.
  69. ---@return number items_allowed_count
  70. function did.allow_take(inv, listname, index, stack, player) end
  71. -- Called after the actual action has happened, according to what was allowed.
  72. --
  73. -- * Taking items from the inventory.
  74. -- * The `on_*` callbacks are called after the items have been placed in the inventories.
  75. -- * This callback triggered `after` the action.
  76. ---@param inv mt.InvRef
  77. ---@param listname string
  78. ---@param index integer
  79. ---@param stack mt.Item
  80. ---@param player mt.PlayerObjectRef
  81. function did.on_take(inv, listname, index, stack, player) end