add setting to allow hammer repair to be disabled

master
FaceDeer 2019-04-14 21:21:31 -06:00
parent 14b32a0e50
commit 200feb25bb
9 changed files with 99 additions and 47 deletions

View File

@ -1,3 +1,5 @@
Anvil mod by Sokomine, originally a part of the Cottages mod but extracted to stand alone. Anvil mod by Sokomine, originally a part of the Cottages mod but extracted to stand alone.
This anvil (and its associated hammer) allows a player to repair worn tools. Place the worn tool in the anvil's inventory and strike it with the hammer to improve its condition. This anvil (and its associated hammer) allows a player to repair worn tools. Place the worn tool in the anvil's inventory and strike it with the hammer to improve its condition.
By default, a hammer can be repaired on the anvil just like any other tool, allowing for infinite recycling of worn tools. Set "anvil_hammer_is_repairable false" to prevent this.

View File

@ -13,12 +13,26 @@ anvil = {
minetest.register_alias("castle:anvil", "anvil:anvil") minetest.register_alias("castle:anvil", "anvil:anvil")
local hammer_repairable = minetest.setting_getbool("anvil_hammer_is_repairable")
if hammer_repairable == nil then hammer_repairable = true end
local make_unrepairable = function(item_name)
local item_def = minetest.registered_items[item_name]
if item_def then
item_def.groups.not_repaired_by_anvil = 1
minetest.override_item(item_name, {groups = item_def.groups})
end
end
make_unrepairable("technic:water_can")
make_unrepairable("technic:lava_can")
-- internationalization boilerplate -- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname()) local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua") local S, NS = dofile(MP.."/intllib.lua")
-- the hammer for the anvil -- the hammer for the anvil
minetest.register_tool("anvil:hammer", {
local hammer_def = {
description = S("Steel blacksmithing hammer"), description = S("Steel blacksmithing hammer"),
_doc_items_longdesc = S("A tool for repairing other tools at a blacksmith's anvil."), _doc_items_longdesc = S("A tool for repairing other tools at a blacksmith's anvil."),
_doc_items_usagehelp = S("Use this hammer to strike blows upon an anvil bearing a damaged tool and you can repair it. It can also be used for smashing stone, but it is not well suited to this task."), _doc_items_usagehelp = S("Use this hammer to strike blows upon an anvil bearing a damaged tool and you can repair it. It can also be used for smashing stone, but it is not well suited to this task."),
@ -34,7 +48,13 @@ minetest.register_tool("anvil:hammer", {
}, },
damage_groups = {fleshy=6}, damage_groups = {fleshy=6},
} }
}) }
if not hammer_repairable then
hammer_def.groups = {["not_repaired_by_anvil"] = 1}
end
minetest.register_tool("anvil:hammer", hammer_def)
local tmp = {} local tmp = {}
@ -168,14 +188,17 @@ minetest.register_node("anvil:anvil", {
if listname~="input" then if listname~="input" then
return 0 return 0
end end
if (listname=='input' if (listname=='input') then
and(stack:get_wear() == 0 if (stack:get_wear() == 0) then
or minetest.get_item_group(stack:get_name(), "not_repaired_by_anvil") ~= 0 minetest.chat_send_player( player:get_player_name(), S('This anvil is for damaged tools only.'))
or stack:get_name() == "technic:water_can" return 0
or stack:get_name() == "technic:lava_can" )) then end
minetest.chat_send_player( player:get_player_name(), S('This anvil is for damaged tools only.')) if (minetest.get_item_group(stack:get_name(), "not_repaired_by_anvil") ~= 0) then
return 0 local item_def = minetest.registered_items[stack:get_name()]
minetest.chat_send_player( player:get_player_name(), S('@1 cannot be repaired with an anvil.', item_def.description))
return 0
end
end end
if meta:get_inventory():room_for_item("input", stack) then if meta:get_inventory():room_for_item("input", stack) then

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-07 22:17-0700\n" "POT-Creation-Date: 2019-04-14 21:16-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: XanthinLanguage-Team: LANGUAGE <LL@li.org>\n" "Last-Translator: XanthinLanguage-Team: LANGUAGE <LL@li.org>\n"
"Language: \n" "Language: \n"
@ -16,32 +16,32 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: init.lua:19 #: init.lua:36
msgid "Steel blacksmithing hammer" msgid "Steel blacksmithing hammer"
msgstr "" msgstr ""
#: init.lua:20 #: init.lua:37
#, fuzzy #, fuzzy
msgid "A tool for repairing other tools at a blacksmith's anvil." msgid "A tool for repairing other tools at a blacksmith's anvil."
msgstr "Stahlhammer um Werkzeuge auf dem Amboss zu reparieren" msgstr "Stahlhammer um Werkzeuge auf dem Amboss zu reparieren"
#: init.lua:21 #: init.lua:38
msgid "" msgid ""
"Use this hammer to strike blows upon an anvil bearing a damaged tool and you " "Use this hammer to strike blows upon an anvil bearing a damaged tool and you "
"can repair it. It can also be used for smashing stone, but it is not well " "can repair it. It can also be used for smashing stone, but it is not well "
"suited to this task." "suited to this task."
msgstr "" msgstr ""
#: init.lua:98 #: init.lua:136
msgid "Anvil" msgid "Anvil"
msgstr "Amboss" msgstr "Amboss"
#: init.lua:99 #: init.lua:137
msgid "" msgid ""
"A tool for repairing other tools in conjunction with a blacksmith's hammer." "A tool for repairing other tools in conjunction with a blacksmith's hammer."
msgstr "" msgstr ""
#: init.lua:100 #: init.lua:138
msgid "" msgid ""
"Right-click on this anvil with a damaged tool to place the damaged tool upon " "Right-click on this anvil with a damaged tool to place the damaged tool upon "
"it. You can then repair the damaged tool by striking it with a blacksmith's " "it. You can then repair the damaged tool by striking it with a blacksmith's "
@ -50,12 +50,16 @@ msgid ""
"hand." "hand."
msgstr "" msgstr ""
#: init.lua:155 #: init.lua:193
#, fuzzy #, fuzzy
msgid "This anvil is for damaged tools only." msgid "This anvil is for damaged tools only."
msgstr "Das Werkstueckfeld gilt nur fuer beschaedigtes Werkzeug." msgstr "Das Werkstueckfeld gilt nur fuer beschaedigtes Werkzeug."
#: init.lua:267 #: init.lua:199
msgid "@1 cannot be repaired with an anvil."
msgstr ""
#: init.lua:325
msgid "Your @1 has been repaired successfully." msgid "Your @1 has been repaired successfully."
msgstr "" msgstr ""

View File

@ -60,6 +60,10 @@ msgstr ""
msgid "This anvil is for damaged tools only." msgid "This anvil is for damaged tools only."
msgstr "Este yunque es sólo para herramientas dañadas" msgstr "Este yunque es sólo para herramientas dañadas"
#: init.lua:199
msgid "@1 cannot be repaired with an anvil."
msgstr ""
#: init.lua:267 #: init.lua:267
msgid "Your @1 has been repaired successfully." msgid "Your @1 has been repaired successfully."
msgstr "Su @1 ha sido reparado correctamente." msgstr "Su @1 ha sido reparado correctamente."

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-26 12:18+0200\n" "POT-Creation-Date: 2019-04-14 21:16-0600\n"
"PO-Revision-Date: 2017-06-26 12:22+0200\n" "PO-Revision-Date: 2017-06-26 12:22+0200\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -18,15 +18,15 @@ msgstr ""
"X-Generator: Poedit 2.0.2\n" "X-Generator: Poedit 2.0.2\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: init.lua:19 #: init.lua:36
msgid "Steel blacksmithing hammer" msgid "Steel blacksmithing hammer"
msgstr "Marteau de forgeron en acier" msgstr "Marteau de forgeron en acier"
#: init.lua:20 #: init.lua:37
msgid "A tool for repairing other tools at a blacksmith's anvil." msgid "A tool for repairing other tools at a blacksmith's anvil."
msgstr "Un outil pour réparer les autres outils avec une enclume de forgeron." msgstr "Un outil pour réparer les autres outils avec une enclume de forgeron."
#: init.lua:21 #: init.lua:38
msgid "" msgid ""
"Use this hammer to strike blows upon an anvil bearing a damaged tool and you " "Use this hammer to strike blows upon an anvil bearing a damaged tool and you "
"can repair it. It can also be used for smashing stone, but it is not well " "can repair it. It can also be used for smashing stone, but it is not well "
@ -36,18 +36,18 @@ msgstr ""
"ainsi vous pourrez le réparer. Il peut être aussi utilisé pour casser de la " "ainsi vous pourrez le réparer. Il peut être aussi utilisé pour casser de la "
"pierre, mais il n'est pas adapté à cette tâche." "pierre, mais il n'est pas adapté à cette tâche."
#: init.lua:98 #: init.lua:136
msgid "Anvil" msgid "Anvil"
msgstr "Enclume" msgstr "Enclume"
#: init.lua:99 #: init.lua:137
msgid "" msgid ""
"A tool for repairing other tools in conjunction with a blacksmith's hammer." "A tool for repairing other tools in conjunction with a blacksmith's hammer."
msgstr "" msgstr ""
"Un outil pour réparer les autres outils à utiliser avec un marteau de " "Un outil pour réparer les autres outils à utiliser avec un marteau de "
"forgeron." "forgeron."
#: init.lua:100 #: init.lua:138
msgid "" msgid ""
"Right-click on this anvil with a damaged tool to place the damaged tool upon " "Right-click on this anvil with a damaged tool to place the damaged tool upon "
"it. You can then repair the damaged tool by striking it with a blacksmith's " "it. You can then repair the damaged tool by striking it with a blacksmith's "
@ -61,10 +61,14 @@ msgstr ""
"l'outil entièrement. Pour récupérer l'outil, frappez dessus ou faites un " "l'outil entièrement. Pour récupérer l'outil, frappez dessus ou faites un "
"click-droit en ayant la main vide." "click-droit en ayant la main vide."
#: init.lua:155 #: init.lua:193
msgid "This anvil is for damaged tools only." msgid "This anvil is for damaged tools only."
msgstr "L'enclume s'utilise sur les outils endommagés." msgstr "L'enclume s'utilise sur les outils endommagés."
#: init.lua:267 #: init.lua:199
msgid "@1 cannot be repaired with an anvil."
msgstr ""
#: init.lua:325
msgid "Your @1 has been repaired successfully." msgid "Your @1 has been repaired successfully."
msgstr "Votre @1 a été réparé avec succès." msgstr "Votre @1 a été réparé avec succès."

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Italian locale file for the Anvil module\n" "Project-Id-Version: Italian locale file for the Anvil module\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-07 22:17-0700\n" "POT-Creation-Date: 2019-04-14 21:16-0600\n"
"PO-Revision-Date: 2017-08-18 16:14+0100\n" "PO-Revision-Date: 2017-08-18 16:14+0100\n"
"Last-Translator: H4mlet <h4mlet@riseup.net>\n" "Last-Translator: H4mlet <h4mlet@riseup.net>\n"
"Language-Team: \n" "Language-Team: \n"
@ -18,15 +18,15 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.6.10\n" "X-Generator: Poedit 1.6.10\n"
#: init.lua:19 #: init.lua:36
msgid "Steel blacksmithing hammer" msgid "Steel blacksmithing hammer"
msgstr "Martello da fabbro di acciaio" msgstr "Martello da fabbro di acciaio"
#: init.lua:20 #: init.lua:37
msgid "A tool for repairing other tools at a blacksmith's anvil." msgid "A tool for repairing other tools at a blacksmith's anvil."
msgstr "Un attrezzo per riparare altri attrezzi su di una incudine da fabbro." msgstr "Un attrezzo per riparare altri attrezzi su di una incudine da fabbro."
#: init.lua:21 #: init.lua:38
msgid "" msgid ""
"Use this hammer to strike blows upon an anvil bearing a damaged tool and you " "Use this hammer to strike blows upon an anvil bearing a damaged tool and you "
"can repair it. It can also be used for smashing stone, but it is not well " "can repair it. It can also be used for smashing stone, but it is not well "
@ -36,16 +36,16 @@ msgstr ""
"danneggiato e potrete ripararlo. Può anche essere usato per colpire la " "danneggiato e potrete ripararlo. Può anche essere usato per colpire la "
"pietra, ma non è molto adatto a questo compito." "pietra, ma non è molto adatto a questo compito."
#: init.lua:98 #: init.lua:136
msgid "Anvil" msgid "Anvil"
msgstr "Incudine" msgstr "Incudine"
#: init.lua:99 #: init.lua:137
msgid "" msgid ""
"A tool for repairing other tools in conjunction with a blacksmith's hammer." "A tool for repairing other tools in conjunction with a blacksmith's hammer."
msgstr "Un attrezzo per riparare altri attrezzi usando un martello da fabbro." msgstr "Un attrezzo per riparare altri attrezzi usando un martello da fabbro."
#: init.lua:100 #: init.lua:138
msgid "" msgid ""
"Right-click on this anvil with a damaged tool to place the damaged tool upon " "Right-click on this anvil with a damaged tool to place the damaged tool upon "
"it. You can then repair the damaged tool by striking it with a blacksmith's " "it. You can then repair the damaged tool by striking it with a blacksmith's "
@ -59,10 +59,14 @@ msgstr ""
"gravemente danneggiato. Per riprendere l'attrezzo colpite o fate click " "gravemente danneggiato. Per riprendere l'attrezzo colpite o fate click "
"destro sull'incudine a mani vuote." "destro sull'incudine a mani vuote."
#: init.lua:155 #: init.lua:193
msgid "This anvil is for damaged tools only." msgid "This anvil is for damaged tools only."
msgstr "Questa incudine è solo per attrezzi danneggiati." msgstr "Questa incudine è solo per attrezzi danneggiati."
#: init.lua:267 #: init.lua:199
msgid "@1 cannot be repaired with an anvil."
msgstr ""
#: init.lua:325
msgid "Your @1 has been repaired successfully." msgid "Your @1 has been repaired successfully."
msgstr "La/il vostr* @1 è stat* riparat* con successo." msgstr "La/il vostr* @1 è stat* riparat* con successo."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-07 22:17-0700\n" "POT-Creation-Date: 2019-04-14 21:16-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,31 +17,31 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: init.lua:19 #: init.lua:36
msgid "Steel blacksmithing hammer" msgid "Steel blacksmithing hammer"
msgstr "" msgstr ""
#: init.lua:20 #: init.lua:37
msgid "A tool for repairing other tools at a blacksmith's anvil." msgid "A tool for repairing other tools at a blacksmith's anvil."
msgstr "" msgstr ""
#: init.lua:21 #: init.lua:38
msgid "" msgid ""
"Use this hammer to strike blows upon an anvil bearing a damaged tool and you " "Use this hammer to strike blows upon an anvil bearing a damaged tool and you "
"can repair it. It can also be used for smashing stone, but it is not well " "can repair it. It can also be used for smashing stone, but it is not well "
"suited to this task." "suited to this task."
msgstr "" msgstr ""
#: init.lua:98 #: init.lua:136
msgid "Anvil" msgid "Anvil"
msgstr "" msgstr ""
#: init.lua:99 #: init.lua:137
msgid "" msgid ""
"A tool for repairing other tools in conjunction with a blacksmith's hammer." "A tool for repairing other tools in conjunction with a blacksmith's hammer."
msgstr "" msgstr ""
#: init.lua:100 #: init.lua:138
msgid "" msgid ""
"Right-click on this anvil with a damaged tool to place the damaged tool upon " "Right-click on this anvil with a damaged tool to place the damaged tool upon "
"it. You can then repair the damaged tool by striking it with a blacksmith's " "it. You can then repair the damaged tool by striking it with a blacksmith's "
@ -50,10 +50,14 @@ msgid ""
"hand." "hand."
msgstr "" msgstr ""
#: init.lua:155 #: init.lua:193
msgid "This anvil is for damaged tools only." msgid "This anvil is for damaged tools only."
msgstr "" msgstr ""
#: init.lua:267 #: init.lua:199
msgid "@1 cannot be repaired with an anvil."
msgstr ""
#: init.lua:325
msgid "Your @1 has been repaired successfully." msgid "Your @1 has been repaired successfully."
msgstr "" msgstr ""

6
locale/update.bat Normal file
View File

@ -0,0 +1,6 @@
@echo off
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
cd ..
set LIST=
for /r %%X in (*.lua) do set LIST=!LIST! %%X
..\intllib\tools\xgettext.bat %LIST%

1
settingtypes.txt Normal file
View File

@ -0,0 +1 @@
anvil_hammer_is_repairable (Hammer can be repaired on anvil) bool true