Making crafting recipes add wear to tools
- MCL
- Member
- Posts: 654
- Joined: Mon Aug 20, 2018 00:44
- GitHub: MCLx86
- IRC: migdyn
- In-game: singleplayer
- Contact:
Making crafting recipes add wear to tools
How to make a crafting recipe that will output a weared tool?
2014-02-14 - 2024-02-14 TEN YEARS OF MCL
Re: Making crafting recipes add wear to tools
"tool count wear"
you can also do /giveme default:pick_wood 1 60000
Code: Select all
minetest.register_craft({
output = "default:pick_wood 1 60000",
recipe = {
{"","default:dirt",""},
{"","default:stick",""},
{"","default:stick",""},
}
})
- MCL
- Member
- Posts: 654
- Joined: Mon Aug 20, 2018 00:44
- GitHub: MCLx86
- IRC: migdyn
- In-game: singleplayer
- Contact:
Re: Making crafting recipes add wear to tools
Is there a way to get the durability of a tool subtract a value from it and output a tool with that durability.
Example:
Recipe: [] [default:dirt] []
[] [default:pick_stone (full durability)] [] | Output = default:pick_stone (durability of 50,000)
[] [] []
Example:
Recipe: [] [default:dirt] []
[] [default:pick_stone (full durability)] [] | Output = default:pick_stone (durability of 50,000)
[] [] []
2014-02-14 - 2024-02-14 TEN YEARS OF MCL
Re: Making crafting recipes add wear to tools
I do not fully understand what you mean, but try this:
wood pick + dirt = +repair 50%
and try this too:
wood pick + dirt = +repair 50%
Code: Select all
minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv)
if itemstack:get_name()=="default:pick_wood" then
local wear=0
local dirt=false
for i, it in pairs(old_craft_grid) do
if it:get_name()=="default:pick_wood" then
wear=it:get_wear()
elseif it:get_name()=="default:dirt" then
dirt=true
end
end
if dirt then
local new_wear=wear - (65534/2)
if new_wear<0 then new_wear=0 end-- -wear makes it start over on 65535
return "default:pick_wood 1 " .. new_wear
end
end
return itemstack
end)
minetest.register_craft({
output ="default:pick_wood",
recipe = {
{"","default:dirt",""},
{"","default:pick_wood",""},
{"","",""},
}
})
Code: Select all
print(minetest.registered_items["default:pick_wood"].tool_capabilities.groupcaps.cracky.uses)
print(dump(minetest.registered_items["default:pick_wood"]))
Who is online
Users browsing this forum: No registered users and 4 guests