Use minetest.is_protected instead of register_on_dig etc
This commit is contained in:
parent
46c8c60cb3
commit
727dec74e0
@ -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)
|
Loading…
x
Reference in New Issue
Block a user