Minetest_game: If you die while using an item you don't lose the item

Created on 27 Sep 2017  路  16Comments  路  Source: minetest/minetest_game

If you die as part of the processing of an item use, the item doesn't get removed and put in bones.
Unsure whether this is a minetest or minetest_game problem, but since bones is supposed to implement "losing items", I'm putting this here.

Bug Engine change needed

Most helpful comment

This should not be fixed in mods, but by the engine or builtin

All 16 comments

How to replicate: 1. /giveme flowers:mushroom_red 99, 2. Eat a bunch of them. You will die, and respawn, all without losing the itemstack.

I ran into this and sidestepped the issue here: https://github.com/jastevenson303/runfast/commit/53cce77b960b1fc057fcf1c764d31415151a721c#diff-d7d74284e2e39f6c06d199c8e2bedbd0L348 with a minetest.after :/

note: Bones puts it in the bones node anyway, which would make this a duplication exploit (though only limited to items that you can kill yourself with).

The HP should be check during the server step instead, when no Lua functions are running. This ~probably~ hopefully won't break any mods.

Couldnt we just take this line and place it right before the "return itemstack" so it takes item before causing any food harm ? https://github.com/minetest/minetest/blob/604fe2083d70fea92b6c53c9a9d1c1ffdcb36610/builtin/game/item.lua#L454

@tenplus1 No, that won't work. The problem isn't that processing gets interrupted, it's that the user dies during processing (and so death processing happens, and the player gets their item put in bones), and after processing is finished the returned itemstack is given to the player even though they lost the original stack.

so would a minetest.after() function not help to finish process before doing damage ?

It would, as @jastevenson303 already mentioned. It's a hack though.

only other way i can think is in the actual on_use function for the red shroom itself, eat 1st, damage after.

if hp > 0 then return itemstack
else return ""

?

@jastevenson303 If the server doesn't have bones activated then they shouldn't lose items.

if hp > 0 then return itemstack
elseif minetest.settings:get("bones_mode") ~= "keep" then return ""

?

Ps. I think if one were to do this to red mushrooms, they'd find many other food items they'd need to modify also. I wonder now about minetest.item_eat(), if the issue can be resolved there.

This should not be fixed in mods, but by the engine or builtin

The extra red mushrooms grew on your corpse. You ate them and that inoculated you with the spores. There, order has been preserved.

lol infinite

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paramat picture paramat  路  3Comments

MarkuBu picture MarkuBu  路  5Comments

FeXoR-o-Illuria picture FeXoR-o-Illuria  路  4Comments

juozaspo picture juozaspo  路  6Comments

Fixer-007 picture Fixer-007  路  6Comments