minetest-mods / craftguide

:book: The most comprehensive Crafting Guide on Minetest
Other
43 stars 20 forks source link

Update list of discovered items after player inventory change #78

Closed Wuzzy2 closed 4 years ago

Wuzzy2 commented 5 years ago

In 5.0.0 it is now possible to detect when a player inventory changed:

minetest.register_on_player_inventory_action

Currently, this mod updates the progressive mode discovered items by polling. I request this behaviour to be optimized accordingly.

p-ouellette commented 5 years ago

That's only called when a player directory changes their inventory, not when they dig a node or when a mod places something in their inventory.

kilbith commented 5 years ago

Digging a node is not a problem as it always predates opening the craftguide (which by itself update the list*). But indeed polling covers more scenarios currently, despite the temptation to use this callback.

*not since https://github.com/minetest-mods/craftguide/commit/07bc14e516f0b17cac00b5526a37419e145932a3

Wuzzy2 commented 5 years ago

Wait, what? So when you get an item from a dug node, that does not count as inventory change? And a mod changing the inventory does also not count? How stupid is that?! Are you sure?

kilbith commented 5 years ago

Are you sure?

Yes. Moreover when you put e.g. a stack of wood inside the craft grid, you call get_inv_items inside register_on_player_inventory_action, it isn't aware that a stack of sticks is in the craftpreview list. You have to move the stack of wood within the grid so it can get what's inside the craftpreview list. This is kind of broken.