forked from mtcontrib/minetest_returnmirror
Allow to use pointed node
This commit is contained in:
parent
d924625eb2
commit
a627418860
24
init.lua
24
init.lua
@ -37,6 +37,16 @@ returnmirror.mana_check = function(player, cost)
|
||||
end
|
||||
|
||||
returnmirror.set_position_inactive = function(itemstack, user, pointed_thing)
|
||||
-- Use pointed node's on_rightclick function first, if present
|
||||
if pointed_thing.type == "node" then
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
if user and not user:get_player_control().sneak then
|
||||
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if returnmirror.mana_check(user, returnmirror.cost_set) then
|
||||
local pos = user:getpos()
|
||||
local newitem = ItemStack("returnmirror:mirror_active")
|
||||
@ -49,6 +59,16 @@ returnmirror.set_position_inactive = function(itemstack, user, pointed_thing)
|
||||
end
|
||||
|
||||
returnmirror.set_position_active = function(itemstack, user, pointed_thing)
|
||||
-- Use pointed node's on_rightclick function first, if present
|
||||
if pointed_thing.type == "node" then
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
if user and not user:get_player_control().sneak then
|
||||
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if returnmirror.mana_check(user, returnmirror.cost_set) then
|
||||
local pos = user:getpos()
|
||||
itemstack:set_metadata(minetest.pos_to_string(pos))
|
||||
@ -77,7 +97,7 @@ minetest.register_tool("returnmirror:mirror_inactive", {
|
||||
inventory_image = "returnmirror_mirror_inactive.png",
|
||||
wield_image = "returnmirror_mirror_inactive.png",
|
||||
tool_capabilities = {},
|
||||
range = 0,
|
||||
range = 2,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
minetest.sound_play( {name="returnmirror_fail", gain=1}, {pos=user:getpos(), max_hear_distance=18})
|
||||
end,
|
||||
@ -92,7 +112,7 @@ minetest.register_tool("returnmirror:mirror_active", {
|
||||
inventory_image = "returnmirror_mirror_active.png",
|
||||
wield_image = "returnmirror_mirror_active.png",
|
||||
tool_capabilities = {},
|
||||
range = 0,
|
||||
range = 2,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local dest_string = itemstack:get_metadata()
|
||||
local dest = minetest.string_to_pos(dest_string)
|
||||
|
Loading…
Reference in New Issue
Block a user