3 Mods hinzugefügt, Fehlende Nahrungspunkteangaben im Inventar ergänzt, falsche Nahrungspunkte berichtigt

This commit is contained in:
N-Nachtigal 2025-05-13 18:57:15 +02:00
parent 763ba03e6c
commit 23dda4593a
151 changed files with 6445 additions and 109 deletions

152
mods/protector/README.md Normal file
View file

@ -0,0 +1,152 @@
Protector Redo mod [protect]
Protector redo for minetest is a mod that protects a players builds by placing
a block that stops other players from digging or placing blocks in that area.
based on glomie's mod, remade by Zeg9 and rewritten by TenPlus1.
https://forum.minetest.net/viewtopic.php?f=11&t=9376
Change log:
- 0.1 - Initial release
- 0.2 - Texture update
- 0.3 - Added Protection Logo to blend in with player builds
- 0.4 - Code tweak for 0.4.10+
- 0.5 - Added protector.radius variable in init.lua (default: 5)
- 0.6 - Added Protected Doors (wood and steel) and Protected Chest
- 0.7 - Protected Chests now have "To Chest" and "To Inventory" buttons to copy
contents across, also chests can be named
- 0.8 - Updated to work with Minetest 0.4.12, simplified textures
- 0.9 - Tweaked code
- 1.0 - Only owner can remove protector
- 1.1 - Set 'protector_pvp = true' in minetest.conf to disable pvp in protected
areas except your own, also setting protector_pvp_spawn higher than 0 will
disable pvp around spawn area with the radius you entered
- 1.2 - Shift and click support added with Minetest 0.4.13 to quickly copy stacks
to and from protected chest
- 1.3 - Moved protector on_place into node itself, protector zone display changed
from 10 to 5 seconds, general code tidy
- 1.4 - Changed protector recipes to give single item instead of 4, added + button
to interface, tweaked and tidied code, added admin command /delprot to remove
protectors in bulk from banned/old players
- 1.5 - Added much requested protected trapdoor
- 1.6 - Added protector_drop (true or false) and protector_hurt (hurt by this num)
variables to minetest.conf settings to stop players breaking protected
areas by dropping tools and hurting player.
- 1.7 - Included an edited version of WTFPL doors mod since protected doors didn't
work with the doors mod in the latest daily build... Now it's fine :)
added support for "protection_bypass" privelage.
- 1.8 - Added 'protector_flip' setting to stop players using lag to grief into
another players house, it flips them around to stop them digging.
- 1.9 - Renamed 'protector_pvp_spawn' setting to 'protector_spawn' which protects
an area around static spawnpoint and disables pvp if active.
(note: previous name can still be used)
- 2.0 - Added protector placement tool (thanks to Shara) so that players can easily
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)
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)
- 2.2 - Updated protector tool so that player only needs to stand nearby (2 block radius)
It can also place vertically (up and down) as well. New protector recipe added.
- 2.3 - Localise many of the protector functions and tidy code.
- 2.4 - Update to newer functions, Minetest 0.4.16 needed to run now.
- 2.5 - Added HUD text to show when player is inside a protected area (updates every 5 seconds)
- 2.6 - Add protection against CSM tampering, updated Intllib support (thanks codexp), tweaked block textures
- 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.
- 3.1 - Ability to hide protection blocks using /protector_hide and /protector_show , italian local added (thanks Hamlet)
- 3.2 - Defaults to Minetest translation if found, otherwise intllib fallback if loaded, locale files updated for both. Added 'protector_msg' setting for player text.
- 3.3 - Added support for playerfactions new api (thanks louisroyer), added limiter to protection radius of 22.
- 3.4 - Player flip and hurt functions moved to minetest.register_protection_violation function (thanks hlqkj), added 'protector_crafts' setting, changed wood doors n chests to immediate_dig for mineclone2 fix. Upped protector radius limit to 30.
- 3.5 - Store settings in global, reduce screenshot, tweak door sounds, use node template, add name check to commands, add commands to add and remove member names, tweak & tidy code.
Lucky Blocks: 10
Usage: (requires server privelage)
list names to remove
/protector_remove
remove specific user names
/protector_remove name1 name2
reset names on remove list
/protector_remove -
Whenever a player is near any protectors with name1 or name2 then it will be
replaced by an air block.
show owner name to replace
/protector_replace
replace owner with new name
/protector_replace owner new_owner
reset names on replace list
/protector_replace -
show protected areas of your nearby protectors (max of 5)
/protector_show_area
A players own protection blocks can be hidden and shown using the following:
/protector_hide
/protector_show
Adding members to local protection can be done by using
/protector_add_member
Removing members from local protection can be done by using
/protector_del_member
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_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
- Sets an area 10 nodes around static spawnpoint that is protected.
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
protector_show_interval
- Number of seconds the protection field is visible, defaults to 5 seconds.
protector_recipe = true
- When true allows players to craft protection blocks
protector_msg = true
- When true shows protection messages in players chat when trying to interact in someone else's area
Protector Tool
Can be crafted with a protector surrounded by steel ingots and is used to place new protectors at a set distance of protector.radius in all directions including up and down simply by looking in a direction.
Use by standing near an existing protector, looking in a direction and using as a tool, hold sneak/shift to place new protector containing member list from inside nearest one.

249
mods/protector/admin.lua Normal file
View file

