diff options
author | Wuzzy <wuzzy2@mail.ru> | 2018-10-16 06:25:34 +0200 |
---|---|---|
committer | Paramat <paramat@users.noreply.github.com> | 2018-10-16 05:25:34 +0100 |
commit | 40ab3e011de5be83b342e5d2b67c2837294b2d58 (patch) | |
tree | 64f5379133fe2c47ee19428d29129cea35e4bab8 | |
parent | b6adb7f09e4375f145c3ddb592527c1dd0b026a2 (diff) | |
download | minetest-40ab3e011de5be83b342e5d2b67c2837294b2d58.tar.gz minetest-40ab3e011de5be83b342e5d2b67c2837294b2d58.tar.bz2 minetest-40ab3e011de5be83b342e5d2b67c2837294b2d58.zip |
Add disable_repair group to prevent tool repair (#7381)
-rw-r--r-- | doc/lua_api.txt | 4 | ||||
-rw-r--r-- | games/minimal/mods/experimental/init.lua | 28 | ||||
-rw-r--r-- | src/craftdef.cpp | 2 |
3 files changed, 33 insertions, 1 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 19d6482ae..b079ac822 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -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 @@ -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 { diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua index 4d4e3e90c..e8aeff2b3 100644 --- a/games/minimal/mods/experimental/init.lua +++ b/games/minimal/mods/experimental/init.lua @@ -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 = { diff --git a/src/craftdef.cpp b/src/craftdef.cpp index 922ea345e..d64b7e55e 100644 --- a/src/craftdef.cpp +++ b/src/craftdef.cpp @@ -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(); } |