From 065543f3321218af9f9df7749608876110bf5ab8 Mon Sep 17 00:00:00 2001 From: fairiestoy Date: Wed, 21 Aug 2013 05:23:47 +0200 Subject: Added TNT workaround Added a quick workaround to avoid TNT set near claimed areas to destroy partial buildings or landscapes with the TNT exploit. Since overwriting the registered node functions seem not to work as expected, used the landrush own routines for this 'fix' --- init.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/init.lua b/init.lua index ea99421..2c925f8 100644 --- a/init.lua +++ b/init.lua @@ -252,6 +252,32 @@ function minetest.item_place(itemstack, placer, pointed_thing) owner = landrush.get_owner(pointed_thing.above) player = placer:get_player_name() if landrush.can_interact(player, pointed_thing.above) or itemstack:get_name() == "" then + -- add a workaround for TNT, since overwriting the registered node seems not to work + if itemstack:get_name() == "tnt:tnt" or itemstack:get_name() == "tnt:tnt_burning" then + local pos = pointed_thing.above + local temp_pos = pos + temp_pos.x = pos.x + 2 + if player ~= landrush.get_owner( temp_pos ) then + minetest.chat_send_player( player, "Do not place TNT near claimed areas..." ) + return itemstack + end + temp_pos.x = pos.x - 2 + if player ~= landrush.get_owner( temp_pos ) then + minetest.chat_send_player( player, "Do not place TNT near claimed areas..." ) + return itemstack + end + temp_pos.z = pos.z + 2 + if player ~= landrush.get_owner( temp_pos ) then + minetest.chat_send_player( player, "Do not place TNT near claimed areas..." ) + return itemstack + end + temp_pos.z = pos.z - 2 + if player ~= landrush.get_owner( temp_pos ) then + minetest.chat_send_player( player, "Do not place TNT near claimed areas..." ) + return itemstack + end + end + -- end of the workaround return landrush.default_place(itemstack, placer, pointed_thing) else if ( owner ~= nil ) then -- cgit v1.2.3