summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.lua31
-rw-r--r--locale/de.txt2
-rw-r--r--locale/template.txt2
3 files changed, 35 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 4edab4d..1be1196 100644
--- a/init.lua
+++ b/init.lua
@@ -145,6 +145,31 @@ local burntime_to_text = function(burntime)
end
end
+local mining_durability_factoid = function(tool_capabilities)
+ local formstring = ""
+ if tool_capabilities ~= nil and tool_capabilities ~= {} then
+ local groupcaps = tool_capabilities.groupcaps
+ if groupcaps ~= nil then
+ local lines = 0
+ for k,v in pairs(groupcaps) do
+ if v.maxlevel ~= nil and v.uses ~= nil and v.uses > 0 then
+ for level=0, v.maxlevel do
+ local uses = v.uses * math.pow(3, v.maxlevel - level)
+ formstring = formstring .. S("• @1, level @2: @3 uses", doc.sub.items.get_group_name(k), level, uses)
+ formstring = formstring .. "\n"
+ lines = lines + 1
+ end
+ end
+ end
+ if lines >= 1 then
+ formstring = S("Mining durability:") .. "\n" .. formstring
+ formstring = newline2(formstring)
+ end
+ end
+ end
+ return formstring
+end
+
local toolcaps_to_text = function(tool_capabilities)
local formstring = ""
if tool_capabilities ~= nil and tool_capabilities ~= {} then
@@ -833,11 +858,17 @@ doc.new_category("tools", {
datastring = datastring .. range_factoid(data.itemstring, data.def)
datastring = newline(datastring)
if type(data.def._doc_items_durability) == "number" then
+ -- Fixed number of uses
datastring = datastring .. S("Durability: @1 uses", data.def._doc_items_durability)
datastring = newline(datastring)
elseif type(data.def._doc_items_durability) == "string" then
+ -- Manually described durability
datastring = datastring .. S("Durability: @1", data.def._doc_items_durability)
datastring = newline(datastring)
+ else
+ -- Automatically detect durability for mining tools
+ datastring = datastring .. mining_durability_factoid(data.def.tool_capabilities)
+ datastring = newline(datastring)
end
datastring = newline2(datastring)
diff --git a/locale/de.txt b/locale/de.txt
index 5289a29..20f5377 100644
--- a/locale/de.txt
+++ b/locale/de.txt
@@ -133,3 +133,5 @@ Unknown item (@1) = Unbekannter Gegenstand (@1)
Itemstring: "@1" = Itemstring: »@1«
Durability: @1 uses = Haltbarkeit: @1 Benutzungen
Durability: @1 = Haltbarkeit: @1
+Mining durability: = Grabehaltbarkeit:
+• @1, level @2: @3 uses = • @1, Stufe @2: @3 Benutzungen
diff --git a/locale/template.txt b/locale/template.txt
index fbe5bde..c4a7329 100644
--- a/locale/template.txt
+++ b/locale/template.txt
@@ -134,3 +134,5 @@ Unknown item (@1) =
Itemstring: "@1" =
Durability: @1 uses =
Durability: @1 =
+Mining durability: =
+• @1, level @2: @3 uses =