(#33) [Maidroid] Corrige duplication potentielle avec maidroid-tool

This commit is contained in:
Sys Quatre 2020-06-13 00:14:16 +02:00
parent 46eddc266b
commit ea7c3eb27b
1 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,9 @@
local rod_uses = 100
local function obj_remove(obj)
obj:remove()
end
minetest.register_tool("maidroid_tool:capture_rod", {
description = "maidroid tool : capture rod",
inventory_image = "maidroid_tool_capture_rod.png",
@ -17,12 +21,17 @@ minetest.register_tool("maidroid_tool:capture_rod", {
return
end
if luaentity.is_removed then
return
end
luaentity.is_removed = true
local drop_pos = vector.add(obj:getpos(), {x = 0, y = 1, z = 0})
local maidroid_name = string.split(luaentity.name, ":")[2]
local stack = ItemStack("maidroid_tool:captured_" .. maidroid_name .. "_egg")
stack:set_metadata(luaentity:get_staticdata())
obj:remove()
minetest.after(0.1, obj_remove, obj)
minetest.add_item(drop_pos, stack)
itemstack:add_wear(65535 / (rod_uses - 1))