Skip to content

Commit

Permalink
Add disable_repair group to prevent tool repair (#7381)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuzzy2 authored and paramat committed Oct 16, 2018
1 parent b6adb7f commit 40ab3e0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/lua_api.txt
Expand Up @@ -1551,6 +1551,8 @@ Special groups
connect to each other
* `slippery`: Players and items will slide on the node.
Slipperiness rises steadily with `slippery` value, starting at 1.
* `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
`"toolrepair"` crafting recipe


Known damage and digging time defining groups
Expand Down Expand Up @@ -6156,6 +6158,8 @@ Used by `minetest.register_craft`.
additional_wear = -0.02,
}

Note: Tools with group `disable_repair=1` will not repairable by this recipe.

### Cooking

{
Expand Down
28 changes: 28 additions & 0 deletions games/minimal/mods/experimental/init.lua
Expand Up @@ -615,6 +615,34 @@ minetest.register_craftitem("experimental:tester_tool_2", {
end,
})
-- Test the disable_repair=1 group
minetest.register_tool("experimental:unrepairable_tool", {
description = "Unrepairable Tool",
wield_image = "default_stone.png",
inventory_image = "default_stone.png",
tool_capabilities = {
groupcaps = {
cracky = {
times = {3, 2, 1},
}
}
},
groups = { disable_repair = 1 }
})
minetest.register_tool("experimental:repairable_tool", {
description = "Repairable Tool",
wield_image = "default_dirt.png",
inventory_image = "default_dirt.png",
tool_capabilities = {
groupcaps = {
cracky = {
times = {3, 2, 1},
}
}
},
})
minetest.register_craft({
output = 'experimental:tester_tool_2',
recipe = {
Expand Down
2 changes: 1 addition & 1 deletion src/craftdef.cpp
Expand Up @@ -579,7 +579,7 @@ static ItemStack craftToolRepair(
IItemDefManager *idef = gamedef->idef();
if (item1.count != 1 || item2.count != 1 || item1.name != item2.name
|| idef->get(item1.name).type != ITEM_TOOL
|| idef->get(item2.name).type != ITEM_TOOL) {
|| itemgroup_get(idef->get(item1.name).groups, "disable_repair") == 1) {
// Failure
return ItemStack();
}
Expand Down

0 comments on commit 40ab3e0

Please sign in to comment.