@ -0,0 +1,249 @@
-- translation and default name vars
local S = core.get_translator("protector")
local removal_names = ""
local replace_names = ""
-- remove protection command
core.register_chatcommand("protector_remove", {
params = S("<names list>"),
description = S("Remove Protectors around players (separate names with spaces)"),
privs = {server = true},
func = function(name, param)
if param == "-" then
core.chat_send_player(name, S("Name List Reset"))
removal_names = "" ; return
end
if param ~= "" then
removal_names = param
end
core.chat_send_player(name,
S("Protector Names to remove: @1", removal_names))
end
})
-- replace protection command
core.register_chatcommand("protector_replace", {
params = S("<owner name> <name to replace with>"),
description = S("Replace Protector Owner with name provided"),
privs = {server = true},
func = function(name, param)
-- reset list to empty
if param == "-" then
core.chat_send_player(name, S("Name List Reset"))
replace_names = "" ; return
end
-- check and set replacement name
if param ~= "" then
local names = param:split(" ") ; if not names[2] then return end
if names[2] ~= string.match(names[2], "[%w_-]+") then
core.chat_send_player(name, S("Invalid player name!")) ; return
end
if names[2]:len() > 25 then
core.chat_send_player(name, S("Player name too long")) ; return
end
replace_names = param
end
-- show name info
if replace_names ~= "" then
local names = replace_names:split(" ")
core.chat_send_player(name, S("Replacing Protector name @1 with @2",
names[1] or "", names[2] or ""))
end
end
})
-- Abm to remove or replace protectors within active player area
core.register_abm({
nodenames = {"protector:protect", "protector:protect2", "protector:protect_hidden"},
interval = 5,
chance = 1,
catch_up = false,
action = function(pos, node)
if removal_names == "" and replace_names == "" then return end
local meta = core.get_meta(pos) ; if not meta then return end
local owner = meta:get_string("owner")
if removal_names ~= "" then
local names = removal_names:split(" ")
for _, n in pairs(names) do
if n == owner then
core.set_node(pos, {name = "air"}) ; return
end
end
end
if replace_names ~= "" then
local names = replace_names:split(" ")
if names[1] and names[2] and owner == names[1] then
meta:set_string("owner", names[2])
meta:set_string("infotext", S("Protection (owned by @1)", names[2]))
end
end
end
})
-- show protection areas of nearby protectors owned by you (thanks agaran)
local r = protector.radius
core.register_chatcommand("protector_show_area", {
params = "",
description = S("Show protected areas of your nearby protectors"),
privs = {},
func = function(name, param)
local player = core.get_player_by_name(name)
local pos = player:get_pos()
-- find the protector nodes
local pos = core.find_nodes_in_area(
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
local meta, owner
-- show a maximum of 5 protected areas only
for n = 1, math.min(#pos, 5) do
meta = core.get_meta(pos[n])
owner = meta:get_string("owner") or ""
if owner == name
or core.check_player_privs(name, {protection_bypass = true}) then
core.add_entity(pos[n], "protector:display")
end
end
end
})
-- ability to hide protection blocks (borrowed from doors mod :)
core.register_node("protector:protect_hidden", {
description = "Hidden Protector",
drawtype = "airlike",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
-- has to be walkable for falling nodes to stop falling
walkable = true,
pointable = false,
diggable = false,
buildable_to = false,
floodable = false,
drop = "",
groups = {not_in_creative_inventory = 1, unbreakable = 1},
is_ground_content = false,
on_blast = function() end,
-- 1px block to stop falling nodes replacing protector
collision_box = {
type = "fixed", fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32}
}
})
-- make own protectors visible in area
core.register_chatcommand("protector_show", {
params = "",
description = S("Show your nearby protection blocks"),
privs = {interact = true},
func = function(name, param)
local player = core.get_player_by_name(name)
if not player then
return false, S("Player not found.")
end
local pos = player:get_pos()
local a = core.find_nodes_in_area(
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
{"protector:protect_hidden"})
local meta, owner
for _, row in pairs(a) do
meta = core.get_meta(row)
owner = meta:get_string("owner") or ""
if owner == name
or core.check_player_privs(name, {protection_bypass = true}) then
core.swap_node(row, {name = "protector:protect"})
end
end
end
})
-- make own protectors invisible in area
core.register_chatcommand("protector_hide", {
params = "",
description = S("Hide your nearby protection blocks"),
privs = {interact = true},
func = function(name, param)
local player = core.get_player_by_name(name)
if not player then
return false, S("Player not found.")
end
local pos = player:get_pos()
local a = core.find_nodes_in_area(
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
{"protector:protect", "protector:protect2"})
local meta, owner
for _, row in pairs(a) do
meta = core.get_meta(row)
owner = meta:get_string("owner") or ""
if owner == name
or core.check_player_privs(name, {protection_bypass = true}) then
core.swap_node(row, {name = "protector:protect_hidden"})
end
end
end
})

253
mods/protector/chest.lua Normal file
View file

@ -0,0 +1,253 @@
-- translation
local S = core.get_translator("protector")
local F = core.formspec_escape
-- MineClone support
local mcl = core.get_modpath("mcl_core")
local mcf = core.get_modpath("mcl_formspec")
-- Are crafts enabled?
local protector_crafts = core.settings:get_bool("protector_crafts") ~= false
-- Protected Chest
local chest_size = mcl and (9 * 3) or (8 * 4)
core.register_node("protector:chest", {
description = S("Protected Chest"),
tiles = {
"default_chest_top.png", "default_chest_top.png",
"default_chest_side.png", "default_chest_side.png",
"default_chest_side.png", "default_chest_front.png^protector_logo.png"
},
paramtype2 = "facedir",
groups = {dig_immediate = 2, unbreakable = 1},
legacy_facedir_simple = true,
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = core.get_meta(pos)
local inv = meta:get_inventory()
meta:set_string("infotext", S("Protected Chest"))
meta:set_string("name", S("Protected Chest"))
inv:set_size("main", chest_size)
end,
can_dig = function(pos,player)
local meta = core.get_meta(pos)
local inv = meta:get_inventory()
if inv:is_empty("main") then
if not core.is_protected(pos, player:get_player_name()) then
return true
end
end
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
core.log("action", player:get_player_name()
.. " moves stuff to protected chest at " .. core.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
core.log("action", player:get_player_name()
.. " takes stuff from protected chest at " .. core.pos_to_string(pos))
end,
on_metadata_inventory_move = function(
pos, from_list, from_index, to_list, to_index, count, player)
core.log("action", player:get_player_name()
.. " moves stuff inside protected chest at " .. core.pos_to_string(pos))
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if core.is_protected(pos, player:get_player_name()) then
return 0
end
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if core.is_protected(pos, player:get_player_name()) then
return 0
end
return stack:get_count()
end,
allow_metadata_inventory_move = function(
pos, from_list, from_index, to_list, to_index, count, player)
if core.is_protected(pos, player:get_player_name()) then
return 0
end
return count
end,
on_rightclick = function(pos, node, clicker)
if core.is_protected(pos, clicker:get_player_name()) then return end
local meta = core.get_meta(pos) ; if not meta then return end
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
local formspec
-- mineclone support
if mcl and mcf then
formspec = "size[9,8.75]"
.. "label[0,0;" .. core.formspec_escape(
core.colorize("#313131", "Protected Chest")) .. "]"
.. "list[nodemeta:" .. spos .. ";main;0,0.5;9,3;]"
.. mcl_formspec.get_itemslot_bg(0,0.5,9,3)
.. "image_button[3.0,3.5;1.05,0.8;protector_up_icon.png;protect_up;]"
.. "image_button[4.0,3.5;1.05,0.8;protector_down_icon.png;protect_down;]"
.. "label[0,4.0;" .. core.formspec_escape(
core.colorize("#313131", "Inventory")) .. "]"
.. "list[current_player;main;0,4.5;9,3;9]"
.. mcl_formspec.get_itemslot_bg(0,4.5,9,3)
.. "list[current_player;main;0,7.74;9,1;]"
.. mcl_formspec.get_itemslot_bg(0,7.74,9,1)
.. "listring[nodemeta:" .. spos .. ";main]"
.. "listring[current_player;main]"
else -- default formspec
formspec = "size[8,9]"
.. "list[nodemeta:".. spos .. ";main;0,0.3;8,4;]"
.. "image_button[-0.01,4.26;1.05,0.8;protector_up_icon.png;protect_up;]"
.. "image_button[0.98,4.26;1.05,0.8;protector_down_icon.png;protect_down;]"
.. "tooltip[protect_up;" .. S("To Chest") .. "]"
.. "tooltip[protect_down;" .. S("To Inventory") .. "]"
.. "field[2.3,4.8;4,0.25;protect_name;;"
.. meta:get_string("name") .. "]"
.. "button[5.99,4.5;2.05,0.25;protect_rename;" .. S("Rename") .. "]"
.. "list[current_player;main;0,5;8,1;]"
.. "list[current_player;main;0,6.08;8,3;8]"
.. "listring[nodemeta:" .. spos .. ";main]"
.. "listring[current_player;main]"
end
core.show_formspec(clicker:get_player_name(),
"protector:chest_" .. core.pos_to_string(pos), formspec)
end,
on_blast = function() end
})
-- Container transfer helper
local function to_from(src, dst)
local stack, item, leftover
local size = dst:get_size("main")
for i = 1, size do
stack = src:get_stack("main", i)
item = stack:get_name()
if item ~= "" and dst:room_for_item("main", item) then
leftover = dst:add_item("main", stack)
if leftover and not leftover:is_empty() then
src:set_stack("main", i, leftover)
else
src:set_stack("main", i, nil)
end
end
end
end
-- Protected Chest formspec buttons
core.register_on_player_receive_fields(function(player, formname, fields)
if string.sub(formname, 0, 16) ~= "protector:chest_" then return end
local pos_s = string.sub(formname, 17)
local pos = core.string_to_pos(pos_s)
if core.is_protected(pos, player:get_player_name()) then return end
local meta = core.get_meta(pos) ; if not meta then return end
local chest_inv = meta:get_inventory() ; if not chest_inv then return end
local player_inv = player:get_inventory()
-- copy contents of player inventory to chest
if fields.protect_up then
to_from(player_inv, chest_inv)
-- copy contents of chest to player inventory
elseif fields.protect_down then
to_from(chest_inv, player_inv)
elseif fields.protect_name or fields.protect_rename then
-- change chest infotext to display name
if fields.protect_name ~= "" then
if fields.protect_name ~= string.match(fields.protect_name, "[%w%s_-]+")
or fields.protect_name:len() > 35 then
return
end
meta:set_string("name", fields.protect_name)
meta:set_string("infotext", fields.protect_name)
else
meta:set_string("name", S("Protected Chest"))
meta:set_string("infotext", S("Protected Chest"))
end
end
end)
-- Protected Chest recipes
if protector_crafts then
if mcl then
core.register_craft({
output = "protector:chest",
recipe = { {"mcl_chests:chest", "mcl_core:gold_ingot"} }
})
else
core.register_craft({
output = "protector:chest",
recipe = {
{"group:wood", "group:wood", "group:wood"},
{"group:wood", "default:copper_ingot", "group:wood"},
{"group:wood", "group:wood", "group:wood"}
}
})
core.register_craft({
output = "protector:chest",
recipe = { {"default:chest", "default:copper_ingot"} }
})
end
end

521
mods/protector/doors.lua Normal file
View file

@ -0,0 +1,521 @@
-- doors code from an old client re-used
local S = core.get_translator("protector")
-- MineClone support
local mcl = core.get_modpath("mcl_core")
-- Are crafts enabled?
local protector_crafts = core.settings:get_bool("protector_crafts") ~= false
-- Registers a door
local function register_door(name, def)
def.groups.not_in_creative_inventory = 1
def.groups.handy = 1
def.groups.prot_door = 1
local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5 + 1.5/16}}
def.node_box_bottom = box
def.node_box_top = box
def.selection_box_bottom = box
def.selection_box_top = box
core.register_craftitem(name, {
description = def.description,
inventory_image = def.inventory_image,
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then return itemstack end
local ptu = pointed_thing.under
local nu = core.get_node(ptu)
if core.registered_nodes[nu.name]
and core.registered_nodes[nu.name].on_rightclick then
return core.registered_nodes[nu.name].on_rightclick(
ptu, nu, placer, itemstack)
end
local pt = pointed_thing.above
local pt2 = {x = pt.x, y = pt.y, z = pt.z}
pt2.y = pt2.y + 1
if not core.registered_nodes[core.get_node(pt).name].buildable_to
or not core.registered_nodes[core.get_node(pt2).name].buildable_to
or not placer or not placer:is_player() then
return itemstack
end
if core.is_protected(pt, placer:get_player_name())
or core.is_protected(pt2, placer:get_player_name()) then
core.record_protection_violation(pt, placer:get_player_name())
return itemstack
end
local p2 = core.dir_to_facedir(placer:get_look_dir())
local pt3 = {x = pt.x, y = pt.y, z = pt.z}
if p2 == 0 then pt3.x = pt3.x - 1
elseif p2 == 1 then pt3.z = pt3.z + 1
elseif p2 == 2 then pt3.x = pt3.x + 1
elseif p2 == 3 then pt3.z = pt3.z - 1
end
if core.get_item_group(core.get_node(pt3).name, "prot_door") == 0 then
core.set_node(pt, {name = name .. "_b_1", param2 = p2})
core.set_node(pt2, {name = name .. "_t_1", param2 = p2})
else
core.set_node(pt, {name = name .. "_b_2", param2 = p2})
core.set_node(pt2, {name = name .. "_t_2", param2 = p2})
core.get_meta(pt):set_int("right", 1)
core.get_meta(pt2):set_int("right", 1)
end
if not core.settings:get_bool("creative_mode") then
itemstack:take_item()
end
core.sound_play(def.sounds.place, {pos = pt2}, true)
return itemstack
end
})
local tt = def.tiles_top
local tb = def.tiles_bottom
local function after_dig_node(pos, name, digger)
local node = core.get_node(pos)
if node.name == name then
core.node_dig(pos, node, digger)
end
end
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y + dir
if core.get_node(pos).name ~= check_name then return end
local p2 = core.get_node(pos).param2
p2 = params[p2 + 1]
core.swap_node(pos, {name = replace_dir, param2 = p2})
pos.y = pos.y - dir
core.swap_node(pos, {name = replace, param2=p2})
core.sound_play(def.open_sound,
{pos = pos, gain = 0.3, max_hear_distance = 10}, true)
end
local function on_rotate(pos, node, dir, user, check_name, mode, new_param2)
if mode ~= screwdriver.ROTATE_FACE then return false end
pos.y = pos.y + dir
if core.get_node(pos).name ~= check_name then return false end
if core.is_protected(pos, user:get_player_name()) then
core.record_protection_violation(pos, user:get_player_name())
return false
end
local node2 = core.get_node(pos)
node2.param2 = (node2.param2 + 1) % 4
core.swap_node(pos, node2)
pos.y = pos.y - dir
node.param2 = (node.param2 + 1) % 4
core.swap_node(pos, node)
return true
end
core.register_node(name .. "_b_1", {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1] .. "^[transformfx"},
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = "clip",
is_ground_content = false,
node_dig_prediction = "",
drop = name,
drawtype = "nodebox",
node_box = {type = "fixed", fixed = def.node_box_bottom},
selection_box = {type = "fixed", fixed = def.selection_box_bottom},
groups = def.groups,
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y + 1
after_dig_node(pos, name.."_t_1", digger)
end,
on_rightclick = function(pos, node, clicker)
if not core.is_protected(pos, clicker:get_player_name()) then
on_rightclick(pos, 1, name .. "_t_1", name .. "_b_2",
name .. "_t_2", {1,2,3,0})
end
end,
on_rotate = function(pos, node, user, mode, new_param2)
return on_rotate(pos, node, 1, user, name .. "_t_1", mode)
end,
sounds = def.sounds,
sunlight_propagates = def.sunlight,
on_blast = function() end
})
core.register_node(name .. "_t_1", {
tiles = {tt[2], tt[2], tt[2], tt[2], tt[1], tt[1] .. "^[transformfx"},
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = "clip",
is_ground_content = false,
node_dig_prediction = "",
drop = "",
drawtype = "nodebox",
node_box = {type = "fixed", fixed = def.node_box_top},
selection_box = {type = "fixed", fixed = def.selection_box_top},
groups = def.groups,
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y - 1
after_dig_node(pos, name .. "_b_1", digger)
end,
on_rightclick = function(pos, node, clicker)
if not core.is_protected(pos, clicker:get_player_name()) then
on_rightclick(pos, -1, name .. "_b_1", name .. "_t_2",
name .. "_b_2", {1,2,3,0})
end
end,
on_rotate = function(pos, node, user, mode, new_param2)
return on_rotate(pos, node, -1, user, name .. "_b_1", mode)
end,
sounds = def.sounds,
sunlight_propagates = def.sunlight,
on_blast = function() end
})
core.register_node(name .. "_b_2", {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1] .. "^[transformfx", tb[1]},
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = "clip",
is_ground_content = false,
node_dig_prediction = "",
drop = name,
drawtype = "nodebox",
node_box = {type = "fixed", fixed = def.node_box_bottom},
selection_box = {type = "fixed", fixed = def.selection_box_bottom},
groups = def.groups,
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y + 1
after_dig_node(pos, name .. "_t_2", digger)
end,
on_rightclick = function(pos, node, clicker)
if not core.is_protected(pos, clicker:get_player_name()) then
on_rightclick(pos, 1, name .. "_t_2", name .. "_b_1",
name .. "_t_1", {3,0,1,2})
end
end,
on_rotate = function(pos, node, user, mode, new_param2)
return on_rotate(pos, node, 1, user, name .. "_t_2", mode)
end,
sounds = def.sounds,
sunlight_propagates = def.sunlight,
on_blast = function() end
})
core.register_node(name .. "_t_2", {
tiles = {tt[2], tt[2], tt[2], tt[2], tt[1] .. "^[transformfx", tt[1]},
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = "clip",
is_ground_content = false,
node_dig_prediction = "",
drop = "",
drawtype = "nodebox",
node_box = {type = "fixed", fixed = def.node_box_top},
selection_box = {type = "fixed", fixed = def.selection_box_top},
groups = def.groups,
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y - 1
after_dig_node(pos, name .. "_b_2", digger)
end,
on_rightclick = function(pos, node, clicker)
if not core.is_protected(pos, clicker:get_player_name()) then
on_rightclick(pos, -1, name .. "_b_2", name .. "_t_1",
name .. "_b_1", {3,0,1,2})
end
end,
on_rotate = function(pos, node, user, mode, new_param2)
return on_rotate(pos, node, -1, user, name .. "_b_2", mode)
end,
sounds = def.sounds,
sunlight_propagates = def.sunlight,
on_blast = function() end
})
end
-- Protected Wooden Door
local name = "protector:door_wood"
register_door(name, {
description = S("Protected Wooden Door"),
inventory_image = "doors_wood.png^protector_logo.png",
groups = {
snappy = 1, choppy = 2, dig_immediate = 2, unbreakable = 1, axey = 1, handy = 1
},
tiles_bottom = {"doors_wood_b.png^protector_logo.png", "doors_brown.png"},
tiles_top = {"doors_wood_a.png", "doors_brown.png"},
sounds = default.node_sound_wood_defaults(),
open_sound = "default_dug_node",
sunlight = false
})
if protector_crafts then
if mcl then
core.register_craft({
output = name,
recipe = { {"mcl_doors:wooden_door", "mcl_core:gold_ingot"} }
})
else
core.register_craft({
output = name,
recipe = {
{"group:wood", "group:wood"},
{"group:wood", "default:copper_ingot"},
{"group:wood", "group:wood"}
}
})
core.register_craft({
output = name,
recipe = { {"doors:door_wood", "default:copper_ingot"} }
})
end
end
-- Protected Steel Door
local name = "protector:door_steel"
register_door(name, {
description = S("Protected Steel Door"),
inventory_image = "doors_steel.png^protector_logo.png",
groups = {
snappy = 1, cracky = 1, handy = 1,
level = (mcl and 0 or 2), pickaxey = 2, unbreakable = 1
},
tiles_bottom = {"doors_steel_b.png^protector_logo.png", "doors_grey.png"},
tiles_top = {"doors_steel_a.png", "doors_grey.png"},
sounds = default.node_sound_metal_defaults(),
open_sound = "default_place_node_metal",
sunlight = false,
})
if protector_crafts then
if mcl then
core.register_craft({
output = name,
recipe = { {"mcl_doors:iron_door", "mcl_core:gold_ingot"} }
})
else
core.register_craft({
output = name,
recipe = {
{"default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:copper_ingot"},
{"default:steel_ingot", "default:steel_ingot"}
}
})
core.register_craft({
output = name,
recipe = { {"doors:door_steel", "default:copper_ingot"} }
})
end
end
----trapdoor----
local function register_trapdoor(name, def)
local name_closed = name
local name_opened = name .. "_open"
def.on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
if core.is_protected(pos, clicker:get_player_name()) then return end
local newname = node.name == name_closed and name_opened or name_closed
core.sound_play(def.open_sound,
{pos = pos, gain = 0.3, max_hear_distance = 10}, true)
core.swap_node(pos,
{name = newname, param1 = node.param1, param2 = node.param2})
end
-- Common trapdoor configuration
def.drawtype = "nodebox"
def.paramtype = "light"
def.paramtype2 = "facedir"
def.use_texture_alpha = "clip"
def.is_ground_content = false
def.node_dig_prediction = ""
local def_opened = table.copy(def)
local def_closed = table.copy(def)
def_closed.node_box = {
type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
}
def_closed.selection_box = {
type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
}
def_closed.tiles = { def.tile_front, def.tile_front, def.tile_side, def.tile_side,
def.tile_side, def.tile_side }
def_opened.node_box = {
type = "fixed", fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}
}
def_opened.selection_box = {
type = "fixed", fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}
}
def_opened.tiles = { def.tile_side, def.tile_side,
def.tile_side .. "^[transform3",
def.tile_side .. "^[transform1",
def.tile_front, def.tile_front }
def_opened.drop = name_closed
def_opened.groups.not_in_creative_inventory = 1
core.register_node(name_opened, def_opened)
core.register_node(name_closed, def_closed)
end
-- Protected Wooden Trapdoor
register_trapdoor("protector:trapdoor", {
description = S("Protected Trapdoor"),
inventory_image = "doors_trapdoor.png^protector_logo.png",
wield_image = "doors_trapdoor.png^protector_logo.png",
tile_front = "doors_trapdoor.png^protector_logo.png",
tile_side = "doors_trapdoor_side.png",
groups = {snappy = 1, choppy = 2, dig_immediate = 2, unbreakable = 1, axey = 1},
_mcl_hardness = 0.8,
_mcl_blast_resistance = 1,
sounds = default.node_sound_wood_defaults(),
open_sound = "default_dug_node"
})
if protector_crafts then
if mcl then
core.register_craft({
output = "protector:trapdoor",
recipe = { {"mcl_doors:trapdoor", "mcl_core:gold_ingot"} }
})
else
core.register_craft({
output = "protector:trapdoor 2",
recipe = {
{"group:wood", "default:copper_ingot", "group:wood"},
{"group:wood", "group:wood", "group:wood"}
}
})
core.register_craft({
output = "protector:trapdoor",
recipe = { {"doors:trapdoor", "default:copper_ingot"} }
})
end
end
-- Protected Steel Trapdoor
register_trapdoor("protector:trapdoor_steel", {
description = S("Protected Steel Trapdoor"),
inventory_image = "doors_trapdoor_steel.png^protector_logo.png",
wield_image = "doors_trapdoor_steel.png^protector_logo.png",
tile_front = "doors_trapdoor_steel.png^protector_logo.png",
tile_side = "doors_trapdoor_steel_side.png",
groups = {
snappy = 1, bendy = 2, cracky = 1, level = (mcl and 0 or 2),
unbreakable = 1, pickaxey = 2, handy = 1
},
_mcl_hardness = 1,
_mcl_blast_resistance = 1,
sounds = default.node_sound_metal_defaults(),
open_sound = "default_place_node_metal"
})
if protector_crafts then
if mcl then
core.register_craft({
output = "protector:trapdoor_steel",
recipe = { {"mcl_doors:iron_trapdoor", "mcl_core:gold_ingot"} }
})
else
core.register_craft({
output = "protector:trapdoor_steel",
recipe = {
{"default:copper_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot"}
}
})
core.register_craft({
output = "protector:trapdoor_steel",
recipe = { {"doors:trapdoor_steel", "default:copper_ingot"} }
})
end
end

