From 69606ed2f2c3f2f020df8d554edf0f3d50a98418 Mon Sep 17 00:00:00 2001
From: WoosterUK
Date: Wed, 14 Aug 2019 09:49:52 +0100
Subject: [PATCH] Re-factor wand registration to avoid oversights in
deconversion recipes
---
wand.lua | 64 +++++++++++++++++++++++++-------------------------------
1 file changed, 28 insertions(+), 36 deletions(-)
diff --git a/wand.lua b/wand.lua
index 18de5d2..19eed12 100644
--- a/wand.lua
+++ b/wand.lua
@@ -1,23 +1,5 @@
-
-minetest.register_craftitem("missions:wand_position", {
- description = "Mission wand with position",
- inventory_image = "missions_wand_position.png",
- stack_max = 1
-})
-
-minetest.register_craftitem("missions:wand_chest", {
- description = "Mission wand with chest-reference",
- inventory_image = "missions_wand_chest.png",
- stack_max = 1
-})
-
-minetest.register_craftitem("missions:wand_mission", {
- description = "Mission wand with mission-reference",
- inventory_image = "missions_wand_mission.png",
- stack_max = 1
-})
-
-
+-- base wand
+-- register item
minetest.register_craftitem("missions:wand", {
description = "Mission wand",
inventory_image = "missions_wand.png",
@@ -30,21 +12,7 @@ minetest.register_craftitem("missions:wand", {
end
})
-
--- crafts
-
-minetest.register_craft({
- type = "shapeless",
- output = "missions:wand",
- recipe = {"missions:wand_chest"}
-})
-
-minetest.register_craft({
- type = "shapeless",
- output = "missions:wand",
- recipe = {"missions:wand_position"}
-})
-
+--register craft
minetest.register_craft({
output = "missions:wand 3",
recipe = {
@@ -52,4 +20,28 @@ minetest.register_craft({
{"", "default:stick", ""},
{"default:mese_crystal_fragment", "", "default:stick"}
}
-})
\ No newline at end of file
+})
+
+-- converted wands
+-- helper table to track which wands are being added
+wands = {
+ ["position"] = "position",
+ ["chest"] = "chest-reference",
+ ["mission"] = "mission-reference"
+}
+
+for key, value in pairs(wands) do
+ -- register item
+ minetest.register_craftitem("missions:wand_" .. key, {
+ description = "Mission wand with " .. value,
+ inventory_image = "missions_wand_" .. key .. ".png",
+ stack_max = 1
+ })
+
+ -- register deconversion
+ minetest.register_craft({
+ type = "shapeless",
+ output = "missions:wand",
+ recipe = {"missions:wand_" .. key}
+ })
+end