Update butterflies/init.lua

Updated butterflies/init.lua to solve issues with on_rightclick
This commit is contained in:
José Douglas da Silva Souza 2023-12-22 18:57:43 -03:00 committed by GitHub
parent b9c089474c
commit 0ee3f67846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -75,14 +75,20 @@ for i in ipairs (butter_list) do
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local player_name = placer:get_player_name() local player_name = placer:get_player_name()
local pos = pointed_thing.above local pos = pointed_thing.above
local node = minetest.get_node(pointed_thing.under)
if not minetest.is_protected(pos, player_name) and if not minetest.is_protected(pos, player_name) and
not minetest.is_protected(pointed_thing.under, player_name) and not minetest.is_protected(pointed_thing.under, player_name) and
minetest.get_node(pos).name == "air" then minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name}) if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
minetest.get_node_timer(pos):start(1) if placer and placer:get_player_control().sneak then
itemstack:take_item() minetest.set_node(pos, {name = "butterflies:hidden_butterfly_"..name})
end 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 return itemstack
end, end,
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)