From 3c44a9be585ef7bf093bf3803f877baadef47415 Mon Sep 17 00:00:00 2001
From: OgelGames <olliverdc28@gmail.com>
Date: Mon, 30 Dec 2019 22:29:25 +1100
Subject: [PATCH] Add `toolranks` support (#37)

* Add toolranks support

* Update the changelog for `toolranks` support
---
 .luacheckrc  | 1 +
 CHANGELOG.md | 4 ++++
 init.lua     | 8 ++++++++
 mod.conf     | 2 +-
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/.luacheckrc b/.luacheckrc
index fb340e5..32ef698 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -30,4 +30,5 @@ read_globals = {
 	"frame",
 	"intllib",
 	"mg",
+	"toolranks",
 }
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aaffdc5..58e8935 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 
 ## [Unreleased]
 
+### Added
+
+- More Ores tools now have [`toolranks`](https://github.com/lisacvuk/minetest-toolranks) support.
+
 ## [2.0.0] - 2019-11-25
 
 ### Added
diff --git a/init.lua b/init.lua
index 33b2a82..704e4aa 100644
--- a/init.lua
+++ b/init.lua
@@ -232,6 +232,14 @@ local function add_ore(modname, description, mineral_name, oredef)
 			end
 		end
 
+		-- Toolranks support
+		if minetest.get_modpath("toolranks") then
+			minetest.override_item(fulltool_name, {
+				original_description = tdef.description,
+				description = toolranks.create_description(tdef.description, 0, 1),
+				after_use = toolranks.new_afteruse})
+		end
+
 		minetest.register_alias(tool_name .. tool_post, fulltool_name)
 		if use_frame then
 			frame.register(fulltool_name)
diff --git a/mod.conf b/mod.conf
index 9b71bfb..928eefe 100644
--- a/mod.conf
+++ b/mod.conf
@@ -1,4 +1,4 @@
 name = moreores
 description = Adds new ore types.
 depends = default
-optional_depends = carts,farming,frame,intllib,mg
+optional_depends = carts,farming,frame,intllib,mg,toolranks
-- 
GitLab