From 1130f447a62cdcb40fe24d68b7717eaa55b1f9bb Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Tue, 6 Jun 2017 10:26:54 +0100 Subject: added protector_night_pvp setting --- pvp.lua | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'pvp.lua') diff --git a/pvp.lua b/pvp.lua index 6cc5407..90a8d3f 100644 --- a/pvp.lua +++ b/pvp.lua @@ -7,13 +7,16 @@ local statspawn = minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 2 -- is pvp protection enabled protector.pvp = minetest.setting_getbool("protector_pvp") +-- is night-only pvp enabled +protector.night_pvp = minetest.setting_getbool("protector_night_pvp") + -- disables PVP in your own protected areas if minetest.setting_getbool("enable_pvp") and protector.pvp then if minetest.register_on_punchplayer then - minetest.register_on_punchplayer( - function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) + minetest.register_on_punchplayer(function(player, hitter, + time_from_last_punch, tool_capabilities, dir, damage) if not player or not hitter then @@ -36,12 +39,26 @@ if minetest.setting_getbool("enable_pvp") and protector.pvp then return true end + -- do we enable pvp at night time only ? + if protector.night_pvp then + + -- get time of day + local tod = minetest.get_timeofday() or 0 + + if tod > 0.2 and tod < 0.8 then + -- + else + return false + end + end + + -- is player being punched inside a protected area ? if minetest.is_protected(pos, hitter:get_player_name()) then return true - else - return false end + return false + end) else print(S("[Protector] pvp_protect not active, update your version of Minetest")) -- cgit v1.2.3