From 0ee3f67846b09b9f447d807e2e1e591219361509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Douglas=20da=20Silva=20Souza?= <44056294+JoseDouglas26@users.noreply.github.com> Date: Fri, 22 Dec 2023 18:57:43 -0300 Subject: [PATCH 1/5] Update butterflies/init.lua Updated butterflies/init.lua to solve issues with on_rightclick --- mods/butterflies/init.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mods/butterflies/init.lua b/mods/butterflies/init.lua index 49240eead5..0fee374fef 100644 --- a/mods/butterflies/init.lua +++ b/mods/butterflies/init.lua @@ -75,14 +75,20 @@ for i in ipairs (butter_list) do on_place = function(itemstack, placer, pointed_thing) local player_name = placer:get_player_name() local pos = pointed_thing.above + local node = minetest.get_node(pointed_thing.under) if not minetest.is_protected(pos, player_name) and - not minetest.is_protected(pointed_thing.under, player_name) and - minetest.get_node(pos).name == "air" then - minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name}) - minetest.get_node_timer(pos):start(1) - itemstack:take_item() - end + not minetest.is_protected(pointed_thing.under, player_name) and + minetest.get_node(pos).name == "air" then + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then + if placer and placer:get_player_control().sneak then + minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name}) + minetest.get_node_timer(pos):start(1) + itemstack:take_item() + else + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) + end + end return itemstack end, on_timer = function(pos, elapsed) From 5ad018249d5f6dbe5a31b0062fe2236f7fd788e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Douglas=20da=20Silva=20Souza?= <44056294+JoseDouglas26@users.noreply.github.com> Date: Sun, 24 Dec 2023 09:48:25 -0300 Subject: [PATCH 2/5] Update init.lua --- mods/butterflies/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/butterflies/init.lua b/mods/butterflies/init.lua index 0fee374fef..c77b76bbac 100644 --- a/mods/butterflies/init.lua +++ b/mods/butterflies/init.lua @@ -89,7 +89,8 @@ for i in ipairs (butter_list) do return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) end end - return itemstack + return itemstack + end end, on_timer = function(pos, elapsed) if minetest.get_node_light(pos) >= 11 then From f0de82e2446d1a41092c3bc7b60fdddcd576df19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Douglas=20da=20Silva=20Souza?= <44056294+JoseDouglas26@users.noreply.github.com> Date: Sun, 24 Dec 2023 10:54:46 -0300 Subject: [PATCH 3/5] Update init.lua --- mods/butterflies/init.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mods/butterflies/init.lua b/mods/butterflies/init.lua index c77b76bbac..ed6fba13e3 100644 --- a/mods/butterflies/init.lua +++ b/mods/butterflies/init.lua @@ -75,22 +75,22 @@ for i in ipairs (butter_list) do on_place = function(itemstack, placer, pointed_thing) local player_name = placer:get_player_name() local pos = pointed_thing.above - local node = minetest.get_node(pointed_thing.under) + local node_under = minetest.get_node(pointed_thing.under) + local node_defs = minetest.registered_nodes[node_under.name] if not minetest.is_protected(pos, player_name) and - not minetest.is_protected(pointed_thing.under, player_name) and - minetest.get_node(pos).name == "air" then - if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - if placer and placer:get_player_control().sneak then + not minetest.is_protected(pointed_thing.under, player_name) then + if node_defs and node_defs.on_rightclick then + if placer and placer:get_player_control().sneak and minetest.get_node(pos).name == "air" then minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name}) minetest.get_node_timer(pos):start(1) itemstack:take_item() else - return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) + return node_defs.on_rightclick(pointed_thing, node, placer, itemstack) end end - return itemstack end + return itemstack end, on_timer = function(pos, elapsed) if minetest.get_node_light(pos) >= 11 then From e032a74f6a7ba6b1f8982b4d4d1951c8532da278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Douglas=20da=20Silva=20Souza?= <44056294+JoseDouglas26@users.noreply.github.com> Date: Sun, 24 Dec 2023 10:57:19 -0300 Subject: [PATCH 4/5] Update init.lua --- mods/butterflies/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/butterflies/init.lua b/mods/butterflies/init.lua index ed6fba13e3..b8ae6a4405 100644 --- a/mods/butterflies/init.lua +++ b/mods/butterflies/init.lua @@ -86,11 +86,11 @@ for i in ipairs (butter_list) do minetest.get_node_timer(pos):start(1) itemstack:take_item() else - return node_defs.on_rightclick(pointed_thing, node, placer, itemstack) + return node_defs.on_rightclick(pointed_thing, node_under, placer, itemstack) end end end - return itemstack + return itemstack end, on_timer = function(pos, elapsed) if minetest.get_node_light(pos) >= 11 then From c33736dbac9006dac8d27fc854efa6743026f2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Douglas=20da=20Silva=20Souza?= <44056294+JoseDouglas26@users.noreply.github.com> Date: Sun, 7 Jan 2024 18:13:29 -0300 Subject: [PATCH 5/5] Update init.lua --- mods/butterflies/init.lua | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/mods/butterflies/init.lua b/mods/butterflies/init.lua index b8ae6a4405..7418759f82 100644 --- a/mods/butterflies/init.lua +++ b/mods/butterflies/init.lua @@ -39,19 +39,7 @@ for i in ipairs (butter_list) do fixed = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1}, }, floodable = true, - on_place = function(itemstack, placer, pointed_thing) - local player_name = placer:get_player_name() - local pos = pointed_thing.above - - if not minetest.is_protected(pos, player_name) and - not minetest.is_protected(pointed_thing.under, player_name) and - minetest.get_node(pos).name == "air" then - minetest.set_node(pos, {name = "butterflies:butterfly_"..name}) - minetest.get_node_timer(pos):start(1) - itemstack:take_item() - end - return itemstack - end, + on_place = minetest.item_place, on_timer = function(pos, elapsed) if minetest.get_node_light(pos) < 11 then minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name})