From e56fa0d8098aaef6b5e325aafe8cf9248f50986a Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 23 Oct 2022 00:38:56 +0200 Subject: [PATCH 1/7] Lightning Rod Fixes - give node a proper nodebox - add better texture compatible with MC texture packs - set use_texture_alpha = "opaque" - fix invalid translator - disable node placement prediction - simplificate placement code --- mods/ITEMS/mcl_lightning_rods/init.lua | 51 +++++++++--------- .../textures/mcl_lightning_rods_rod.png | Bin 236 -> 144 bytes 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/mods/ITEMS/mcl_lightning_rods/init.lua b/mods/ITEMS/mcl_lightning_rods/init.lua index 41d9adfbd..593a3119b 100644 --- a/mods/ITEMS/mcl_lightning_rods/init.lua +++ b/mods/ITEMS/mcl_lightning_rods/init.lua @@ -1,34 +1,39 @@ -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator("mcl_lightning_rods") +---@type nodebox local cbox = { type = "fixed", fixed = { - { 0/16, -8/16, 0/16, 2/16, 4/16, 2/16 }, - { 0/16, 4/16, 0/16, 3/16, 8/16, 3/16 }, - } + { -0.0625, -0.5, -0.0625, 0.0625, 0.25, 0.0625 }, + { -0.125, 0.25, -0.125, 0.125, 0.5, 0.125 }, + }, } +local text_top = "[combine:16x16:6,6=mcl_lightning_rods_rod.png" +local text_side = "[combine:16x16:7,0=mcl_lightning_rods_rod.png:-6,0=mcl_lightning_rods_rod.png\\^[transformR270" + minetest.register_node("mcl_lightning_rods:rod", { description = S("Lightning Rod"), _doc_items_longdesc = S("A block that attracts lightning"), - --inventory_image = "mcl_lightning_rods_rod_inv.png", tiles = { - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", + text_top, + text_top, + text_side, + text_side, + text_side, + text_side, }, drawtype = "nodebox", is_ground_content = false, paramtype = "light", paramtype2 = "facedir", - groups = {pickaxey=2,attracts_lightning=1}, + use_texture_alpha = "opaque", + groups = { pickaxey = 2, attracts_lightning = 1 }, sounds = mcl_sounds.node_sound_metal_defaults(), node_box = cbox, selection_box = cbox, collision_box = cbox, + node_placement_prediction = "", on_place = function(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then return itemstack @@ -40,12 +45,7 @@ minetest.register_node("mcl_lightning_rods:rod", { local placer_pos = placer:get_pos() if placer_pos then - local dir = { - x = p1.x - placer_pos.x, - y = p1.y - placer_pos.y, - z = p1.z - placer_pos.z - } - param2 = minetest.dir_to_facedir(dir) + param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos)) end if p0.y - 1 == p1.y then @@ -63,20 +63,19 @@ minetest.register_node("mcl_lightning_rods:rod", { return minetest.item_place(itemstack, placer, pointed_thing, param2) end, - sounds = mcl_sounds.node_sound_glass_defaults(), _mcl_blast_resistance = 0, }) -lightning.register_on_strike(function(pos,pos2,objects) - local lr = minetest.find_node_near(pos,128,{"group:attracts_lightning"},true) - return lr,nil +lightning.register_on_strike(function(pos, pos2, objects) + local lr = minetest.find_node_near(pos, 128, { "group:attracts_lightning" }, true) + return lr, nil end) minetest.register_craft({ output = "mcl_lightning_rods:rod", recipe = { - {"", "mcl_copper:copper_ingot",""}, - {"", "mcl_copper:copper_ingot",""}, - {"", "mcl_copper:copper_ingot",""}, - } + { "", "mcl_copper:copper_ingot", "" }, + { "", "mcl_copper:copper_ingot", "" }, + { "", "mcl_copper:copper_ingot", "" }, + }, }) diff --git a/mods/ITEMS/mcl_lightning_rods/textures/mcl_lightning_rods_rod.png b/mods/ITEMS/mcl_lightning_rods/textures/mcl_lightning_rods_rod.png index 71a0817029b40ca0c3638407651824cd5b1c315e..227ff1ceb5189aa13b1aa278a4bc182ad908b5ed 100644 GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`;hrvzAr`&K7UIdji literal 236 zcmVzXxl4Npk4p=SdCc<~~ zz}OB{6t8JqO9k7R)(!vK;kGPvwJ_Dd-={lM-8r_#8i~J-Gl#}dRWbtyIQAVu@^M>G zfT^rR1OR#(dPw-33s1eHTLgP10Ba3YL}<+bFj2HOnh?g(c|#0000 Date: Sun, 23 Oct 2022 00:40:39 +0200 Subject: [PATCH 2/7] Add locale template to mcl_lightning_rods --- mods/ITEMS/mcl_lightning_rods/locale/template.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 mods/ITEMS/mcl_lightning_rods/locale/template.txt diff --git a/mods/ITEMS/mcl_lightning_rods/locale/template.txt b/mods/ITEMS/mcl_lightning_rods/locale/template.txt new file mode 100644 index 000000000..5b2bbbcd2 --- /dev/null +++ b/mods/ITEMS/mcl_lightning_rods/locale/template.txt @@ -0,0 +1,3 @@ +# textdomain: mcl_lightning_rods +Lightning Rod= +A block that attracts lightning= \ No newline at end of file From cb7d5e37904c7049772f21a3713fa8f1154c8045 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 23 Oct 2022 00:45:10 +0200 Subject: [PATCH 3/7] Make lightning rod texture look better --- .../textures/mcl_lightning_rods_rod.png | Bin 144 -> 146 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/mods/ITEMS/mcl_lightning_rods/textures/mcl_lightning_rods_rod.png b/mods/ITEMS/mcl_lightning_rods/textures/mcl_lightning_rods_rod.png index 227ff1ceb5189aa13b1aa278a4bc182ad908b5ed..9b20cb45404f7026ad7957a8c93d93beea63520a 100644 GIT binary patch delta 40 vcmbQhIEitB3S;C%)j%1e1=pgQm6#c_o&|KB`F-L90}yz+`njxgN@xNA9rX@# delta 38 scmbQlIDv733S;<0)j%meX0IehhCKOzY1{p+?lAy?r>mdKI;Vst0K_Z`lK=n! From a11948c5f3bbab7344583f8eebe09aacd9cd483a Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 8 Nov 2022 21:15:23 +0100 Subject: [PATCH 4/7] Add new texture --- .../textures/mcl_lightning_rods_rod.png | Bin 146 -> 203 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/mods/ITEMS/mcl_lightning_rods/textures/mcl_lightning_rods_rod.png b/mods/ITEMS/mcl_lightning_rods/textures/mcl_lightning_rods_rod.png index 9b20cb45404f7026ad7957a8c93d93beea63520a..355b2bd0143a03237a239f0f73685221639c0e50 100644 GIT binary patch delta 175 zcmV;g08syu0m}i9B!7}gL_t(IjboVXYx#dcsKb8{4Z;kh0+6QFkxu_xU5&v8k!%1+ z6G(Hul@|FfK=ua71{B-s{4cQ9B3&a4R5|GV&otK{-+*dIeX#$@HlWVg;D5TAI{5~a z*y;RFGo`?QQaj!Mh1S}Xc_G(QlY9fp?R6=Og#w`Sb1W!uK`03@Ar;wB5(Z8N|MMtH d2Tqiw0|5C5P3;OxN74WQ002ovPDHLkV1jI3Pcr}j delta 117 zcmV-*0E++10g?fbByL$rL_t(Ijbk_$WBVV3cLte*X$DdONYi|G{r?jjw8%36WHU%} zv$Y!76=b=9A}@e!uP{?0T_X&DoIdad6dK8sZvZF^C^CRz7f>7q!z3ChGN9I4gCYX} XYUWUi%=^g500000NkvXXu0mjf{bVY< From 47e46efa6fcd14fa5ca832ed3f706b8808be9d07 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 8 Nov 2022 21:23:17 +0100 Subject: [PATCH 5/7] Add french translation --- mods/ITEMS/mcl_lightning_rods/locale/mcl_lightning_rods.fr.tr | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 mods/ITEMS/mcl_lightning_rods/locale/mcl_lightning_rods.fr.tr diff --git a/mods/ITEMS/mcl_lightning_rods/locale/mcl_lightning_rods.fr.tr b/mods/ITEMS/mcl_lightning_rods/locale/mcl_lightning_rods.fr.tr new file mode 100644 index 000000000..8f99047f6 --- /dev/null +++ b/mods/ITEMS/mcl_lightning_rods/locale/mcl_lightning_rods.fr.tr @@ -0,0 +1,3 @@ +# textdomain: mcl_lightning_rods +Lightning Rod=Paratonnerre +A block that attracts lightning=Un bloc qui attire la foudre \ No newline at end of file From 5f626cf1b02db0d568606ba01d3e409b8d4acd1b Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 8 Nov 2022 22:40:36 +0100 Subject: [PATCH 6/7] Make lightning rods send redstone signal when struck by lighting (0.5s) --- mods/ITEMS/mcl_lightning_rods/init.lua | 61 +++++++++++++++++++++++++- mods/ITEMS/mcl_lightning_rods/mod.conf | 2 +- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_lightning_rods/init.lua b/mods/ITEMS/mcl_lightning_rods/init.lua index 593a3119b..1c78e8dae 100644 --- a/mods/ITEMS/mcl_lightning_rods/init.lua +++ b/mods/ITEMS/mcl_lightning_rods/init.lua @@ -12,7 +12,11 @@ local cbox = { local text_top = "[combine:16x16:6,6=mcl_lightning_rods_rod.png" local text_side = "[combine:16x16:7,0=mcl_lightning_rods_rod.png:-6,0=mcl_lightning_rods_rod.png\\^[transformR270" -minetest.register_node("mcl_lightning_rods:rod", { +local text_top_active = "[combine:16x16:6,6=mcl_lightning_rods_rod.png\\^[brighten" +local text_side_active = "[combine:16x16:7,0=mcl_lightning_rods_rod.png\\^[brighten:-6,0=mcl_lightning_rods_rod.png\\^[transformR270\\^[brighten" + +---@type node_definition +local rod_def = { description = S("Lightning Rod"), _doc_items_longdesc = S("A block that attracts lightning"), tiles = { @@ -34,6 +38,12 @@ minetest.register_node("mcl_lightning_rods:rod", { selection_box = cbox, collision_box = cbox, node_placement_prediction = "", + mesecons = { + receptor = { + state = mesecon.state.off, + rules = mesecon.rules.alldirs, + }, + }, on_place = function(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then return itemstack @@ -64,10 +74,57 @@ minetest.register_node("mcl_lightning_rods:rod", { end, _mcl_blast_resistance = 0, -}) +} + +minetest.register_node("mcl_lightning_rods:rod", rod_def) + +local rod_def_a = table.copy(rod_def) + +rod_def_a.tiles = { + text_top_active, + text_top_active, + text_side_active, + text_side_active, + text_side_active, + text_side_active, +} + +rod_def_a.groups.not_in_creative_inventory = 1 + +rod_def_a.mesecons = { + receptor = { + state = mesecon.state.on, + rules = mesecon.rules.alldirs, + }, +} + +rod_def_a.on_timer = function(pos, elapsed) + local node = minetest.get_node(pos) + + if node.name == "mcl_lightning_rods:rod_powered" then --has not been dug + minetest.set_node(pos, { name = "mcl_lightning_rods:rod" }) + mesecon.receptor_off(pos, mesecon.rules.alldirs) + end + + return false +end + +minetest.register_node("mcl_lightning_rods:rod_powered", rod_def_a) + lightning.register_on_strike(function(pos, pos2, objects) local lr = minetest.find_node_near(pos, 128, { "group:attracts_lightning" }, true) + + if lr then + local node = minetest.get_node(lr) + + if node.name == "mcl_lightning_rods:rod" then + minetest.set_node(lr, { name = "mcl_lightning_rods:rod_powered" }) + mesecon.receptor_on(lr, mesecon.rules.alldirs) + minetest.get_node_timer(lr):start(0.5) + end + end + return lr, nil end) diff --git a/mods/ITEMS/mcl_lightning_rods/mod.conf b/mods/ITEMS/mcl_lightning_rods/mod.conf index cafd9ba5e..dd30d7aa7 100644 --- a/mods/ITEMS/mcl_lightning_rods/mod.conf +++ b/mods/ITEMS/mcl_lightning_rods/mod.conf @@ -1,3 +1,3 @@ name = mcl_lightning_rods author = cora -depends = mcl_sounds, lightning +depends = mcl_sounds, lightning, mesecons From 7dbe6489bebc0673bc8c6e1115a1c89f2f0ac66a Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 9 Nov 2022 20:20:08 +0100 Subject: [PATCH 7/7] Change lighting rod activation time to 0.4 --- mods/ITEMS/mcl_lightning_rods/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_lightning_rods/init.lua b/mods/ITEMS/mcl_lightning_rods/init.lua index 1c78e8dae..72763a37b 100644 --- a/mods/ITEMS/mcl_lightning_rods/init.lua +++ b/mods/ITEMS/mcl_lightning_rods/init.lua @@ -121,7 +121,7 @@ lightning.register_on_strike(function(pos, pos2, objects) if node.name == "mcl_lightning_rods:rod" then minetest.set_node(lr, { name = "mcl_lightning_rods:rod_powered" }) mesecon.receptor_on(lr, mesecon.rules.alldirs) - minetest.get_node_timer(lr):start(0.5) + minetest.get_node_timer(lr):start(0.4) end end