82
mods/protector/hud.lua Normal file
View file

@ -0,0 +1,82 @@
-- translation and protector radius
local S = core.get_translator("protector")
local radius = protector.radius
-- hud settings
local hud = {}
local hud_timer = 0
local hud_interval = (tonumber(core.settings:get("protector_hud_interval")) or 4)
local hud_style = core.has_feature("hud_def_type_field")
if hud_interval > 0 then
core.register_globalstep(function(dtime)
hud_timer = hud_timer + dtime
if hud_timer < hud_interval then return end
hud_timer = 0
for _, player in pairs(core.get_connected_players()) do
local name = player:get_player_name()
local pos = vector.round(player:get_pos())
local hud_text = ""
local protectors = core.find_nodes_in_area(
{x = pos.x - radius , y = pos.y - radius , z = pos.z - radius},
{x = pos.x + radius , y = pos.y + radius , z = pos.z + radius},
{"protector:protect","protector:protect2", "protector:protect_hidden"})
if #protectors > 0 then
local npos = protectors[1]
local meta = core.get_meta(npos)
local nodeowner = meta:get_string("owner")
local members = meta:get_string("members"):split(" ")
hud_text = S("Owner: @1", nodeowner)
if #members > 0 then
hud_text = hud_text .. " [" .. #members .. "]"
end
end
if not hud[name] then
hud[name] = {}
local hud_tab = {
name = "Protector Area",
number = 0xFFFF22,
position = {x = 0, y = 0.95},
offset = {x = 8, y = -8},
text = hud_text,
scale = {x = 200, y = 60},
alignment = {x = 1, y = -1},
}
if hud_style then
hud_tab["type"] = "text"
else
hud_tab["hud_elem_type"] = "text"
end
hud[name].id = player:hud_add(hud_tab)
return
else
player:hud_change(hud[name].id, "text", hud_text)
end
end
end)
core.register_on_leaveplayer(function(player)
hud[player:get_player_name()] = nil
end)
end -- END hud_interval > 0

