summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-07-21 09:01:48 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2016-07-21 09:01:48 +0100
commit04166fc7e4e45102261594fcb043c0ea8bf182ee (patch)
treee92d4b605c9ee13d92cf0317be9f32caccb94770
parentf5dd6da5635e67e3c44ed3530d19a29a6ee16083 (diff)
Flipped horizontal AND vertical thanks to auouymous
-rw-r--r--README.md21
-rw-r--r--init.lua36
2 files changed, 42 insertions, 15 deletions
diff --git a/README.md b/README.md
index 74f8976..e6984eb 100644
--- a/README.md
+++ b/README.md
@@ -56,3 +56,24 @@ remove all names from list
Whenever a player is near any protectors with name1 or name2 then it will be
replaced by an air block.
+
+
+The following lines can be added to your minetest.conf file to configure specific features of the mod:
+
+protector_radius = 5
+- Sets the area around each protection node so that other players cannot dig, place or enter through protected doors or chests.
+
+protector_pvp = true
+- true or false this setting disabled pvp inside of protected areas for all players apart from those listed on the protector node.
+
+protector_pvp_spawn = 10
+- Sets an area 10 nodes around spawn where pvp is disabled completely.
+
+protector_drop = true
+- When true players who dig inside a protected area will automatically drop tools to stop them going any further.
+
+protector_hurt = 2
+- When set to above 0, players digging in protected areas will be hurt by 2 health points (or whichever number it's set to)
+
+protector_flip = true
+- When true players who dig inside a protected area will flipped around to stop them using lag to grief into someone else's build
diff --git a/init.lua b/init.lua
index 3a366c0..635d0bd 100644
--- a/init.lua
+++ b/init.lua
@@ -247,26 +247,32 @@ function minetest.is_protected(pos, digger)
player:set_hp(player:get_hp() - protector.hurt)
end
- -- flip player around when protection violated
+ -- flip player when protection violated
if protector.flip
and player then
+ -- yaw + 180°
+ local yaw = player:get_look_yaw() + math.pi
+
+ if yaw > 2 * math.pi then
+ yaw = yaw - 2 * math.pi
+ end
+
+ player:set_look_yaw(yaw)
+
+ -- invert pitch
+ player:set_look_vertical(-player:get_look_vertical())
+
+ -- if digging below player, move up 1 block
local pla_pos = player:getpos()
- local vec = {
- x = pos.x - pla_pos.x,
- y = pos.y - pla_pos.y,
- z = pos.z - pla_pos.z
- }
- if vec.x ~= 0
- and vec.z ~= 0 then
-
- local yaw = math.atan(vec.z / vec.x) + 3 * math.pi / 2
-
- if pos.x > pla_pos.x then
- yaw = yaw + math.pi
- end
- player:set_look_yaw(yaw)
+ if pos.y < pla_pos.y then
+
+ player:setpos({
+ x = pla_pos.x,
+ y = pla_pos.y + 1,
+ z = pla_pos.z
+ })
end
end