remove unecessary globals

This commit is contained in:
TenPlus1 2018-09-27 12:52:52 +01:00
commit a7ee92feff
4 changed files with 40 additions and 35 deletions

24
pvp.lua
View file

@ -5,14 +5,16 @@ local S = protector.intllib
local statspawn = minetest.string_to_pos(minetest.settings:get("static_spawnpoint"))
or {x = 0, y = 2, z = 0}
-- is pvp protection enabled
protector.pvp = minetest.settings:get_bool("protector_pvp")
-- is spawn protected
local protector_spawn = tonumber(minetest.settings:get("protector_spawn")
or minetest.settings:get("protector_pvp_spawn")) or 0
-- is night-only pvp enabled
protector.night_pvp = minetest.settings:get_bool("protector_night_pvp")
local protector_night_pvp = minetest.settings:get_bool("protector_night_pvp")
-- disables PVP in your own protected areas
if minetest.settings:get_bool("enable_pvp") and protector.pvp then
if minetest.settings:get_bool("enable_pvp")
and minetest.settings:get_bool("protector_pvp") then
if minetest.register_on_punchplayer then
@ -31,17 +33,17 @@ if minetest.settings:get_bool("enable_pvp") and protector.pvp then
-- no pvp at spawn area
local pos = player:get_pos()
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
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
-- do we enable pvp at night time only ?
if protector.night_pvp then
if protector_night_pvp then
-- get time of day
local tod = minetest.get_timeofday() or 0