test.lua 556 B

123456789101112131415161718192021
  1. rr.register_on_player_inventory_change(
  2. function(player, old_item, new_item, index, action_name)
  3. minetest.log( -- dump changes
  4. ("%s #%s: [ %s %s ] >> [ %s %s ] %s"):format(
  5. player:get_player_name(),
  6. index,
  7. old_item:get_name(),
  8. old_item:get_count(),
  9. new_item:get_name(),
  10. new_item:get_count(),
  11. action_name
  12. )
  13. )
  14. if new_item:get_count() >= old_item:get_count() then
  15. minetest.log "item number increased"
  16. return
  17. end
  18. minetest.log "item number decreased"
  19. end
  20. )