MT-CTF / capturetheflag

Capture the Flag game using the Minetest Voxel Engine
https://ctf.rubenwardy.com
81 stars 88 forks source link

Automatic inventory management on item pickup #291

Closed AKryukov92 closed 2 years ago

AKryukov92 commented 5 years ago

Today I have played CTF and noticed that it is extremely incomvenient to gather throphies in heat of battle.

Player as usual can manually manage his inventory as he likes.

I propose following changes:

Is it possible to handle pickups in MT?

AKryukov92 commented 5 years ago

I checked https://github.com/minetest/minetest/blob/master/doc/lua_api.txt And found several ways to do this:

I'll try to tinker with those options and see which one suits me more.

ClobberXD commented 5 years ago

minetest.register_on_player_inventory_action is the best option. on_metadata_inventory_take callbacks are executed when taking items from a node inventory (e.g. chest) and is hence irrelevant to your requirement. Overriding on_use is the most tedious way to do this, as you'd have to override this callback for every registered node/craftitem/tool.

There's an open PR for running callbacks on item-pickup, which would be the most straight-forward way to do this, but that's only for 5.0, assuming it even gets merged.

rubenwardy commented 5 years ago

minetest.register_on_player_inventory_action is a 5.0-dev feature. I already run a modified version of 0.4.17 with 5.0 features, so I could add it. I'd just rather not

ClobberXD commented 5 years ago

I think this is now doable, as capturetheflag is now targeting 5.0.0 (while maintaining backwards compat with 0.4.x). Would you be able to work on this @AKryukov92?

AKryukov92 commented 5 years ago

I will look on this this week. I assume, that "backward compatibility" can be handled by disabling this feature if MT version is lower than 5.0