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.
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")
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
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
-- the hammer for the anvil
minetest.register_tool("anvil:hammer", {
local hammer_def = {
description = S("Steel blacksmithing hammer"),
_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."),
@ -34,7 +48,13 @@ minetest.register_tool("anvil:hammer", {
},
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 = {}
@ -168,14 +188,17 @@ minetest.register_node("anvil:anvil", {
if listname~="input" then
return 0
end
if (listname=='input'
and(stack:get_wear() == 0
or minetest.get_item_group(stack:get_name(), "not_repaired_by_anvil") ~= 0
or stack:get_name() == "technic:water_can"
or stack:get_name() == "technic:lava_can" )) then
minetest.chat_send_player( player:get_player_name(), S('This anvil is for damaged tools only.'))
return 0
if (listname=='input') then
if (stack:get_wear() == 0) then
minetest.chat_send_player( player:get_player_name(), S('This anvil is for damaged tools only.'))
return 0
end
if (minetest.get_item_group(stack:get_name(), "not_repaired_by_anvil") ~= 0) then
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
if meta:get_inventory():room_for_item("input", stack) then

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: XanthinLanguage-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
@ -16,32 +16,32 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: init.lua:19
#: init.lua:36
msgid "Steel blacksmithing hammer"
msgstr ""
#: init.lua:20
#: init.lua:37
#, fuzzy
msgid "A tool for repairing other tools at a blacksmith's anvil."
msgstr "Stahlhammer um Werkzeuge auf dem Amboss zu reparieren"
#: init.lua:21
#: init.lua:38
msgid ""
"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."
msgstr ""
#: init.lua:98
#: init.lua:136
msgid "Anvil"
msgstr "Amboss"
#: init.lua:99
#: init.lua:137
msgid ""
"A tool for repairing other tools in conjunction with a blacksmith's hammer."
msgstr ""
#: init.lua:100
#: init.lua:138
msgid ""
"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 "
@ -50,12 +50,16 @@ msgid ""
"hand."
msgstr ""
#: init.lua:155
#: init.lua:193
#, fuzzy
msgid "This anvil is for damaged tools only."
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."
msgstr ""

View File

@ -60,6 +60,10 @@ msgstr ""
msgid "This anvil is for damaged tools only."
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
msgid "Your @1 has been repaired successfully."
msgstr "Su @1 ha sido reparado correctamente."

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \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"
"Last-Translator: \n"
"Language-Team: \n"
@ -18,15 +18,15 @@ msgstr ""
"X-Generator: Poedit 2.0.2\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: init.lua:19
#: init.lua:36
msgid "Steel blacksmithing hammer"
msgstr "Marteau de forgeron en acier"
#: init.lua:20
#: init.lua:37
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."
#: init.lua:21
#: init.lua:38
msgid ""
"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 "
@ -36,18 +36,18 @@ msgstr ""
"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."
#: init.lua:98
#: init.lua:136
msgid "Anvil"
msgstr "Enclume"
#: init.lua:99
#: init.lua:137
msgid ""
"A tool for repairing other tools in conjunction with a blacksmith's hammer."
msgstr ""
"Un outil pour réparer les autres outils à utiliser avec un marteau de "
"forgeron."
#: init.lua:100
#: init.lua:138
msgid ""
"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 "
@ -61,10 +61,14 @@ msgstr ""
"l'outil entièrement. Pour récupérer l'outil, frappez dessus ou faites un "
"click-droit en ayant la main vide."
#: init.lua:155
#: init.lua:193
msgid "This anvil is for damaged tools only."
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."
msgstr "Votre @1 a été réparé avec succès."

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Italian locale file for the Anvil module\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"
"Last-Translator: H4mlet <h4mlet@riseup.net>\n"
"Language-Team: \n"
@ -18,15 +18,15 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.6.10\n"
#: init.lua:19
#: init.lua:36
msgid "Steel blacksmithing hammer"
msgstr "Martello da fabbro di acciaio"
#: init.lua:20
#: init.lua:37
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."
#: init.lua:21
#: init.lua:38
msgid ""
"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 "
@ -36,16 +36,16 @@ msgstr ""
"danneggiato e potrete ripararlo. Può anche essere usato per colpire la "
"pietra, ma non è molto adatto a questo compito."
#: init.lua:98
#: init.lua:136
msgid "Anvil"
msgstr "Incudine"
#: init.lua:99
#: init.lua:137
msgid ""
"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."
#: init.lua:100
#: init.lua:138
msgid ""
"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 "
@ -59,10 +59,14 @@ msgstr ""
"gravemente danneggiato. Per riprendere l'attrezzo colpite o fate click "
"destro sull'incudine a mani vuote."
#: init.lua:155
#: init.lua:193
msgid "This anvil is for damaged tools only."
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."
msgstr "La/il vostr* @1 è stat* riparat* con successo."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,31 +17,31 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: init.lua:19
#: init.lua:36
msgid "Steel blacksmithing hammer"
msgstr ""
#: init.lua:20
#: init.lua:37
msgid "A tool for repairing other tools at a blacksmith's anvil."
msgstr ""
#: init.lua:21
#: init.lua:38
msgid ""
"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."
msgstr ""
#: init.lua:98
#: init.lua:136
msgid "Anvil"
msgstr ""
#: init.lua:99
#: init.lua:137
msgid ""
"A tool for repairing other tools in conjunction with a blacksmith's hammer."
msgstr ""
#: init.lua:100
#: init.lua:138
msgid ""
"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 "
@ -50,10 +50,14 @@ msgid ""
"hand."
msgstr ""
#: init.lua:155
#: init.lua:193
msgid "This anvil is for damaged tools only."
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."
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