forked from mtcontrib/minetest_returnmirror
Fix rightclick, reduce range to 0, disable dig
This commit is contained in:
parent
f24fc2b04e
commit
ef94a65906
43
init.lua
43
init.lua
|
@ -29,20 +29,34 @@ returnmirror.mana_check = function(player, cost)
|
||||||
return allowed
|
return allowed
|
||||||
end
|
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", {
|
minetest.register_tool("returnmirror:mirror_inactive", {
|
||||||
description = "Mirror of Returning",
|
description = "Mirror of Returning",
|
||||||
inventory_image = "returnmirror_mirror_inactive.png",
|
inventory_image = "returnmirror_mirror_inactive.png",
|
||||||
wield_image = "returnmirror_mirror_inactive.png",
|
wield_image = "returnmirror_mirror_inactive.png",
|
||||||
tool_capabilities = {},
|
tool_capabilities = {},
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
range = 0,
|
||||||
if returnmirror.mana_check(placer, returnmirror.cost_set) then
|
on_use = function() end,
|
||||||
local pos = placer:getpos()
|
on_place = returnmirror.set_position_inactive,
|
||||||
local newitem = ItemStack("returnmirror:mirror_active")
|
on_secondary_use = returnmirror.set_position_inactive,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("returnmirror:mirror_active", {
|
minetest.register_tool("returnmirror:mirror_active", {
|
||||||
|
@ -51,6 +65,7 @@ minetest.register_tool("returnmirror:mirror_active", {
|
||||||
inventory_image = "returnmirror_mirror_active.png",
|
inventory_image = "returnmirror_mirror_active.png",
|
||||||
wield_image = "returnmirror_mirror_active.png",
|
wield_image = "returnmirror_mirror_active.png",
|
||||||
tool_capabilities = {},
|
tool_capabilities = {},
|
||||||
|
range = 0,
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
local dest_string = itemstack:get_metadata()
|
local dest_string = itemstack:get_metadata()
|
||||||
local dest = minetest.string_to_pos(dest_string)
|
local dest = minetest.string_to_pos(dest_string)
|
||||||
|
@ -89,14 +104,8 @@ minetest.register_tool("returnmirror:mirror_active", {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = returnmirror.set_position_active,
|
||||||
if returnmirror.mana_check(placer, returnmirror.cost_set) then
|
on_secondary_use = returnmirror.set_position_active,
|
||||||
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,
|
|
||||||
groups = { not_in_creative_inventory = 1 },
|
groups = { not_in_creative_inventory = 1 },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue