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. #3962
Conversation
@@ -523,6 +523,43 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame | |||
} | |||
} | |||
|
|||
InventoryLocation from_loc; | |||
if(from_inv.type == InventoryLocation::NODEMETA) |
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.
we use
if (condition) {
code;
}
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.
Should i edit my patch immediately for this pull to be accepted, or this is just a note for a future?
Why did you change |
It looks like |
Please could you explain more what this would be useful for? What is an overweight inventory effect? |
@paramat i am guessing that it means slowing down the player movement (ie: set_physics_override) when the player carry too many stuff. |
@paramat asl97 guessed absolutely correctly. First i have idea to make a mod, which will limit player carrying capacity by weight of carried items, secondly i found out - there is not enought callbacks to do so, third - i made a nessesary callbacks and create this request. |
@paramat second option - detect whenever player take something radioactive, for example, enriched uranium fuel and add effects of radiation sickness. Or opposite - some magic device, which will heal player. |
Can this be accomplished by not adding Otherwise, the idea is good, however you should do only one commit for this change, and add a meaningful commit description. |
@est31 commit? You mean - change only one file? Or do not change files after this request created? |
Each commit can update multiple files. There should only be one entry here ideally: https://github.com/minetest/minetest/pull/3962/commits The merger can squash your commits, though |
Updating to actual version
This is missing documentation in I would prefer if this would work without adding |
|
Added description for: * minetest.register_on_inventory_move_item * minetest.register_on_inventory_add_item * minetest.register_on_inventory_drop_item * ObjRev:add_item
@PilzAdam This could be done. But for my purposes i need player reference. And i have no idea how to extract player reverence from |
I don't like that the callbacks are only called if I think that the new So, 👎 to this implementation. The general idea of this PR is good, tough. |
@PilzAdam |
@Foghrye4 every mod that calls |
@PilzAdam 100% of them do so on
|
Changes to be committed: modified: builtin/game/register.lua modified: src/content_nodemeta.cpp modified: src/content_nodemeta.h modified: src/game.cpp modified: src/inventory.cpp modified: src/inventory.h modified: src/inventorymanager.cpp modified: src/inventorymanager.h modified: src/mapblock.cpp modified: src/network/clientpackethandler.cpp modified: src/nodemetadata.cpp modified: src/nodemetadata.h modified: src/player.cpp modified: src/player.h modified: src/rollback_interface.cpp modified: src/script/common/c_content.cpp modified: src/script/cpp_api/s_inventory.cpp modified: src/script/cpp_api/s_inventory.h modified: src/script/cpp_api/s_nodemeta.cpp modified: src/script/cpp_api/s_nodemeta.h modified: src/script/cpp_api/s_player.cpp modified: src/script/cpp_api/s_player.h modified: src/script/lua_api/l_inventory.cpp modified: src/script/lua_api/l_nodemeta.cpp modified: src/server.cpp modified: src/serverobject.cpp modified: src/unittest/test_inventory.cpp
@rubenwardy here is a realisation of your idea. I will change some things (will remove Player parameter from ScriptApiPlayer functions and InvRef from Lua call, will update lua_api.txt). I would like to see your opinion and opinion of others members. |
There is 'minetest.clear_craft(recipe)' in this pull request as well here now. It was properly checked in all possible uses. This function allow modders remove previously registered recipes either by output or by input and type (including "fuel" and "cooking"). Plus, removed recipes no longer visible via crafting guides, because they eliminated from registry. |
@Foghrye4 can you open a separate PR for that, its unrelated to this change. |
@est31 As you wish. |
This reverts commit 70b50ab.
What if i try this?.. Fucking github.
With three new callbacks (on inventory itemstack add, move and drop) modders will be able to trace inventory state at any moment without need to iterate thru all players inventories. This way we can make, for example, overweight inventory effects.