mirror of
https://notabug.org/TenPlus1/protector.git
synced 2024-12-05 03:23:47 +01:00
added playerfactions support, protecor_hud_interval and settings update
This commit is contained in:
parent
39cd62a221
commit
db932e676c
@ -57,6 +57,7 @@ Change log:
|
||||
- 2.7 - Remove protection field entity when protector has been dug
|
||||
- 2.8 - Added 'protector_show_interval' setting to minetest.conf [default is 5], make protection field glow in dark.
|
||||
- 2.9 - Added MineClone2 recipes for protection block but no official support as yet
|
||||
- 3.0 - Added PlayerFactions support, 'protector_hud_interval' setting and listing in advanced settings for mod values.
|
||||
|
||||
Lucky Blocks: 10
|
||||
|
||||
|
@ -2,3 +2,4 @@ default?
|
||||
intllib?
|
||||
lucky_block?
|
||||
mesecons_mvps?
|
||||
playerfactions?
|
||||
|
6
hud.lua
6
hud.lua
@ -3,12 +3,14 @@ local S = protector.intllib
|
||||
local radius = (tonumber(minetest.setting_get("protector_radius")) or 5)
|
||||
local hud = {}
|
||||
local hud_timer = 0
|
||||
local hud_interval = (tonumber(minetest.setting_get("protector_hud_interval")) or 5)
|
||||
|
||||
if hud_interval > 0 then
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
-- every 5 seconds
|
||||
hud_timer = hud_timer + dtime
|
||||
if hud_timer < 5 then
|
||||
if hud_timer < hud_interval then
|
||||
return
|
||||
end
|
||||
hud_timer = 0
|
||||
@ -57,3 +59,5 @@ end)
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
hud[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
end
|
||||
|
29
init.lua
29
init.lua
@ -13,6 +13,8 @@ local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S = dofile(MP .. "/intllib.lua")
|
||||
local F = minetest.formspec_escape
|
||||
|
||||
-- Load support for factions
|
||||
local factions_available = minetest.global_exists("factions")
|
||||
|
||||
protector = {
|
||||
mod = "redo",
|
||||
@ -58,6 +60,15 @@ end
|
||||
-- check for member name
|
||||
local is_member = function (meta, name)
|
||||
|
||||
if factions_available
|
||||
and meta:get_int("faction_members") == 1
|
||||
and factions.get_player_faction(name) ~= nil
|
||||
and factions.get_player_faction(meta:get_string("owner")) ==
|
||||
factions.get_player_faction(name) then
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
for _, n in pairs(get_member_list(meta)) do
|
||||
|
||||
if n == name then
|
||||
@ -129,6 +140,19 @@ local protector_formspec = function(meta)
|
||||
local npp = protector_max_share_count -- max users added to protector list
|
||||
local i = 0
|
||||
|
||||
if factions_available
|
||||
and factions.get_player_faction(meta:get_string("owner")) then
|
||||
|
||||
formspec = formspec .. "checkbox[0,5;faction_members;"
|
||||
.. F(S("Allow faction access"))
|
||||
.. ";" .. (meta:get_int("faction_members") == 1 and
|
||||
"true" or "false") .. "]"
|
||||
|
||||
if npp > 8 then
|
||||
npp = 8
|
||||
end
|
||||
end
|
||||
|
||||
for n = 1, #members do
|
||||
|
||||
if i < npp then
|
||||
@ -613,6 +637,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
|
||||
-- add faction members
|
||||
if factions_available then
|
||||
meta:set_int("faction_members", fields.faction_members == "true" and 1 or 0)
|
||||
end
|
||||
|
||||
-- add member [+]
|
||||
if add_member_input then
|
||||
|
||||
|
26
settingtypes.txt
Normal file
26
settingtypes.txt
Normal file
@ -0,0 +1,26 @@
|
||||
# Size of protected area around protection node limiting player interaction
|
||||
protector_radius (Protector Radius) int 5
|
||||
|
||||
# Flips player around when accessing protected area to stop lag griefing
|
||||
protector_flip (Protector Flip) bool false
|
||||
|
||||
# Hurts player by amount entered when accessing protected area, 0 to disable
|
||||
protector_hurt (Protector Hurt) int 0
|
||||
|
||||
# Sets a protected area around spawn by node radius given
|
||||
protector_spawn (Protector Spawn) int 0
|
||||
|
||||
# Enables PVP inside of protected areas
|
||||
protector_pvp (Protector PVP) bool false
|
||||
|
||||
# When true will allow PVP inside protected spawn area
|
||||
protector_pvp_spawn (Protector PVP Spawn) int 0
|
||||
|
||||
# When true will allow PVP inside all protected areas at night time only
|
||||
protector_night_pvp (Protector Night PVP) bool false
|
||||
|
||||
# Interval in seconds that protection field is shown
|
||||
protector_show_interval (Protector Show Interval) int 5
|
||||
|
||||
# Interval in seconds that HUD ownership text is updated, 0 to disable
|
||||
protector_hud_interval (Protector HUD Interval) int 5
|
Loading…
Reference in New Issue
Block a user