summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfairiestoy <johannesvk@web.de>2013-08-21 05:23:47 +0200
committerfairiestoy <johannesvk@web.de>2013-08-21 05:23:47 +0200
commit065543f3321218af9f9df7749608876110bf5ab8 (patch)
tree770f8cf2c10c9f1392fb8ee3d8619d5730080800
parent0ead0b1e5a1c8ed9aa5d516c53a48e9683b70921 (diff)
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'
-rw-r--r--init.lua26
1 files changed, 26 insertions, 0 deletions
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