Fix some handling issues and picking up/removal

This commit is contained in:
Auke Kok 2015-04-27 23:45:18 -07:00
parent ba6ade74b3
commit b39c36d931
2 changed files with 13 additions and 2 deletions

3
README
View File

@ -17,7 +17,8 @@ A warpstone can be given or found in the creative inventory (item
id: warps:warpstone). This warpstone can be placed on the ground
and be programmed to warp players who punch it to a certain warp
location (one of the warps in /listwarps). Right-clicking the item
as a warp_admin user will allow you to program the warpstone.
as a warp_admin user will allow you to program the warpstone. The
warpstone can be removed by shift-punching the warp stone.
========

View File

@ -145,6 +145,7 @@ minetest.register_node("warps:warpstone", {
walkable = false,
paramtype = "light",
groups = { choppy=3 },
light_source = 5,
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}
@ -160,6 +161,9 @@ minetest.register_node("warps:warpstone", {
minetest.chat_send_player(sender:get_player_name(), "You do not have permission to modify warp stones")
return false
end
if not fields.destination then
return
end
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"field[destination;Warp Destination;" .. fields.destination .. "]")
@ -167,10 +171,16 @@ minetest.register_node("warps:warpstone", {
minetest.log("action", sender:get_player_name() .. " changed warp stone to \"" .. fields.destination .. "\"")
end,
on_punch = function(pos, node, puncher, pointed_thingo)
if puncher:get_player_control().sneak and minetest.check_player_privs(puncher:get_player_name(), {warp_admin = true}) then
minetest.remove_node(pos)
minetest.chat_send_player(puncher:get_player_name(), "Warp stone removed!")
return
end
local meta = minetest.get_meta(pos)
local destination = meta:get_string("warps_destination")
if destination == "" then
return false, "Warp stone not initialized"
minetest.chat_send_player(puncher:get_player_name(), "Unknown warp location for this warp stone, cannot warp!")
return false
end
for i = 1,table.getn(warps) do
if warps[i].name == destination then