From b39c36d93117082fb40d954809cf51fc7afa59f5 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Mon, 27 Apr 2015 23:45:18 -0700 Subject: [PATCH] Fix some handling issues and picking up/removal --- README | 3 ++- init.lua | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README b/README index 320175d..cd9c24f 100644 --- a/README +++ b/README @@ -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. ======== diff --git a/init.lua b/init.lua index a49fc12..5604cc9 100644 --- a/init.lua +++ b/init.lua @@ -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