From 9188b70438ea6c8c8d6afc6efffa468321f0bf32 Mon Sep 17 00:00:00 2001 From: Diablosxm <132860646+Diablosxm@users.noreply.github.com> Date: Fri, 19 May 2023 23:30:38 -0400 Subject: [PATCH 01/11] Update init.lua adding dofile for compressor recipe --- init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 2251be9..9f8116e 100644 --- a/init.lua +++ b/init.lua @@ -144,7 +144,9 @@ if nether.NETHER_REALM_ENABLED then end end dofile(nether.path .. "/portal_examples.lua") - +if minetest.get_modpath("technic") then + dofile(nether.path .. "/nether-compressor-recipe.lua") +end -- Portals are ignited by right-clicking with a mese crystal fragment nether.register_portal_ignition_item( @@ -345,4 +347,4 @@ minetest.register_on_dieplayer( ) end end -) \ No newline at end of file +) From 53bab7a33aa0245ff0e6167c47b93692d6ad212e Mon Sep 17 00:00:00 2001 From: Diablosxm <132860646+Diablosxm@users.noreply.github.com> Date: Fri, 19 May 2023 23:31:41 -0400 Subject: [PATCH 02/11] Update mod.conf adding optional_depends for technic --- mod.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod.conf b/mod.conf index 50426d2..50f3f51 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = nether description = Adds a deep underground realm with different mapgen that you can reach with obsidian portals. depends = stairs, default -optional_depends = moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls +optional_depends = technic, moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls From f0e825f5420dda1267a8a0a4168d3819051e6ced Mon Sep 17 00:00:00 2001 From: Diablosxm <132860646+Diablosxm@users.noreply.github.com> Date: Fri, 19 May 2023 23:35:16 -0400 Subject: [PATCH 03/11] Add files via upload adding compressor recipe for brick brick_deep brick_compressed and nether_lump --- nether-compressor-recipe.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 nether-compressor-recipe.lua diff --git a/nether-compressor-recipe.lua b/nether-compressor-recipe.lua new file mode 100644 index 0000000..96b0681 --- /dev/null +++ b/nether-compressor-recipe.lua @@ -0,0 +1,22 @@ +local S = minetest.get_translator("nether") + +technic.register_recipe_type("compressing", { description = S("Compressing") }) + +function technic.register_compressor_recipe(data) + data.time = data.time or 4 + technic.register_recipe("compressing", data) +end + +local recipes = { + {"nether:rack", "nether:brick",}, + {"nether:rack_deep", "nether:brick_deep"}, + {"nether:brick 9", "nether:brick_compressed", 12}, + {"nether:brick_compressed 9", "nether:nether_lump", 12} + +} + +for _, data in pairs(recipes) do + technic.register_compressor_recipe({input = {data[1]}, output = data[2], time = data[3]}) +end + + From 86af687576442b6a18806258f44dba4f7505ec14 Mon Sep 17 00:00:00 2001 From: Diablosxm <132860646+Diablosxm@users.noreply.github.com> Date: Sat, 20 May 2023 01:06:25 -0400 Subject: [PATCH 04/11] Update tools.lua adding toolranls optional --- tools.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools.lua b/tools.lua index 1591e47..b4540c6 100644 --- a/tools.lua +++ b/tools.lua @@ -18,9 +18,11 @@ ]]-- local S = nether.get_translator +local toolranks_loaded = minetest.get_modpath("toolranks") +local pickaxe_desc = S("Nether Pickaxe\nWell suited for mining netherrack") minetest.register_tool("nether:pick_nether", { - description = S("Nether Pickaxe\nWell suited for mining netherrack"), + description = toolranks_loaded and toolranks.create_description(pickaxe_desc) or pickaxe_desc, _doc_items_longdesc = S("Uniquely suited for mining netherrack, with minimal wear when doing so. Blunts quickly on other materials."), inventory_image = "nether_tool_netherpick.png", tool_capabilities = { @@ -34,7 +36,9 @@ minetest.register_tool("nether:pick_nether", { sound = {breaks = "default_tool_breaks"}, groups = {pickaxe = 1}, - after_use = function(itemstack, user, node, digparams) + original_description = toolranks_loaded and pickaxe_desc or nil, + after_use = toolranks_loaded and toolranks.new_afteruse or nil, + function(itemstack, user, node, digparams) local wearDivisor = 1 local nodeDef = minetest.registered_nodes[node.name] if nodeDef ~= nil and nodeDef.groups ~= nil then From 4164ecf0415b3a0231d6c34363e680f99f4ca580 Mon Sep 17 00:00:00 2001 From: Diablosxm <132860646+Diablosxm@users.noreply.github.com> Date: Sat, 20 May 2023 01:07:19 -0400 Subject: [PATCH 05/11] Update mod.conf adding optional depends toolranks --- mod.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod.conf b/mod.conf index 50f3f51..978b9b6 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = nether description = Adds a deep underground realm with different mapgen that you can reach with obsidian portals. depends = stairs, default -optional_depends = technic, moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls +optional_depends = toolranks, technic, moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls From 12bd60f3d9d72ecc8bfb41b99472840405d221a3 Mon Sep 17 00:00:00 2001 From: Diablosxm <132860646+Diablosxm@users.noreply.github.com> Date: Sat, 20 May 2023 01:34:51 -0400 Subject: [PATCH 06/11] Update nether-compressor-recipe.lua clear craft recipe --- nether-compressor-recipe.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/nether-compressor-recipe.lua b/nether-compressor-recipe.lua index 96b0681..53b90eb 100644 --- a/nether-compressor-recipe.lua +++ b/nether-compressor-recipe.lua @@ -14,6 +14,36 @@ local recipes = { {"nether:brick_compressed 9", "nether:nether_lump", 12} } +-- clear craft recipe +minetest.clear_craft({ + recipe = { + {"nether:rack", "nether:rack"}, + {"nether:rack", "nether:rack"}, + } +}) + +minetest.clear_craft({ + recipe = { + {"nether:brick","nether:brick","nether:brick"}, + {"nether:brick","nether:brick","nether:brick"}, + {"nether:brick","nether:brick","nether:brick"}, + } +}) + +minetest.clear_craft({ + recipe = { + {"nether:rack_deep", "nether:rack_deep"}, + {"nether:rack_deep", "nether:rack_deep"} + } +}) + +minetest.clear_craft({ + recipe = { + {"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"}, + {"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"}, + {"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"}, + } +}) for _, data in pairs(recipes) do technic.register_compressor_recipe({input = {data[1]}, output = data[2], time = data[3]}) From 854c37751bfe56baf2126a6b6d2f3181fd737e94 Mon Sep 17 00:00:00 2001 From: Diablosxm <132860646+Diablosxm@users.noreply.github.com> Date: Sat, 20 May 2023 21:56:56 -0400 Subject: [PATCH 07/11] Update tools.lua support toolranks but problem with pickaxe --- tools.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools.lua b/tools.lua index b4540c6..51588be 100644 --- a/tools.lua +++ b/tools.lua @@ -18,11 +18,10 @@ ]]-- local S = nether.get_translator -local toolranks_loaded = minetest.get_modpath("toolranks") -local pickaxe_desc = S("Nether Pickaxe\nWell suited for mining netherrack") + minetest.register_tool("nether:pick_nether", { - description = toolranks_loaded and toolranks.create_description(pickaxe_desc) or pickaxe_desc, + description = S("Nether Pickaxe\nWell suited for mining netherrack"), _doc_items_longdesc = S("Uniquely suited for mining netherrack, with minimal wear when doing so. Blunts quickly on other materials."), inventory_image = "nether_tool_netherpick.png", tool_capabilities = { @@ -37,8 +36,7 @@ minetest.register_tool("nether:pick_nether", { groups = {pickaxe = 1}, original_description = toolranks_loaded and pickaxe_desc or nil, - after_use = toolranks_loaded and toolranks.new_afteruse or nil, - function(itemstack, user, node, digparams) + after_use = function(itemstack, user, node, digparams) local wearDivisor = 1 local nodeDef = minetest.registered_nodes[node.name] if nodeDef ~= nil and nodeDef.groups ~= nil then @@ -364,3 +362,9 @@ minetest.register_tool("nether:lightstaff_eternal", { return itemstack end }) +if minetest.get_modpath("toolranks") then +-- toolranks.add_tool("nether:pick_nether"), + toolranks.add_tool("nether:axe_nether"), + toolranks.add_tool("nether:shovel_nether"), + toolranks.add_tool("nether:sword_nether") +end From add8d74323c06e1b8c658f318745dc576db9685e Mon Sep 17 00:00:00 2001 From: Diablosxm <132860646+Diablosxm@users.noreply.github.com> Date: Sat, 20 May 2023 22:28:36 -0400 Subject: [PATCH 08/11] Add files via upload --- tools.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools.lua b/tools.lua index 51588be..fa4de94 100644 --- a/tools.lua +++ b/tools.lua @@ -19,7 +19,6 @@ local S = nether.get_translator - minetest.register_tool("nether:pick_nether", { description = S("Nether Pickaxe\nWell suited for mining netherrack"), _doc_items_longdesc = S("Uniquely suited for mining netherrack, with minimal wear when doing so. Blunts quickly on other materials."), @@ -35,7 +34,6 @@ minetest.register_tool("nether:pick_nether", { sound = {breaks = "default_tool_breaks"}, groups = {pickaxe = 1}, - original_description = toolranks_loaded and pickaxe_desc or nil, after_use = function(itemstack, user, node, digparams) local wearDivisor = 1 local nodeDef = minetest.registered_nodes[node.name] @@ -363,8 +361,8 @@ minetest.register_tool("nether:lightstaff_eternal", { end }) if minetest.get_modpath("toolranks") then --- toolranks.add_tool("nether:pick_nether"), - toolranks.add_tool("nether:axe_nether"), - toolranks.add_tool("nether:shovel_nether"), - toolranks.add_tool("nether:sword_nether") +-- toolranks.add_tool("nether:pick_nether") + toolranks.add_tool("nether:shovel_nether") + toolranks.add_tool("nether:axe_nether") + toolranks.add_tool("nether:sword_nether") end From 5b692cfeb09b6103ea8606e91bfd042e3b7a0f6f Mon Sep 17 00:00:00 2001 From: Treer Date: Sun, 28 May 2023 23:28:09 +1000 Subject: [PATCH 09/11] fix toolranks support for Nether Pickaxe combine the after_use() event of nethertools with toolranks --- .luacheckrc | 3 +++ tools.lua | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 319eba3..6946337 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -27,9 +27,12 @@ read_globals = { "stairsplus", "string.split", table = { fields = { "copy", "getn" } }, + "technic", + "toolranks", "vector", "VoxelArea", "VoxelManip", + "walls", xpanes = { fields = { "register_pane" } }, } diff --git a/tools.lua b/tools.lua index fa4de94..fca8a03 100644 --- a/tools.lua +++ b/tools.lua @@ -153,6 +153,36 @@ minetest.register_craft({ }) +if minetest.get_modpath("toolranks") then + + function add_toolranks(name) + local nethertool_after_use = ItemStack(name):get_definition().after_use + toolranks.add_tool(name) + local toolranks_after_use = ItemStack(name):get_definition().after_use + + if (nethertool_after_use ~= nil and nethertool_after_use ~= toolranks_after_use) then + minetest.override_item(name, { + after_use = function(itemstack, user, node, digparams) + -- combine nethertool_after_use and toolranks_after_use by allowing + -- nethertool_after_use() to calculate the wear... + local initialWear = itemstack:get_wear() + itemstack = nethertool_after_use(itemstack, user, node, digparams) + local wear = itemstack:get_wear() - initialWear + itemstack:set_wear(initialWear) -- restore/undo the wear + + -- ...and have toolranks_after_use() apply the wear. + digparams.wear = wear + return toolranks_after_use(itemstack, user, node, digparams) + end + }) + end + end + + add_toolranks("nether:pick_nether") + add_toolranks("nether:shovel_nether") + add_toolranks("nether:axe_nether") + add_toolranks("nether:sword_nether") +end --===========================-- @@ -360,9 +390,3 @@ minetest.register_tool("nether:lightstaff_eternal", { return itemstack end }) -if minetest.get_modpath("toolranks") then --- toolranks.add_tool("nether:pick_nether") - toolranks.add_tool("nether:shovel_nether") - toolranks.add_tool("nether:axe_nether") - toolranks.add_tool("nether:sword_nether") -end From d84cc4ba7e76784c4cd1adf22805d83f74032452 Mon Sep 17 00:00:00 2001 From: Treer Date: Sun, 28 May 2023 23:34:12 +1000 Subject: [PATCH 10/11] treat technic variable as read-only fix luacheck warning: nether-compressor-recipe.lua:5:10: setting read-only field 'register_compressor_recipe' of global 'technic' since a local function is all we need --- nether-compressor-recipe.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nether-compressor-recipe.lua b/nether-compressor-recipe.lua index 53b90eb..5400161 100644 --- a/nether-compressor-recipe.lua +++ b/nether-compressor-recipe.lua @@ -2,7 +2,7 @@ local S = minetest.get_translator("nether") technic.register_recipe_type("compressing", { description = S("Compressing") }) -function technic.register_compressor_recipe(data) +function register_compressor_recipe(data) data.time = data.time or 4 technic.register_recipe("compressing", data) end @@ -46,7 +46,7 @@ minetest.clear_craft({ }) for _, data in pairs(recipes) do - technic.register_compressor_recipe({input = {data[1]}, output = data[2], time = data[3]}) + register_compressor_recipe({input = {data[1]}, output = data[2], time = data[3]}) end From 24d46c4c641829c1c92b9cfb2d6b46d7c82fda1d Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 9 Mar 2024 19:36:16 +0100 Subject: [PATCH 11/11] local function + formatting --- tools.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tools.lua b/tools.lua index fca8a03..740bf83 100644 --- a/tools.lua +++ b/tools.lua @@ -155,27 +155,29 @@ minetest.register_craft({ if minetest.get_modpath("toolranks") then - function add_toolranks(name) + local function add_toolranks(name) local nethertool_after_use = ItemStack(name):get_definition().after_use toolranks.add_tool(name) local toolranks_after_use = ItemStack(name):get_definition().after_use - if (nethertool_after_use ~= nil and nethertool_after_use ~= toolranks_after_use) then - minetest.override_item(name, { - after_use = function(itemstack, user, node, digparams) - -- combine nethertool_after_use and toolranks_after_use by allowing - -- nethertool_after_use() to calculate the wear... - local initialWear = itemstack:get_wear() - itemstack = nethertool_after_use(itemstack, user, node, digparams) - local wear = itemstack:get_wear() - initialWear - itemstack:set_wear(initialWear) -- restore/undo the wear - - -- ...and have toolranks_after_use() apply the wear. - digparams.wear = wear - return toolranks_after_use(itemstack, user, node, digparams) - end - }) + if nethertool_after_use == nil or nethertool_after_use == toolranks_after_use then + return end + + minetest.override_item(name, { + after_use = function(itemstack, user, node, digparams) + -- combine nethertool_after_use and toolranks_after_use by allowing + -- nethertool_after_use() to calculate the wear... + local initial_wear = itemstack:get_wear() + itemstack = nethertool_after_use(itemstack, user, node, digparams) + local wear = itemstack:get_wear() - initial_wear + itemstack:set_wear(initial_wear) -- restore/undo the wear + + -- ...and have toolranks_after_use() apply the wear. + digparams.wear = wear + return toolranks_after_use(itemstack, user, node, digparams) + end + }) end add_toolranks("nether:pick_nether")