summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2015-08-19 11:34:19 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2015-08-19 11:34:19 +0100
commitc409f445d6c9f06f80c3fba1bbac7736db91755b (patch)
tree642ce220542f68bcb478b25389b4c579982967e2 /init.lua
parent313039b165e117157b5ee8e430309092f66b6d80 (diff)
Added spawn protection from pvp using protector_pvp_spawn setting in minetest.conf
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 31d37ba..e1b70ba 100644
--- a/init.lua
+++ b/init.lua
@@ -1,9 +1,13 @@
minetest.register_privilege("delprotect","Ignore player protection")
+-- get static spawn position
+local statspawn = (minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 2, z = 0})
+
protector = {}
protector.mod = "redo"
protector.radius = (tonumber(minetest.setting_get("protector_radius")) or 5)
protector.pvp = minetest.setting_get("protector_pvp") or false
+protector.spawn = (tonumber(minetest.setting_get("protector_pvp_spawn")) or 0)
protector.get_member_list = function(meta)
return meta:get_string("members"):split(" ")
@@ -713,7 +717,18 @@ if minetest.setting_getbool("enable_pvp") and protector.pvp == "true" then
return false
end
- if minetest.is_protected(player:getpos(), hitter:get_player_name()) then
+ -- no pvp at spawn area
+ local pos = player:getpos()
+ if pos.x < statspawn.x + protector.spawn
+ and pos.x > statspawn.x - protector.spawn
+ and pos.y < statspawn.y + protector.spawn
+ and pos.y > statspawn.y - protector.spawn
+ and pos.z < statspawn.z + protector.spawn
+ and pos.z > statspawn.z - protector.spawn then
+ return true
+ end
+
+ if minetest.is_protected(pos, hitter:get_player_name()) then
return true
else
return false