New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional hooks for inventory manipulations callbacks. #4035
Conversation
@@ -510,7 +510,15 @@ core.registered_craft_predicts, core.register_craft_predict = make_registration( | |||
core.registered_on_protection_violation, core.register_on_protection_violation = make_registration() | |||
core.registered_on_item_eats, core.register_on_item_eat = make_registration() | |||
core.registered_on_punchplayers, core.register_on_punchplayer = make_registration() | |||
|
|||
core.registered_on_player_inventory_remove_item, core.register_on_player_inventory_remove_item = make_registration() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind the conventional plural-s on most other callback tables.
If you transfer an item from your creative inventory to a chest this will trigger at least two callbacks for essentially the same action. Can't you just pass the You could even combine all 9 into a single callback: --- passed to core.register_on_inventory_change
function(from_inv, from_list, from_slot, to_inv, to_list, to_slot, stack, player)
-- maybe we can allow to interrupt the inventory action? Or maybe even change it.
return
end The parameters might seem a bit long, but if you account for the additional Coming to think of it, why don't node callbacks do something similar? |
@t4im There is a reason for this. If you look up C++ code, you will see, that every change made passed by "InventoryList" object functions. Currently you can directly access lists and change their contents without using inventory object. As well, not only player can do so, but any script. As well you can get inventory reference from first argument of callback function (detached name or player or position). You are free to fork my work and modify it a way you want to. |
Please squash commits to make it easier to review. |
@paramat Pull is rewritten on fresh version. Commits are squashed. |
Geting rid of another old branch fixing bugs
What's the intended usage for |
@sfan5 there is no such. Because callbacks implemented on server side inside InventoryList class, InventoryChangesReciever class, as Rubenwardy suggest, implemented in any inventory type, including detached and nodemeta. It could be used to trace all item movements for all players and mod actions. But I absolutely don't care about such movements. |
Replaced with #5647 |
Well, i screwed a little when i tried to remove 'minetest.clear_craft' from old master branch, so here is a new pull request.
For those, who does not saw #3962 this pull will add modding API function, which allow modders to trace any inventory changes (detached, nodemeta or player).