From d7ac127d24f45b0eb942ba8acfa49c7731c93ee0 Mon Sep 17 00:00:00 2001
From: Louis Royer <55180044+louisroyer@users.noreply.github.com>
Date: Sun, 13 Oct 2019 13:04:00 +0200
Subject: [PATCH] Add compatibility with mod frame

- [mod frame](https://github.com/minetest-mods/frame)
---
 .luacheckrc |  2 ++
 init.lua    | 19 +++++++++++++++++++
 mod.conf    |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/.luacheckrc b/.luacheckrc
index b1eb1c9..fb340e5 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -25,7 +25,9 @@ stds.minetest = {
 }
 
 read_globals = {
+	"carts",
 	"farming",
+	"frame",
 	"intllib",
 	"mg",
 }
diff --git a/init.lua b/init.lua
index 839c370..33b2a82 100644
--- a/init.lua
+++ b/init.lua
@@ -23,6 +23,9 @@ if minetest.get_modpath("mg") then
 	dofile(modpath .. "/mg.lua")
 end
 
+-- `frame` support
+local use_frame = minetest.get_modpath("frame")
+
 local default_stone_sounds = default.node_sound_stone_defaults()
 local default_metal_sounds = default.node_sound_metal_defaults()
 
@@ -89,6 +92,10 @@ local function add_ore(modname, description, mineral_name, oredef)
 			sounds = default_stone_sounds,
 			drop = lump_item,
 		})
+
+		if use_frame then
+			frame.register(modname .. ":mineral_" .. mineral_name)
+		end
 	end
 
 	if oredef.makes.block then
@@ -112,6 +119,9 @@ local function add_ore(modname, description, mineral_name, oredef)
 				}
 			})
 		end
+		if use_frame then
+			frame.register(block_item)
+		end
 	end
 
 	if oredef.makes.lump then
@@ -127,6 +137,9 @@ local function add_ore(modname, description, mineral_name, oredef)
 				recipe = lump_item,
 			})
 		end
+		if use_frame then
+			frame.register(lump_item)
+		end
 	end
 
 	if oredef.makes.ingot then
@@ -135,6 +148,9 @@ local function add_ore(modname, description, mineral_name, oredef)
 			inventory_image = img_base .. "_ingot.png",
 		})
 		minetest.register_alias(mineral_name .. "_ingot", ingot)
+		if use_frame then
+			frame.register(ingot)
+		end
 	end
 
 	if oredef.makes.chest then
@@ -217,6 +233,9 @@ local function add_ore(modname, description, mineral_name, oredef)
 		end
 
 		minetest.register_alias(tool_name .. tool_post, fulltool_name)
+		if use_frame then
+			frame.register(fulltool_name)
+		end
 	end
 end
 
diff --git a/mod.conf b/mod.conf
index 04a353a..9b71bfb 100644
--- a/mod.conf
+++ b/mod.conf
@@ -1,4 +1,4 @@
 name = moreores
 description = Adds new ore types.
 depends = default
-optional_depends = carts,farming,intllib,mg
+optional_depends = carts,farming,frame,intllib,mg
-- 
GitLab