808
mods/protector/init.lua Normal file
View file

@ -0,0 +1,808 @@
-- default support (for use with MineClone2 and other [games]
if not core.global_exists("default") then
default = {
node_sound_stone_defaults = function(table) return {} end,
node_sound_wood_defaults = function(table) return {} end,
node_sound_metal_defaults = function(table) return {} end,
gui_bg = "", gui_bg_img = "", gui_slots = ""
}
end
if core.get_modpath("mcl_sounds") then
default.node_sound_stone_defaults = mcl_sounds.node_sound_stone_defaults
default.node_sound_wood_defaults = mcl_sounds.node_sound_wood_defaults
default.node_sound_metal_defaults = mcl_sounds.node_sound_metal_defaults
end
-- modpath, formspec helper and translator
local MP = core.get_modpath(core.get_current_modname())
local F = core.formspec_escape
local S = core.get_translator("protector")
-- global table
protector = {
mod = "redo",
max_shares = 12,
radius = tonumber(core.settings:get("protector_radius")) or 5
}
-- radius limiter (minetest cannot handle node volume of more than 4096000)
if protector.radius > 30 then protector.radius = 30 end
-- playerfactions check
local factions_available = core.global_exists("factions")
if factions_available then protector.max_shares = 8 end
-- localize math
local math_floor, math_pi = math.floor, math.pi
-- settings
local protector_flip = core.settings:get_bool("protector_flip") or false
local protector_hurt = tonumber(core.settings:get("protector_hurt")) or 0
local protector_spawn = tonumber(core.settings:get("protector_spawn")
or core.settings:get("protector_pvp_spawn")) or 0
local protector_show = tonumber(core.settings:get("protector_show_interval")) or 5
local protector_recipe = core.settings:get_bool("protector_recipe") ~= false
local protector_msg = core.settings:get_bool("protector_msg") ~= false
-- get static spawn position
local statspawn = core.string_to_pos(core.settings:get("static_spawnpoint"))
or {x = 0, y = 2, z = 0}
-- return list of members as a table
local function get_member_list(meta)
return meta:get_string("members"):split(" ")
end
-- write member list table in protector meta as string
local function set_member_list(meta, list)
meta:set_string("members", table.concat(list, " "))
end
-- check for owner name
local function is_owner(meta, name)
return name == meta:get_string("owner")
end
-- check for member name
local function is_member(meta, name)
if factions_available and meta:get_int("faction_members") == 1 then
if factions.version == nil then
-- backward compatibility
if factions.get_player_faction(name) ~= nil
and factions.get_player_faction(meta:get_string("owner")) ==
factions.get_player_faction(name) then
return true
end
else
-- is member if player and owner share at least one faction
local player_factions = factions.get_player_factions(name)
local owner = meta:get_string("owner")
if player_factions ~= nil and player_factions ~= false then
for _, f in ipairs(player_factions) do
if factions.player_is_in_faction(f, owner) then return true end
end
end
end
end
for _, n in pairs(get_member_list(meta)) do
if n == name then return true end
end
return false
end
-- add player name to table as member
local function add_member(meta, name)
-- Validate player name for MT compliance
if name ~= string.match(name, "[%w_-]+") then return end
-- Constant (20) defined by player.h
if name:len() > 25 then return end
-- does name already exist?
if is_owner(meta, name) or is_member(meta, name) then return end
local list = get_member_list(meta)
if #list >= protector.max_shares then return end
table.insert(list, name)
set_member_list(meta, list)
end
-- remove player name from table
local function del_member(meta, name)
local list = get_member_list(meta)
for i, n in pairs(list) do
if n == name then
table.remove(list, i) ; break
end
end
set_member_list(meta, list)
end
-- protector interface
local function protector_formspec(meta)
local formspec = "size[8,7]"
.. default.gui_bg
.. default.gui_bg_img
.. "label[2.5,0;" .. F(S("-- Protector interface --")) .. "]"
.. "label[0,1;" .. F(S("PUNCH node to show protected area")) .. "]"
.. "label[0,2;" .. F(S("Members:")) .. "]"
.. "button_exit[2.5,6.2;3,0.5;close_me;" .. F(S("Close")) .. "]"
.. "field_close_on_enter[protector_add_member;false]"
local members = get_member_list(meta)
local i = 0
local checkbox_faction = false
-- Display the checkbox only if the owner is member of at least 1 faction
if factions_available then
if factions.version == nil then
-- backward compatibility
if factions.get_player_faction(meta:get_string("owner")) then
checkbox_faction = true
end
else
local player_factions = factions.get_player_factions(meta:get_string("owner"))
if player_factions ~= nil and type(player_factions) == "table"
and #player_factions >= 1 then
checkbox_faction = true
end
end
end
if checkbox_faction then
formspec = formspec .. "checkbox[0,5;faction_members;"
.. F(S("Allow faction access"))
.. ";" .. (meta:get_int("faction_members") == 1 and
"true" or "false") .. "]"
end
for n = 1, #members do
if i < protector.max_shares then
-- show username
formspec = formspec .. "button[" .. (i % 4 * 2)
.. "," .. math_floor(i / 4 + 3)
.. ";1.5,.5;protector_member;" .. F(members[n]) .. "]"
-- username remove button
.. "button[" .. (i % 4 * 2 + 1.25) .. ","
.. math_floor(i / 4 + 3)
.. ";.75,.5;protector_del_member_" .. F(members[n]) .. ";X]"
end
i = i + 1
end
if i < protector.max_shares then
-- user name entry field
formspec = formspec .. "field[" .. (i % 4 * 2 + 1 / 3) .. ","
.. (math_floor(i / 4 + 3) + 1 / 3)
.. ";1.433,.5;protector_add_member;;]"
-- username add button
.."button[" .. (i % 4 * 2 + 1.25) .. ","
.. math_floor(i / 4 + 3) .. ";.75,.5;protector_submit;+]"
end
return formspec
end
-- check if pos is inside a protected spawn area
local function inside_spawn(pos, radius)
if protector_spawn <= 0 then return false end
if pos.x < statspawn.x + radius and pos.x > statspawn.x - radius
and pos.y < statspawn.y + radius and pos.y > statspawn.y - radius
and pos.z < statspawn.z + radius and pos.z > statspawn.z - radius then
return true
end
end
-- show protection message if enabled
local function show_msg(player_name, msg)
-- if messages disabled or no player name provided
if protector_msg == false or not player_name or player_name == "" then return end
core.chat_send_player(player_name, msg)
end
-- Infolevel:
-- 0 for no info
-- 1 for "This area is owned by <owner> !" if you can't dig
-- 2 for "This area is owned by <owner>.
-- 3 for checking protector overlaps
function protector.can_dig(r, pos, digger, onlyowner, infolevel)
if not digger or not pos then return false end
-- protector_bypass privileged users can override protection
if infolevel == 1
and core.check_player_privs(digger, {protection_bypass = true}) then
return true
end
-- infolevel 3 is only used to bypass priv check, change to 1 now
if infolevel == 3 then infolevel = 1 end
-- is spawn area protected ?
if inside_spawn(pos, protector_spawn) then
show_msg(digger, S("Spawn @1 has been protected up to a @2 block radius.",
core.pos_to_string(statspawn), protector_spawn))
return false
end
-- find the protector nodes
local pos = core.find_nodes_in_area(
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
local meta, owner, members
for n = 1, #pos do
meta = core.get_meta(pos[n])
owner = meta:get_string("owner") or ""
members = meta:get_string("members") or ""
-- node change and digger isn't owner
if infolevel == 1 and owner ~= digger then
-- and you aren't on the member list
if onlyowner or not is_member(meta, digger) then
show_msg(digger, S("This area is owned by @1", owner) .. "!")
return false
end
end
-- when using protector as tool, show protector information
if infolevel == 2 then
core.chat_send_player(digger,
S("This area is owned by @1", owner) .. ".")
core.chat_send_player(digger,
S("Protection located at: @1", core.pos_to_string(pos[n])))
if members ~= "" then
core.chat_send_player(digger, S("Members: @1.", members))
end
return false
end
end
-- show when you can build on unprotected area
if infolevel == 2 then
if #pos < 1 then
core.chat_send_player(digger, S("This area is not protected."))
end
core.chat_send_player(digger, S("You can build here."))
end
return true
end
-- add protector hurt and flip to protection violation function
core.register_on_protection_violation(function(pos, name)
local player = core.get_player_by_name(name)
if player and player:is_player() then
-- hurt player if protection violated
if protector_hurt > 0 and player:get_hp() > 0 then
-- This delay fixes item duplication bug (thanks luk3yx)
core.after(0.1, function(player)
player:set_hp(player:get_hp() - protector_hurt)
end, player)
end
-- flip player when protection violated
if protector_flip then
-- yaw + 180°
local yaw = player:get_look_horizontal() + math_pi
if yaw > 2 * math_pi then
yaw = yaw - 2 * math_pi
end
player:set_look_horizontal(yaw)
-- invert pitch
player:set_look_vertical(-player:get_look_vertical())
-- if digging below player, move up to avoid falling through hole
local pla_pos = player:get_pos()
if pos.y < pla_pos.y then
player:set_pos({x = pla_pos.x, y = pla_pos.y + 0.8, z = pla_pos.z})
end
end
end
end)
-- backup old is_protected function
local old_is_protected = core.is_protected
-- check for protected area, return true if protected and digger isn't on list
function core.is_protected(pos, digger)
digger = digger or "" -- nil check
-- is area protected against digger?
if not protector.can_dig(protector.radius, pos, digger, false, 1) then
return true
end
-- otherwise can dig or place
return old_is_protected(pos, digger)
end
-- make sure protection block doesn't overlap another protector's area
local function check_overlap(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then return itemstack end
local pos = pointed_thing.above
local name = placer:get_player_name()
-- make sure protector doesn't overlap onto protected spawn area
if inside_spawn(pos, protector_spawn + protector.radius) then
core.chat_send_player(name,
S("Spawn @1 has been protected up to a @2 block radius.",
core.pos_to_string(statspawn), protector_spawn))
return itemstack
end
-- make sure protector doesn't overlap any other player's area
if not protector.can_dig(protector.radius * 2, pos, name, true, 3) then
core.chat_send_player(name,
S("Overlaps into above players protected area"))
return itemstack
end
return core.item_place(itemstack, placer, pointed_thing)
end
-- remove protector display entities
local function del_display(pos)
local objects = core.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do
if v and v:get_luaentity() and v:get_luaentity().name == "protector:display" then
v:remove()
end
end
end
-- temporary position store
local player_pos = {}
-- stone texture
local stone_tex = "default_stone.png"
if core.get_modpath("nc_terrain") then
stone_tex = "nc_terrain_stone.png"
end
-- protector default
local def = {
description = S("Protection Block") .. " (" .. S("USE for area check") .. ")",
tiles = {
stone_tex .. "^protector_overlay.png",
stone_tex .. "^protector_overlay.png",
stone_tex .. "^protector_overlay.png^protector_logo.png"
},
drawtype = "nodebox",
node_box = {type = "fixed", fixed = {{-0.499 ,-0.499, -0.499, 0.499, 0.499, 0.499}}},
sounds = default.node_sound_stone_defaults(),
groups = {dig_immediate = 2, unbreakable = 1},
is_ground_content = false,
paramtype = "light",
light_source = 4,
walkable = true,
on_place = check_overlap,
after_place_node = function(pos, placer)
local meta = core.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("members", "")
meta:set_string("infotext",
S("Protection (owned by @1)", meta:get_string("owner")))
end,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
protector.can_dig(protector.radius, pointed_thing.under,
user:get_player_name(), false, 2)
end,
on_rightclick = function(pos, node, clicker, itemstack)
local meta = core.get_meta(pos)
local name = clicker:get_player_name()
if meta and protector.can_dig(1, pos, name, true, 1) then
player_pos[name] = pos
core.show_formspec(name, "protector:node", protector_formspec(meta))
end
end,
on_punch = function(pos, node, puncher)
if core.is_protected(pos, puncher:get_player_name()) then return end
core.add_entity(pos, "protector:display")
end,
can_dig = function(pos, player)
return player and protector.can_dig(1, pos, player:get_player_name(), true, 1)
end,
on_blast = function() end,
after_destruct = del_display
}
-- protection node
core.register_node("protector:protect", table.copy(def))
-- default recipe and alternative for MineClone2
if protector_recipe then
local item_gold = "default:gold_ingot"
local item_stone = "default:stone"
if core.get_modpath("mcl_core") then
item_gold = "mcl_core:gold_ingot"
item_stone = "mcl_core:stone"
end
core.register_craft({
output = "protector:protect",
recipe = {
{item_stone, item_stone, item_stone},
{item_stone, item_gold, item_stone},
{item_stone, item_stone, item_stone}
}
})
end
-- protection logo
def.description = S("Protection Logo") .. " (" .. S("USE for area check") .. ")"
def.tiles = {"protector_logo.png"}
def.wield_image = "protector_logo.png"
def.inventory_image = "protector_logo.png"
def.use_texture_alpha = "clip"
def.paramtype2 = "wallmounted"
def.legacy_wallmounted = true
def.sunlight_propagates = true
def.node_box = {
type = "wallmounted",
wall_top = {-0.375, 0.4375, -0.5, 0.375, 0.5, 0.5},
wall_bottom = {-0.375, -0.5, -0.5, 0.375, -0.4375, 0.5},
wall_side = {-0.5, -0.5, -0.375, -0.4375, 0.5, 0.375}
}
def.selection_box = {type = "wallmounted"}
core.register_node("protector:protect2", table.copy(def))
-- recipes to switch between protectors
core.register_craft({
output = "protector:protect", recipe = {{"protector:protect2"}}
})
core.register_craft({
output = "protector:protect2", recipe = {{"protector:protect"}}
})
-- check formspec buttons or when name entered
core.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "protector:node" then return end
local name = player:get_player_name()
local pos = player_pos[name]
if not name or not pos then return end
local add_member_input = fields.protector_add_member
-- reset formspec until close button pressed
if (fields.close_me or fields.quit)
and (not add_member_input or add_member_input == "") then
player_pos[name] = nil
return
end
-- only owner can add names
if not protector.can_dig(1, pos, player:get_player_name(), true, 1) then
return
end
-- are we adding member to a protection node ? (csm protection)
local nod = core.get_node(pos).name
if nod ~= "protector:protect" and nod ~= "protector:protect2" then
player_pos[name] = nil
return
end
local meta = core.get_meta(pos) ; if not meta then return end
-- add faction members
if factions_available and fields.faction_members ~= nil then
meta:set_int("faction_members", fields.faction_members == "true" and 1 or 0)
end
-- add member [+]
if add_member_input then
for _, i in pairs(add_member_input:split(" ")) do
add_member(meta, i)
end
end
-- remove member [x]
for field, value in pairs(fields) do
if string.sub(field, 0,
string.len("protector_del_member_")) == "protector_del_member_" then
del_member(meta, string.sub(field,string.len("protector_del_member_") + 1))
end
end
core.show_formspec(name, formname, protector_formspec(meta))
end)
-- display entity shown when protector node is punched
core.register_entity("protector:display", {
initial_properties = {
physical = false,
collisionbox = {0, 0, 0, 0, 0, 0},
visual = "wielditem",
-- wielditem seems to be scaled to 1.5 times original node size
visual_size = {x = 0.67, y = 0.67},
textures = {"protector:display_node"},
glow = 10
},
timer = 0,
on_step = function(self, dtime)
self.timer = self.timer + dtime
-- remove after set number of seconds
if self.timer > protector_show then self.object:remove() end
end
})
-- Display-zone node, Do NOT place the display as a node,
-- it is made to be used as an entity (see above)
local r = protector.radius
core.register_node("protector:display_node", {
tiles = {"protector_display.png"},
use_texture_alpha = "clip",
walkable = false,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-(r+.55), -(r+.55), -(r+.55), -(r+.45), (r+.55), (r+.55)}, -- sides
{-(r+.55), -(r+.55), (r+.45), (r+.55), (r+.55), (r+.55)},
{(r+.45), -(r+.55), -(r+.55), (r+.55), (r+.55), (r+.55)},
{-(r+.55), -(r+.55), -(r+.55), (r+.55), (r+.55), -(r+.45)},
{-(r+.55), (r+.45), -(r+.55), (r+.55), (r+.55), (r+.55)}, -- top
{-(r+.55), -(r+.55), -(r+.55), (r+.55), -(r+.45), (r+.55)}, -- bottom
{-.55,-.55,-.55, .55,.55,.55} -- middle (surrounding protector)
}
},
selection_box = {type = "regular"},
paramtype = "light",
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "",
on_blast = function() end
})
-- load mod sections
dofile(MP .. "/doors.lua")
dofile(MP .. "/chest.lua")
dofile(MP .. "/pvp.lua")
dofile(MP .. "/admin.lua")
dofile(MP .. "/tool.lua")
dofile(MP .. "/hud.lua")
if core.get_modpath("lucky_block") then
dofile(MP .. "/lucky_block.lua")
end
-- stop mesecon pistons from pushing protectors
if core.get_modpath("mesecons_mvps") then
mesecon.register_mvps_stopper("protector:protect")
mesecon.register_mvps_stopper("protector:protect2")
mesecon.register_mvps_stopper("protector:protect_hidden")
mesecon.register_mvps_stopper("protector:chest")
end
-- player command to add member names to local protection
core.register_chatcommand("protector_add_member", {
params = "",
description = S("Add member names to local protection"),
privs = {interact = true},
func = function(name, param)
if param == "" then return end
local to_add = param:split(" ")
local player = core.get_player_by_name(name)
local pos = player:get_pos()
-- find the protector nodes
local pos = core.find_nodes_in_area(
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
local meta, owner
for n = 1, #pos do
meta = core.get_meta(pos[n])
owner = meta:get_string("owner") or ""
if owner == name
or core.check_player_privs(name, {protection_bypass = true}) then
for m = 1, #to_add do
add_member(meta, to_add[m])
end
core.add_entity(pos[n], "protector:display")
end
end
end
})
-- player command to remove member names from local protection
core.register_chatcommand("protector_del_member", {
params = "",
description = S("Remove member names from local protection"),
privs = {interact = true},
func = function(name, param)
if param == "" then return end
local to_del = param:split(" ")
local player = core.get_player_by_name(name)
local pos = player:get_pos()
-- find the protector nodes
local pos = core.find_nodes_in_area(
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
local meta, owner
for n = 1, #pos do
meta = core.get_meta(pos[n])
owner = meta:get_string("owner") or ""
if owner == name
or core.check_player_privs(name, {protection_bypass = true}) then
for m = 1, #to_del do
del_member(meta, to_del[m])
end
core.add_entity(pos[n], "protector:display")
end
end
end
})
print ("[MOD] Protector Redo loaded")

View file

@ -0,0 +1,33 @@
The MIT License (MIT)
Copyright (c) 2025 TenPlus1
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Original doors mod code (WTFPL license)
Textures by TenPlus1 (CC0) unless mentioned below
Textures from original Minetest doors mod (CC-BY-SA 3.0)
doors_*.png
..default_chest*.png
Textures by Sirrobzeroone (CC0)
protector_tool.png

View file

@ -0,0 +1,57 @@
# textdomain: protector
# author: Xanthin and CodeXP
# last update: 2020/Jul/12
### admin.lua ###
Remove Protectors around players (separate names with spaces)=Entferne Störschützer von bestimmten Namen in der Nähe von Spielern (trenne Namen durch Leerzeichen)
<names list>=<Namensliste der Spieler>
Replace Protector Owner with name provided=Ersetze Besitzer der Störschützer mit neuem Besitzer
<owner name> <name to replace with>=<Name des Besitzers> <Name des neuen Besitzers>
Replacing Protector name '@1' with '@2'=Ersetze Besitzer der Störschützer von '@1' mit '@2'
Show protected areas of your nearby protectors=Zeige geschützte Bereiche der Störschützer in der Nähe
Protector Names to remove: @1=Störschutznamen zum Entfernen: @1
Name List Reset=Namensliste zurückgesetzt
Invalid player name!=
Player name too long=
Player not found.=
### doors_chest.lua ###
Protected Wooden Door=Geschützte Holztür
Protected Steel Door=Geschützte Stahltür
Protected Trapdoor=Geschützte Falltür
Protected Steel Trapdoor=Geschützte Stahlfalltür
Protected Chest=Geschützte Truhe
To Chest=Zur Truhe
To Inventory=Zum Inventar
Protected Chest (@1)=Geschützte Truhe (@1)
### init.lua ###
-- Protector interface --=-- Störschutz-Interface --
PUNCH node to show protected area=SCHLAGE Node, um geschützten Bereich anzuzeigen oder
USE for area check=BENUTZE für Bereichsprüfung
Members:=Mitglieder:
Close=Schließen
Protection located at: @1=Störschutz befindet sich bei: @1
Members: @1.=Mitglieder: @1.
Allow faction access=
This area is not protected.=Dieser Bereich ist nicht geschützt.
You can build here.=Du kannst hier bauen.
Overlaps into above players protected area=Überlappung im geschützen Bereich eines Spielers
Protection Block=Störschutzblock
Protection (owned by @1)=Störschutz (gehört @1)
Protection Logo=Störschutzlogo
[MOD] Protector Redo loaded=[MOD] Protector Redo geladen
Spawn @1 has been protected up to a @2 block radius.=Spawn @1 ist geschützt mit einem Radius von @2 Blöcke.
This area is owned by @1=Dieser Bereich gehört @1
### hud.lua ###
Owner: @1=Besitzer: @1
### tool.lua ###
Protector Placer Tool (stand near protector, face direction and use)=Störschutz Platzier-Werkzeug (stehe neben Störschutz, schaue in die gewünschte Richtung und anwenden)
Protector already in place!=Störschutz is bereits platziert!
No protectors available to place!=Keine Störschützer mehr im Inventar!
"Protector placed at @1"=Störschutz befindet sich bei: @1
Out of bounds!=
Cannot place protector, already protected at @1=
Cannot place protector, container at @1=

View file

@ -0,0 +1,57 @@
# textdomain: protector
# author: universales
# last update: 2020-02-27
### admin.lua ###
Remove Protectors around players (separate names with spaces)=Eliminar protectores alrededor de los jugadores (nombres separados con espacios)
<names list>=<Lista de nombres>
Replace Protector Owner with name provided=Reemplace el propietario del protector con el nombre proporcionado
<owner name> <name to replace with>=<Nombre del propietario> <Nombre del nuevo propietario>
Replacing Protector name '@1' with '@2'=Reemplazando el nombre del protector '@1' a '@2'
Show protected areas of your nearby protectors=Mostrar áreas protegidas de sus protectores cercanos
Protector Names to remove: @1=Nombres de protectores para eliminar: @1
Name List Reset=Restablecer lista de nombres
Invalid player name!=
Player name too long=
Player not found.=
### doors_chest.lua ###
Protected Wooden Door=Puerta de madera protegida
Protected Steel Door=Puerta de hierro protegida
Protected Trapdoor=Trampilla Protegida
Protected Steel Trapdoor=Trampilla de hierro protegida
Protected Chest=Cofre protegido
To Chest=Al cofre
To Inventory=Al inventario
Protected Chest (@1)=Cofre protegido (@1)
### init.lua ###
-- Protector interface --=-- Interfaz del protector --
PUNCH node to show protected area=nodo de perforación para mostrar el área protegida
USE for area check=Usar para chequeo del área
Members:=Miembros:
Close=Cerrar
Protection located at: @1=Protección ubicada en: @1
Members: @1.=Miembros: @1.
Allow faction access=
This area is not protected.=Esta área no está protegida.
You can build here.=Puedes construir aquí.
Overlaps into above players protected area=Se superpone en el área protegida de los jugadores anteriores
Protection Block=Bloque de protección
Protection (owned by @1)=Protegido (Propiedad de @1)
Protection Logo=Logotipo de la protección
[MOD] Protector Redo loaded=[MOD] Protector recargado
Spawn @1 has been protected up to a @2 block radius.=Spawn @1 ha sido protegido hasta un radio de bloque @2.
This area is owned by @1=Esta área es propiedad de @1
### hud.lua ###
Owner: @1=Propietario: @1
### tool.lua ###
Protector Placer Tool (stand near protector, face direction and use)=Herramienta de colocación del protector (pararse cerca del protector, dirección de la cara y uso)
Protector already in place!=¡El protector ya está en este lugar!
No protectors available to place!=¡No hay protectores disponibles para colocar!
Protector placed at @1=Protector colocado en @1
Out of bounds!=
Cannot place protector, already protected at @1=
Cannot place protector, container at @1=

View file

@ -0,0 +1,57 @@
# textdomain: protector
# author: CodeXP and TenPlus1
# last update: 2020/Jul/12
### admin.lua ###
Remove Protectors around players (separate names with spaces)=Retirer les protecteurs près des joueurs avec les noms fournis (noms séparés avec des espaces)
<names list>=<liste de noms>
Replace Protector Owner with name provided=Remplacer le propriétaire du protecteur par le nom fourni
<owner name> <name to replace with>=<nom du propriétaire> <nom à remplacer>
Replacing Protector name '@1' with '@2'=
Show protected areas of your nearby protectors=Affichez les zones protégées de vos protecteurs à proximité
Protector Names to remove: @1=Noms de protecteurs à supprimer: @1
Name List Reset=Liste de noms réinitialiser
Invalid player name!=
Player name too long=
Player not found.=
### doors_chest.lua ###
Protected Wooden Door=Porte en bois protégée
Protected Steel Door=Porte en acier protégée
Protected Trapdoor=Trappe protégé
Protected Steel Trapdoor=Trap en acier protégé
Protected Chest=Coffre protégé
To Chest=Vers le coffre
To Inventory=Vers l'inventaire
Protected Chest (@1)=Coffre protégé (@1)
### init.lua ###
-- Protector interface --=-- Interface Protector --
PUNCH node to show protected area=TAPÉ le bloc pour afficher la zone protégée
USE for area check=UTILISER pour vérifier la zone
Members:=Membres:
Close=Fermer
Protection located at: @1=Protection située à: @1
Members: @1.=Membres: @1.
Allow faction access=
This area is not protected.=msgstr "Cette zone n'est pas protégée.
You can build here.=Vous pouvez construire ici.
Overlaps into above players protected area=Vous chevauché une zone protégé.
Protection Block=Bloc de protection
Protection (owned by @1)=Protection (détenue par @1)
Protection Logo=Logo de protection
[MOD] Protector Redo loaded=[MOD] Protector Redo chargé
Spawn @1 has been protected up to a @2 block radius.=
This area is owned by @1=Cette zone appartient à @1!
### hud.lua ###
Owner: @1=Propriétaire: @1
### tool.lua ###
Protector Placer Tool (stand near protector, face direction and use)=Outil de placement du protecteur (se tenir près du protecteur, direction du visage et utilisation)
Protector already in place!=Protecteur déjà en place!
No protectors available to place!=Aucun protecteur disponible à placer!
Protector placed at @1=Protection située à: @1
Out of bounds!=
Cannot place protector, already protected at @1=
Cannot place protector, container at @1=

View file

@ -0,0 +1,57 @@
# textdomain: protector
# author: Xanthin and CodeXP
# last update: 2018/Jul/10
### admin.lua ###
Remove Protectors around players (separate names with spaces)=Elimina i protettori attorno ai giocatori (separa i nomi con gli spazi)
<names list>=<elenco nomi>
Replace Protector Owner with name provided=Sostituisci il proprietario del protettore col nome fornito
<owner name> <name to replace with>=<nome proprietario> <nome con cui sostituirlo>
Replacing Protector name '@1' with '@2'=Sostituzione del nome del protettore '@1' con '@2'
Show protected areas of your nearby protectors=Mostra le aree protette dei protettori vicino a te
Protector Names to remove: @1=Nomi dei protettori da eliminare: @1
Name List Reset=Azzera l'elenco dei nomi
Invalid player name!=
Player name too long=
Player not found.=
### doors_chest.lua ###
Protected Wooden Door=Porta di legno protetta
Protected Steel Door=Porta d'acciaio protetta
Protected Trapdoor=Botola protetta
Protected Steel Trapdoor=Botola d'acciaio protetta
Protected Chest=Baule protetto
To Chest=Al baule
To Inventory=All'inventario
Protected Chest (@1)=Baule protetto (@1)
### init.lua ###
-- Protector interface --=-- Interfaccia protettore --
PUNCH node to show protected area=COLPISCI il nodo per mostrare l'area protetta
USE for area check=USA per controllare l'area
Members:=Membri:
Close=Chiudi
Protection located at: @1=Protezione collocata a: @1
Members: @1.=Membri: @1.
Allow faction access=
This area is not protected.=Quest'area non è protetta.
You can build here.=Qui puoi costruire.
Overlaps into above players protected area=Si sovrappone ad un'area sovrastante protetta dai giocatori
Protection Block=Blocco di protezione
Protection (owned by @1)=Protezione (di proprietà di @1)
Protection Logo=Logo di protezione
[MOD] Protector Redo loaded=[MOD] Protector Redo caricato
Spawn @1 has been protected up to a @2 block radius.=Lo spawn @1 è stato protetto fino a un raggio di @2 blocchi.
This area is owned by @1=Quest'area è di proprietà di @1
### hud.lua ###
Owner: @1=Proprietario: @1
### tool.lua ###
Protector Placer Tool (stand near protector, face direction and use)=Strumento di posizionamento protettore (stai vicino al protettore, guarda la direzione e usa)
Protector already in place!=Protettore già presente!
No protectors available to place!=Nessun protettore disponibile da posizionare!
Protector placed at @1=Protettore posizionato a @1
Out of bounds!=
Cannot place protector, already protected at @1=
Cannot place protector, container at @1=

View file

@ -0,0 +1,62 @@
# textdomain: protector
# author: SkyBuilder1717
# last update: 2025/Jan/27
### admin.lua ###
Remove Protectors around players (separate names with spaces)=Удалить Защитников вокруг игроков (отделяйте имена с помощью пробела)
<names list>=<игроки>
Replace Protector Owner with name provided=Заменить Владельца Защитника с доставленным именем
<owner name> <name to replace with>=<владелец> <новый владелец>
Replacing Protector name '@1' with '@2'=Замена Имени Защитника '@1' с '@2'
Show protected areas of your nearby protectors=Показать защищённые зоны Защитниками с вами неподалёку
Protector Names to remove: @1=Имена Защитников чтобы удалить: @1
Name List Reset=Сброс Список Имён
Invalid player name!=Неправильное имя игрока!
Player name too long=Имя игрока слишком длинное
Player not found.=Игрок не найден.
### doors_chest.lua ###
Protected Wooden Door=Защищённая Деревянная Дверь
Protected Steel Door=Защищённая Стальная Дверь
Protected Trapdoor=Защищённый Люк
Protected Steel Trapdoor=Защищённый Стальной Люк
Protected Chest=Защищённый Сундук
To Chest=В Сундук
To Inventory=В Инвентарь
Protected Chest (@1)=Защищённый Сундук (@1)
### init.lua ###
-- Protector interface --=-- Интерфейс Защитника --
PUNCH node to show protected area=УДАРЬТЕ по блоку чтобы показать защищённую зону
USE for area check=ИСПОЛЬЗУЙТЕ для проверки зоны
Members:=Участники:
Close=Закрыть
Allow faction access=Разрешить частичный доступ
Protection located at: @1=Защитник расположен на: @1
Members: @1.=Участники: @1.
This area is not protected.=Эта зона не защищена.
You can build here.=Вы можете здесь строить.
Overlaps into above players protected area=Перекрывает защищенную зону вышеперечисленных игроков
Protection Block=Блок Защиты
Protection (owned by @1)=Защита (владелец: @1)
Protection Logo=Логотип Защиты
[MOD] Protector Redo loaded=[MOD] Protector Redo загружен
Spawn @1 has been protected up to a @2 block radius.=Спавн @1 был защищён радиусом в блоках @2.
This area is owned by @1=Эта зона принадлежит @1.
### pvp.lua ###
[Protector] on_punchplayer called with nil objects=on_punchplayer вызван на нулевом объекте
[Protector] pvp_protect not active, update your version of Luanti=[Protector] pvp_protect не активен, обновите версию Luanti
[Protector] pvp_protect is disabled=[Protector] pvp_protect выключен
### hud.lua ###
Owner: @1=Владелец: @1
### tool.lua ###
Protector Placer Tool (stand near protector, face direction and use)=Инструмент Размещения Защитника (встаньте рядом с Защитником, повернитесь к нему и используйте предмет)
Protector already in place!=Защитник уже стоит на этом месте!
No protectors available to place!=Нет доступных Защитников чтобы поставить!
Out of bounds!=За пределами!
Protector placed at @1=Защитник размещён на @1
Cannot place protector, already protected at @1=Нельзя поставить Защитник, другой Защитник уже на @1
Cannot place protector, container at @1=Нельзя поставить Защитник, контейнер на @1

View file

@ -0,0 +1,57 @@
# textdomain: protector
# author: CodeXP and TenPlus1
# last update: 2020/Jul/12
### admin.lua ###
Remove Protectors around players (separate names with spaces)=Ismi verilen oyuncuların yanındaki korumaları kaldır. (İsimleri boşlukla ayır)
<names list>=<isim listesi>
Replace Protector Owner with name provided=Koruyucu Sahibini belirtilen adla değiştirin
<owner name> <name to replace with>=<sahip adı> <değiştirilecek ad>
Replacing Protector name '@1' with '@2'='@1' Koruyucu adını '@2' ile değiştirin
Show protected areas of your nearby protectors=Yakındaki koruyucuların korunan alanlarını göster
Protector Names to remove: @1=Silinecek korumaların isimleri: @1
Name List Reset=İsim listesini sıfırla
Invalid player name!=
Player name too long=
Player not found.=
### doors_chest.lua ###
Protected Wooden Door=Korumalı ahşap kapı
Protected Steel Door=Korumalı çelik kapı
Protected Trapdoor=Korumalı tuzak kapısı
Protected Steel Trapdoor=Korumalı çelik tuzak kapısı
Protected Chest=Korumalı sandık
To Chest=Sandığa
To Inventory=Envantere
Protected Chest (@1)=Korumalı sandık (@1)
### init.lua ###
-- Protector interface --=-- Koruyucu arayüz --
PUNCH node to show protected area=Korunan alanı göstermek için yumruk
USE for area check=Bölge kontrolü için kullan
Members:=Üyeler
Close=Kapat
Protection located at: @1=Korumanın bulunduğu yer @1
Members: @1.=Üyeler @1.
Allow faction access=
This area is not protected.=Bu alan korumalı değildir.
You can build here.=Buraya inşaa edebilirsiniz.
Overlaps into above players protected area=Yukarıdaki oyuncuların koruma alanı ile çakışıyor
Protection Block=Koruma kutusu
Protection (owned by @1)=Koruma (@1 sahibidir)
Protection Logo=Koruma arması
[MOD] Protector Redo loaded=[MOD] Protector Redo yüklendi
Spawn @1 has been protected up to a @2 block radius.=Spawn @1, @2 blok yarıçapa kadar korunur.
This area is owned by @1=Burasının sahibi @1!
### hud.lua ###
Owner: @1=Sahip: @1
### tool.lua ###
Protector Placer Tool (stand near protector, face direction and use)=Koruyucu Yerleştirme Aleti (koruyucunun yanında durun, yüz yönü ve kullanım)
Protector already in place!=Koruyucu zaten yerinde!
No protectors available to place!=Yerleştirilecek koruyucu yok!
Protector placed at @1=Korumanın bulunduğu yer @1
Out of bounds!=
Cannot place protector, already protected at @1=
Cannot place protector, container at @1=

View file

@ -0,0 +1,56 @@
# textdomain: protector
Protector Redo=Захист
Lets players craft special blocks to protect their builds or disable PVP in areas.=Дозволяє гравцям створювати спеціальні блоки для захисту їхніх споруд або вимкнення PVP на певних територіях.
### admin.lua ###
Remove Protectors around players (separate names with spaces)=Видалити захист поряд із гравцями (перечислити імена, розділяючи пробілами)
<names list>=<список імен>
Replace Protector Owner with name provided=Замінити власника захисту новим власником
<owner name> <name to replace with>=<ім'я власника> <ім'я нового власника>
Replacing Protector name '@1' with '@2'=Заміняється власник захисту із '@1' на '@2'
Show protected areas of your nearby protectors=Показати найближчі захищені території
Protector Names to remove: @1=Імена, які будуть видалені: @1
Name List Reset=Очистити список імен
### doors_chest.lua ###
Protected Wooden Door=Захищені дерев'яні двері
Protected Steel Door=Захищені сталеві двері
Protected Trapdoor=Захищений дерев'яний люк
Protected Steel Trapdoor=Захищений сталевий люк
Protected Chest=Захищена скриня
To Chest=В скриню
To Inventory=В інвентар
Protected Chest (@1)=Захищена скриня (@1)
### init.lua ###
-- Protector interface --=-- Налаштування захисту --
PUNCH node to show protected area=ВДАРИТИ блок для підсвітки захищеної території
USE for area check=ЛКМ для перевірки захищеної території
Members:=Учасники:
Close=Закрити
Protection located at: @1=Захист знаходиться на координатах: @1
Members: @1.=Учасники: @1.
This area is not protected.=Територія вільна.
You can build here.=Тут можна будувати.
Overlaps into above players protected area=Блок захисту не може бути встановлений тут, десь поруч є територія іншого гравця
Protection Block=Блок захисту території
Protection (owned by @1)=Захист території гравця @1
Protection Logo=Захисний знак
[MOD] Protector Redo loaded=[МОД] Protector Redo завантажено
Spawn @1 has been protected up to a @2 block radius.=Спавн @1 захищений у радіусі @2 блока.
This area is owned by @1=Ця територія належить гравцю @1
### pvp.lua ###
[Protector] on_punchplayer called with nil objects=[Захист] on_punchplayer викликана із нульовими об'єктами
[Protector] pvp_protect not active, update your version of Minetest=[Захист] pvp_protect неактивний, оновіть версію Luanti
[Protector] pvp_protect is disabled=[Защита] pvp_protect вимкнений
### hud.lua ###
Owner: @1=Територія належить @1
### tool.lua ###
Protector Placer Tool (stand near protector, face direction and use)=Інструмент встановлення захисту (встаньте поруч із захистом, поверніться в потрібному напрямку і використайте)
Protector already in place!=Захист уже встановлено!
No protectors available to place!=У вас немає блоків захисту території в інвентарю!
Protector placed at @1=Захист знаходиться на координатах @1

View file

@ -0,0 +1,59 @@
# textdomain: protector
# author: ?
# last update: 2020/Jul/12
### admin.lua ###
Remove Protectors around players (separate names with spaces)=
<names list>=
Replace Protector Owner with name provided=
<owner name> <name to replace with>=
Replacing Protector name '@1' with '@2'=
Show protected areas of your nearby protectors=
Protector Names to remove: @1=
Name List Reset=
Invalid player name!=
Player name too long=
Player not found.=
### doors_chest.lua ###
Protected Wooden Door=
Protected Steel Door=
Protected Trapdoor=
Protected Steel Trapdoor=
Protected Chest=
To Chest=
To Inventory=
Protected Chest (@1)=
### init.lua ###
-- Protector interface --=
PUNCH node to show protected area=
USE for area check=
Members:=
Close=
Protection located at: @1=
Members: @1.=
Allow faction access=
This area is not protected.=
You can build here.=
Overlaps into above players protected area=
Protection Block=
Protection (owned by @1)=
Protection Logo=
[MOD] Protector Redo loaded=
Spawn @1 has been protected up to a @2 block radius.=
This area is owned by @1=
Add member names to local protection
Remove member names from local protection
### hud.lua ###
Owner: @1=
### tool.lua ###
Protector Placer Tool (stand near protector, face direction and use)=
Protector already in place!=
Out of bounds!=
No protectors available to place!=
Protector placed at @1=
Cannot place protector, already protected at @1=
Cannot place protector, container at @1=

View file

@ -0,0 +1,15 @@
-- add lucky blocks
lucky_block:add_blocks({
{"dro", {"protector:protect"}, 2},
{"dro", {"protector:protect2"}, 2},
{"dro", {"protector:door_wood"}, 2},
{"dro", {"protector:door_steel"}, 2},
{"exp", 5, true},
{"dro", {"protector:trapdoor"}, 2},
{"dro", {"protector:trapdoor_steel"}, 2},
{"dro", {"protector:tool"}, 1},
{"dro", {"protector:chest"}, 1},
{"exp"}
})

7
mods/protector/mod.conf Normal file
View file

@ -0,0 +1,7 @@
name = protector
description = Lets players craft special blocks to protect their builds or disable PVP in areas.
optional_depends = default, lucky_block, mesecons_mvps, playerfactions, mcl_core, mcl_formspec, mcl_sounds
min_minetest_version = 5.0
release = 30961
author = TenPlus1
title = Protector Redo

70
mods/protector/pvp.lua Normal file
View file

@ -0,0 +1,70 @@
-- get static spawn position
local statspawn = core.string_to_pos(core.settings:get("static_spawnpoint"))
or {x = 0, y = 2, z = 0}
-- is spawn protected
local protector_spawn = tonumber(core.settings:get("protector_spawn")
or core.settings:get("protector_pvp_spawn")) or 0
-- is night-only pvp enabled
local protector_night_pvp = core.settings:get_bool("protector_night_pvp")
-- disables PVP in your own protected areas
if core.settings:get_bool("enable_pvp")
and core.settings:get_bool("protector_pvp") then
if core.register_on_punchplayer then
core.register_on_punchplayer(function(player, hitter,
time_from_last_punch, tool_capabilities, dir, damage)
if not player or not hitter then
print("[MOD] Protector - on_punchplayer called with nil objects")
return false
end
if not hitter:is_player() then return false end
-- 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
return true
end
-- do we enable pvp at night time only ?
if protector_night_pvp then
-- get time of day
local tod = core.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 core.is_protected(pos, hitter:get_player_name()) then
return true
end
return false
end)
else
print("[MOD] Protector - pvp_protect not active, update your version of Minetest")
end
else
print("[MOD] Protector - pvp_protect is disabled")
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View file

@ -0,0 +1,35 @@
# Size of protected area around protection node limiting player interaction
protector_radius (Protector Radius [max 30]) 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
# Enables craft recipe for protection block
protector_recipe (Enable Protector recipe) bool true
# Enables craft recipes for protected doors and chest
protector_crafts (Enable Protector door/chest recipes) bool true
# Enables protection messages in player chat
protector_msg (Enable Protector Messages) bool true

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

View file

@ -0,0 +1,34 @@
following Textures created by Fernando Zapata (CC BY-SA 3.0):
doors_wood.png
doors_wood_a.png
doors_wood_b.png
doors_brown.png
following Textures created by BlockMen (WTFPL):
doors_trapdoor.png
following textures created by celeron55 (CC BY-SA 3.0):
doors_trapdoor_side.png
following textures created by PilzAdam (WTFPL):
doors_steel.png
doors_steel_a.png
doors_steel_b.png
doors_grey.png
doors_trapdoor_steel.png
doors_trapdoor_steel_side.png
following textures by Cisoun (WTFPL):
default_chest_front.png
default_chest_side.png
default_chest_top.png
following textures by TenPlus1 (CC BY-SA 3.0):
protector_logo.png
protector_display.png
protector_overlay.png
following textures by Kilbith (CC BY-SA 3.0):
protector_up_icon.png
protector_down_icon.png (both rotated)

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

164
mods/protector/tool.lua Normal file
View file

@ -0,0 +1,164 @@
-- protector placement tool (thanks to Shara for code and idea)
local S = core.get_translator("protector")
-- get protection radius
local r = protector.radius
-- protector placement tool
core.register_craftitem("protector:tool", {
description = S("Protector Placer Tool (stand near protector, face direction and use)"),
inventory_image = "protector_tool.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local name = user:get_player_name()
-- check for protector near player (2 block radius)
local pos = user:get_pos()
local pp = core.find_nodes_in_area(
vector.subtract(pos, 2), vector.add(pos, 2),
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
if #pp == 0 then return end -- none found
pos = pp[1] -- take position of first protector found
-- get members on protector
local meta = core.get_meta(pos)
local members = meta:get_string("members") or ""
-- get direction player is facing
local dir = core.dir_to_facedir( user:get_look_dir() )
local vec = {x = 0, y = 0, z = 0}
local gap = (r * 2) + 1
local pit = user:get_look_vertical()
-- set placement coords
if pit > 1.2 then vec.y = -gap -- up
elseif pit < -1.2 then vec.y = gap -- down
elseif dir == 0 then vec.z = gap -- north
elseif dir == 1 then vec.x = gap -- east
elseif dir == 2 then vec.z = -gap -- south
elseif dir == 3 then vec.x = -gap -- west
end
-- new position
pos.x = pos.x + vec.x
pos.y = pos.y + vec.y
pos.z = pos.z + vec.z
-- does placing a protector overlap existing area
if not protector.can_dig(r * 2, pos, user:get_player_name(), true, 3) then
core.chat_send_player(name,
S("Overlaps into above players protected area"))
return
end
-- does a protector already exist ?
if #core.find_nodes_in_area(vector.subtract(pos, 1), vector.add(pos, 1),
{"protector:protect", "protector:protect2",
"protector:protect_hidden"}) > 0 then
core.chat_send_player(name, S("Protector already in place!"))
return
end
-- do not place protector out of map bounds or replace bedrock
if #core.find_nodes_in_area(pos, pos, {"ignore", "mcl_core:bedrock"}) > 0 then
core.chat_send_player(name, S("Out of bounds!"))
return
end
-- do we have protectors to use ?
local nod
local inv = user:get_inventory()
if not inv:contains_item("main", "protector:protect")
and not inv:contains_item("main", "protector:protect2") then
core.chat_send_player(name,
S("No protectors available to place!"))
return
end
-- take protector (block first then logo)
if inv:contains_item("main", "protector:protect") then
inv:remove_item("main", "protector:protect")
nod = "protector:protect"
elseif inv:contains_item("main", "protector:protect2") then
inv:remove_item("main", "protector:protect2")
nod = "protector:protect2"
end
-- do not replace containers with inventory space
local inv = core.get_inventory({type = "node", pos = pos})
if inv then
core.chat_send_player(name,
S("Cannot place protector, container at @1",
core.pos_to_string(pos)))
return
end
-- protection check for other mods like Areas
if core.is_protected(pos, name) then
core.chat_send_player(name,
S("Cannot place protector, already protected at @1",
core.pos_to_string(pos)))
return
end
-- place protector
core.set_node(pos, {name = nod, param2 = 1})
-- set protector metadata
local meta = core.get_meta(pos)
meta:set_string("owner", name)
meta:set_string("infotext", "Protection (owned by " .. name .. ")")
-- copy members across if holding sneak when using tool
if user:get_player_control().sneak then
meta:set_string("members", members)
else
meta:set_string("members", "")
end
core.chat_send_player(name,
S("Protector placed at @1", core.pos_to_string(pos)))
end
})
-- tool recipe
local df = "default:steel_ingot"
if core.get_modpath("mcl_core") then
df = "mcl_core:iron_ingot"
end
core.register_craft({
output = "protector:tool",
recipe = {
{df, df, df},
{df, "protector:protect", df},
{df, df, df}
}
})