From 727dec74e04b71b5b5a7f81df466ffd0e68fbac1 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 28 Dec 2014 16:09:53 +0000 Subject: [PATCH] Use minetest.is_protected instead of register_on_dig etc --- mods/capturetheflag/ctf_protect/init.lua | 32 ++++++------------------ 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/mods/capturetheflag/ctf_protect/init.lua b/mods/capturetheflag/ctf_protect/init.lua index fef9ae3..bcc1027 100644 --- a/mods/capturetheflag/ctf_protect/init.lua +++ b/mods/capturetheflag/ctf_protect/init.lua @@ -1,37 +1,19 @@ -- This mod is used to protect nodes in the capture the flag game +local old_is_protected = minetest.is_protected -function stop_dig(name,pos) +function minetest.is_protected(pos, name) local team = ctf.area.get_area(pos) - + if not team then - return false + return old_is_protected(pos, name) end if ctf.players and ctf.player(name) and ctf.player(name).team then if ctf.player(name).team == team then - return false + return old_is_protected(pos, name) end end - return team + minetest.chat_send_player(name, "You cannot dig on team "..team.."'s land") + return true end - -minetest.register_on_dignode(function(pos, oldnode, digger) - if digger and digger:get_player_name() then - local res = stop_dig(digger:get_player_name(),pos) - if res then - minetest.chat_send_player(digger:get_player_name(),"You can not dig on team "..res.."'s land") - minetest.env:set_node(pos,oldnode) - end - end -end) - -minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack) - if placer and placer:get_player_name() then - local res = stop_dig(placer:get_player_name(),pos) - if res then - minetest.chat_send_player(placer:get_player_name(),"You can not place on team "..res.."'s land") - minetest.env:set_node(pos,oldnode) - end - end -end) \ No newline at end of file