Fix rightclick, reduce range to 0, disable dig

This commit is contained in:
Wuzzy 2016-08-02 18:19:41 +02:00
parent f24fc2b04e
commit ef94a65906

View File

@ -29,20 +29,34 @@ returnmirror.mana_check = function(player, cost)
return allowed
end
returnmirror.set_position_inactive = function(itemstack, user, pointed_thing)
if returnmirror.mana_check(user, returnmirror.cost_set) then
local pos = user:getpos()
local newitem = ItemStack("returnmirror:mirror_active")
newitem:set_metadata(minetest.pos_to_string(pos))
minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12})
return newitem
end
end
returnmirror.set_position_active = function(itemstack, user, pointed_thing)
if returnmirror.mana_check(user, returnmirror.cost_set) then
local pos = user:getpos()
itemstack:set_metadata(minetest.pos_to_string(pos))
minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12})
return itemstack
end
end
minetest.register_tool("returnmirror:mirror_inactive", {
description = "Mirror of Returning",
inventory_image = "returnmirror_mirror_inactive.png",
wield_image = "returnmirror_mirror_inactive.png",
tool_capabilities = {},
on_place = function(itemstack, placer, pointed_thing)
if returnmirror.mana_check(placer, returnmirror.cost_set) then
local pos = placer:getpos()
local newitem = ItemStack("returnmirror:mirror_active")
newitem:set_metadata(minetest.pos_to_string(pos))
minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12})
return newitem
end
end,
range = 0,
on_use = function() end,
on_place = returnmirror.set_position_inactive,
on_secondary_use = returnmirror.set_position_inactive,
})
minetest.register_tool("returnmirror:mirror_active", {
@ -51,6 +65,7 @@ minetest.register_tool("returnmirror:mirror_active", {
inventory_image = "returnmirror_mirror_active.png",
wield_image = "returnmirror_mirror_active.png",
tool_capabilities = {},
range = 0,
on_use = function(itemstack, user, pointed_thing)
local dest_string = itemstack:get_metadata()
local dest = minetest.string_to_pos(dest_string)
@ -89,14 +104,8 @@ minetest.register_tool("returnmirror:mirror_active", {
end
end
end,
on_place = function(itemstack, placer, pointed_thing)
if returnmirror.mana_check(placer, returnmirror.cost_set) then
local pos = placer:getpos()
itemstack:set_metadata(minetest.pos_to_string(pos))
minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12})
return itemstack
end
end,
on_place = returnmirror.set_position_active,
on_secondary_use = returnmirror.set_position_active,
groups = { not_in_creative_inventory = 1 },
})