Skip to content

Commit 40ab3e0

Browse files
Wuzzy2paramat
authored andcommittedOct 16, 2018
Add disable_repair group to prevent tool repair (#7381)
1 parent b6adb7f commit 40ab3e0

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed
 

Diff for: ‎doc/lua_api.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,8 @@ Special groups
15511551
connect to each other
15521552
* `slippery`: Players and items will slide on the node.
15531553
Slipperiness rises steadily with `slippery` value, starting at 1.
1554+
* `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
1555+
`"toolrepair"` crafting recipe
15541556

15551557

15561558
Known damage and digging time defining groups
@@ -6156,6 +6158,8 @@ Used by `minetest.register_craft`.
61566158
additional_wear = -0.02,
61576159
}
61586160

6161+
Note: Tools with group `disable_repair=1` will not repairable by this recipe.
6162+
61596163
### Cooking
61606164

61616165
{

Diff for: ‎games/minimal/mods/experimental/init.lua

+28
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,34 @@ minetest.register_craftitem("experimental:tester_tool_2", {
615615
end,
616616
})
617617

618+
-- Test the disable_repair=1 group
619+
minetest.register_tool("experimental:unrepairable_tool", {
620+
description = "Unrepairable Tool",
621+
wield_image = "default_stone.png",
622+
inventory_image = "default_stone.png",
623+
tool_capabilities = {
624+
groupcaps = {
625+
cracky = {
626+
times = {3, 2, 1},
627+
}
628+
}
629+
},
630+
groups = { disable_repair = 1 }
631+
})
632+
633+
minetest.register_tool("experimental:repairable_tool", {
634+
description = "Repairable Tool",
635+
wield_image = "default_dirt.png",
636+
inventory_image = "default_dirt.png",
637+
tool_capabilities = {
638+
groupcaps = {
639+
cracky = {
640+
times = {3, 2, 1},
641+
}
642+
}
643+
},
644+
})
645+
618646
minetest.register_craft({
619647
output = 'experimental:tester_tool_2',
620648
recipe = {

Diff for: ‎src/craftdef.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ static ItemStack craftToolRepair(
579579
IItemDefManager *idef = gamedef->idef();
580580
if (item1.count != 1 || item2.count != 1 || item1.name != item2.name
581581
|| idef->get(item1.name).type != ITEM_TOOL
582-
|| idef->get(item2.name).type != ITEM_TOOL) {
582+
|| itemgroup_get(idef->get(item1.name).groups, "disable_repair") == 1) {
583583
// Failure
584584
return ItemStack();
585585
}

0 commit comments

Comments
 (0)
Please sign in to comment.