mirror of
https://notabug.org/TenPlus1/protector.git
synced 2025-01-10 03:17:34 +01:00
added protector_night_pvp setting
This commit is contained in:
parent
da742fd386
commit
1130f447a6
@ -46,6 +46,8 @@ Change log:
|
|||||||
stand on a protector, face in a direction and it places a new one at a set
|
stand on a protector, face in a direction and it places a new one at a set
|
||||||
distance to cover protection radius. Added /protector_show command (thanks agaran)
|
distance to cover protection radius. Added /protector_show command (thanks agaran)
|
||||||
Protectors and chest cannot be moved by mesecon pistons or machines.
|
Protectors and chest cannot be moved by mesecon pistons or machines.
|
||||||
|
2.1 - Added 'protector_night_pvp' setting so night-time becomes a free for all and
|
||||||
|
players can hurt one another even inside protected areas (not spawn protected)
|
||||||
|
|
||||||
Lucky Blocks: 6
|
Lucky Blocks: 6
|
||||||
|
|
||||||
@ -93,12 +95,12 @@ protector_radius = 5
|
|||||||
protector_pvp = true
|
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.
|
- true or false this setting disabled pvp inside of protected areas for all players apart from those listed on the protector node.
|
||||||
|
|
||||||
|
protector_night_pvp = false
|
||||||
|
- when true this setting enables pvp at night time only, even inside protected areas, requires protector_pvp to be active to work.
|
||||||
|
|
||||||
protector_spawn = 10
|
protector_spawn = 10
|
||||||
- Sets an area 10 nodes around static spawnpoint that is protected.
|
- Sets an area 10 nodes around static spawnpoint that is protected.
|
||||||
|
|
||||||
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
|
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)
|
- When set to above 0, players digging in protected areas will be hurt by 2 health points (or whichever number it's set to)
|
||||||
|
|
||||||
|
25
init.lua
25
init.lua
@ -7,7 +7,6 @@
|
|||||||
protector = {}
|
protector = {}
|
||||||
protector.mod = "redo"
|
protector.mod = "redo"
|
||||||
protector.radius = tonumber(minetest.setting_get("protector_radius")) or 5
|
protector.radius = tonumber(minetest.setting_get("protector_radius")) or 5
|
||||||
--protector.drop = minetest.setting_getbool("protector_drop") or false
|
|
||||||
protector.flip = minetest.setting_getbool("protector_flip") or false
|
protector.flip = minetest.setting_getbool("protector_flip") or false
|
||||||
protector.hurt = tonumber(minetest.setting_get("protector_hurt")) or 0
|
protector.hurt = tonumber(minetest.setting_get("protector_hurt")) or 0
|
||||||
protector.spawn = tonumber(minetest.setting_get("protector_spawn")
|
protector.spawn = tonumber(minetest.setting_get("protector_spawn")
|
||||||
@ -307,30 +306,6 @@ function minetest.is_protected(pos, digger)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--[[
|
|
||||||
-- drop tool/item if protection violated
|
|
||||||
if protector.drop == true then
|
|
||||||
|
|
||||||
local holding = player:get_wielded_item()
|
|
||||||
|
|
||||||
if holding:to_string() ~= "" then
|
|
||||||
|
|
||||||
-- take stack
|
|
||||||
local sta = holding:take_item(holding:get_count())
|
|
||||||
player:set_wielded_item(holding)
|
|
||||||
|
|
||||||
-- incase of lag, reset stack
|
|
||||||
minetest.after(0.1, function()
|
|
||||||
player:set_wielded_item(holding)
|
|
||||||
|
|
||||||
-- drop stack
|
|
||||||
local obj = minetest.add_item(player:getpos(), sta)
|
|
||||||
if obj then
|
|
||||||
obj:setvelocity({x = 0, y = 5, z = 0})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end]]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
25
pvp.lua
25
pvp.lua
@ -7,13 +7,16 @@ local statspawn = minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 2
|
|||||||
-- is pvp protection enabled
|
-- is pvp protection enabled
|
||||||
protector.pvp = minetest.setting_getbool("protector_pvp")
|
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
|
-- disables PVP in your own protected areas
|
||||||
if minetest.setting_getbool("enable_pvp") and protector.pvp then
|
if minetest.setting_getbool("enable_pvp") and protector.pvp then
|
||||||
|
|
||||||
if minetest.register_on_punchplayer then
|
if minetest.register_on_punchplayer then
|
||||||
|
|
||||||
minetest.register_on_punchplayer(
|
minetest.register_on_punchplayer(function(player, hitter,
|
||||||
function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
|
time_from_last_punch, tool_capabilities, dir, damage)
|
||||||
|
|
||||||
if not player
|
if not player
|
||||||
or not hitter then
|
or not hitter then
|
||||||
@ -36,12 +39,26 @@ if minetest.setting_getbool("enable_pvp") and protector.pvp then
|
|||||||
return true
|
return true
|
||||||
end
|
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
|
if minetest.is_protected(pos, hitter:get_player_name()) then
|
||||||
return true
|
return true
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
print(S("[Protector] pvp_protect not active, update your version of Minetest"))
|
print(S("[Protector] pvp_protect not active, update your version of Minetest"))
|
||||||
|
Loading…
Reference in New Issue
Block a user