forked from mtcontrib/moretrees
Merge branch 'cocomilk-axe-bugfix' into 'master'
Fix bug with coconut-milk craft See merge request VanessaE/moretrees!3
This commit is contained in:
commit
d335eceecc
31
crafts.lua
31
crafts.lua
|
@ -117,10 +117,39 @@ for i in ipairs(moretrees.cutting_tools) do
|
|||
},
|
||||
replacements = {
|
||||
{ "moretrees:coconut", "moretrees:raw_coconut" },
|
||||
{ tool, tool }
|
||||
}
|
||||
})
|
||||
end
|
||||
-- give tool back with wear preserved
|
||||
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
|
||||
if (itemstack:get_name() == "moretrees:coconut_milk") then
|
||||
for i, j in pairs(old_craft_grid) do
|
||||
-- find tool used to do the craft
|
||||
local ocg_name = j:get_name()
|
||||
if ((ocg_name ~= "") and (ocg_name ~= "moretrees:coconut") and (ocg_name ~= "vessels:drinking_glass")) then
|
||||
-- create a new tool and set wear
|
||||
local t = ItemStack(ocg_name)
|
||||
local w = j:get_wear()
|
||||
-- works if tool used is an axe
|
||||
local uses = j:get_tool_capabilities().groupcaps.choppy.uses or 0
|
||||
if (w == 0 and uses ~= 0) then
|
||||
-- tool has never been used
|
||||
-- use tool once
|
||||
t:set_wear(65535/(9*(uses - 1)))
|
||||
else
|
||||
-- set wear back
|
||||
t:set_wear(w)
|
||||
-- use tool once
|
||||
if (uses ~= 0) then
|
||||
t:add_wear(65535/(9*(uses - 1)))
|
||||
end
|
||||
end
|
||||
-- add to craft inventory
|
||||
craft_inv:add_item("craft", t)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
|
|
Loading…
Reference in New Issue
Block a user