Initial commit
This commit is contained in:
@@ -117,7 +117,7 @@ Removing members from local protection can be done by using
|
||||
|
||||
The following lines can be added to your minetest.conf file to configure specific features of the mod:
|
||||
|
||||
protector_radius = 5
|
||||
protector_length = 15
|
||||
- Sets the area around each protection node so that other players cannot dig, place or enter through protected doors or chests.
|
||||
|
||||
protector_pvp = true
|
||||
|
||||
@@ -116,7 +116,7 @@ core.register_abm({
|
||||
|
||||
-- show protection areas of nearby protectors owned by you (thanks agaran)
|
||||
|
||||
local r = protector.radius
|
||||
local r = protector.length
|
||||
|
||||
core.register_chatcommand("protector_show_area", {
|
||||
params = "",
|
||||
@@ -131,7 +131,7 @@ core.register_chatcommand("protector_show_area", {
|
||||
-- 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},
|
||||
{x = pos.x, y = pos.y, z = pos.z},
|
||||
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||
|
||||
local meta, owner
|
||||
@@ -144,7 +144,7 @@ core.register_chatcommand("protector_show_area", {
|
||||
|
||||
if owner == name
|
||||
or core.check_player_privs(name, {protection_bypass = true}) then
|
||||
core.add_entity(pos[n], "protector:display")
|
||||
core.add_entity({x=pos[n].x+r, y=pos[n].y+r, z=pos[n].z+r}, "protector:display")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -193,7 +193,7 @@ core.register_chatcommand("protector_show", {
|
||||
|
||||
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},
|
||||
{x = pos.x, y = pos.y, z = pos.z},
|
||||
{"protector:protect_hidden"})
|
||||
|
||||
local meta, owner
|
||||
@@ -230,7 +230,7 @@ core.register_chatcommand("protector_hide", {
|
||||
|
||||
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},
|
||||
{x = pos.x, y = pos.y, z = pos.z},
|
||||
{"protector:protect", "protector:protect2"})
|
||||
|
||||
local meta, owner
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
-- translation and protector radius
|
||||
-- translation and protector length
|
||||
|
||||
local S = core.get_translator("protector")
|
||||
local radius = protector.radius
|
||||
local length = protector.length
|
||||
|
||||
-- hud settings
|
||||
|
||||
@@ -28,8 +28,8 @@ core.register_globalstep(function(dtime)
|
||||
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},
|
||||
{x = pos.x - length, y = pos.y - length, z = pos.z - length},
|
||||
{x = pos.x, y = pos.y, z = pos.z},
|
||||
{"protector:protect","protector:protect2", "protector:protect_hidden"})
|
||||
|
||||
if #protectors > 0 then
|
||||
|
||||
@@ -28,12 +28,12 @@ local S = core.get_translator("protector")
|
||||
protector = {
|
||||
mod = "redo",
|
||||
max_shares = 12,
|
||||
radius = tonumber(core.settings:get("protector_radius")) or 5
|
||||
length = tonumber(core.settings:get("protector_length")) or 15
|
||||
}
|
||||
|
||||
-- radius limiter (minetest cannot handle node volume of more than 4096000)
|
||||
-- length limiter (minetest cannot handle node volume of more than 4096000)
|
||||
|
||||
if protector.radius > 30 then protector.radius = 30 end
|
||||
if protector.length > 60 then protector.length = 60 end
|
||||
|
||||
-- playerfactions check
|
||||
|
||||
@@ -374,10 +374,11 @@ function protector.can_dig(r, pos, digger, onlyowner, infolevel)
|
||||
return false
|
||||
end
|
||||
|
||||
-- find the protector nodes
|
||||
-- find the protector nodes (protector is at the corner of its zone,
|
||||
-- so a protector at p covers [p, p+length]; search [pos-length, pos] to find it)
|
||||
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},
|
||||
{x = pos.x, y = pos.y, z = pos.z},
|
||||
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||
|
||||
local meta, owner, members
|
||||
@@ -487,7 +488,7 @@ 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
|
||||
if not protector.can_dig(protector.length, pos, digger, false, 1) then
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -505,7 +506,7 @@ local function check_overlap(itemstack, placer, pointed_thing)
|
||||
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
|
||||
if inside_spawn(pos, protector_spawn + protector.length) then
|
||||
|
||||
core.chat_send_player(name,
|
||||
S("Spawn @1 has been protected up to a @2 block radius.",
|
||||
@@ -515,12 +516,25 @@ local function check_overlap(itemstack, placer, pointed_thing)
|
||||
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
|
||||
-- Zone of protector at p = [p, p+length]. New zone at pos = [pos, pos+length].
|
||||
-- They overlap when p is in (pos-length, pos+length).
|
||||
local r_ov = protector.length
|
||||
local ov_nodes = core.find_nodes_in_area(
|
||||
{x = pos.x - r_ov, y = pos.y - r_ov, z = pos.z - r_ov},
|
||||
{x = pos.x + r_ov, y = pos.y + r_ov, z = pos.z + r_ov},
|
||||
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||
|
||||
for _, npos in ipairs(ov_nodes) do
|
||||
|
||||
local ometa = core.get_meta(npos)
|
||||
|
||||
if ometa:get_string("owner") ~= name then
|
||||
|
||||
core.chat_send_player(name, S("Overlaps into above players protected area"))
|
||||
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
return core.item_place(itemstack, placer, pointed_thing)
|
||||
end
|
||||
@@ -586,7 +600,7 @@ local def = {
|
||||
|
||||
if pointed_thing.type ~= "node" then return end
|
||||
|
||||
protector.can_dig(protector.radius, pointed_thing.under,
|
||||
protector.can_dig(protector.length, pointed_thing.under,
|
||||
user:get_player_name(), false, 2)
|
||||
end,
|
||||
|
||||
@@ -607,7 +621,8 @@ local def = {
|
||||
|
||||
if core.is_protected(pos, puncher:get_player_name()) then return end
|
||||
|
||||
core.add_entity(pos, "protector:display")
|
||||
local dr = protector.length / 2
|
||||
core.add_entity({x=pos.x+dr, y=pos.y+dr, z=pos.z+dr}, "protector:display")
|
||||
end,
|
||||
|
||||
can_dig = function(pos, player)
|
||||
@@ -773,7 +788,8 @@ core.register_entity("protector:display", {
|
||||
-- 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
|
||||
local r = protector.length
|
||||
local hl = r / 2 -- half-length: display box centered at zone midpoint
|
||||
|
||||
core.register_node("protector:display_node", {
|
||||
tiles = {"protector_display.png"},
|
||||
@@ -782,12 +798,12 @@ core.register_node("protector:display_node", {
|
||||
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
|
||||
{-(hl+.55), -(hl+.55), -(hl+.55), -(hl+.45), (hl+.55), (hl+.55)}, -- sides
|
||||
{-(hl+.55), -(hl+.55), (hl+.45), (hl+.55), (hl+.55), (hl+.55)},
|
||||
{(hl+.45), -(hl+.55), -(hl+.55), (hl+.55), (hl+.55), (hl+.55)},
|
||||
{-(hl+.55), -(hl+.55), -(hl+.55), (hl+.55), (hl+.55), -(hl+.45)},
|
||||
{-(hl+.55), (hl+.45), -(hl+.55), (hl+.55), (hl+.55), (hl+.55)}, -- top
|
||||
{-(hl+.55), -(hl+.55), -(hl+.55), (hl+.55), -(hl+.45), (hl+.55)}, -- bottom
|
||||
{-.55,-.55,-.55, .55,.55,.55} -- middle (surrounding protector)
|
||||
}
|
||||
},
|
||||
@@ -838,7 +854,7 @@ core.register_chatcommand("protector_add_member", {
|
||||
-- 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},
|
||||
{x = pos.x, y = pos.y, z = pos.z},
|
||||
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||
|
||||
local meta, owner
|
||||
@@ -855,7 +871,7 @@ core.register_chatcommand("protector_add_member", {
|
||||
add_member(meta, to_add[m])
|
||||
end
|
||||
|
||||
core.add_entity(pos[n], "protector:display")
|
||||
core.add_entity({x=pos[n].x+r/2, y=pos[n].y+r/2, z=pos[n].z+r/2}, "protector:display")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -879,7 +895,7 @@ core.register_chatcommand("protector_del_member", {
|
||||
-- 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},
|
||||
{x = pos.x, y = pos.y, z = pos.z},
|
||||
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||
|
||||
local meta, owner
|
||||
@@ -896,7 +912,7 @@ core.register_chatcommand("protector_del_member", {
|
||||
del_member(meta, to_del[m])
|
||||
end
|
||||
|
||||
core.add_entity(pos[n], "protector:display")
|
||||
core.add_entity({x=pos[n].x+r/2, y=pos[n].y+r/2, z=pos[n].z+r/2}, "protector:display")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
# Size of protected area around protection node limiting player interaction
|
||||
protector_radius (Protector Radius [max 30]) int 5
|
||||
# Length of protected cube from the corner of the protection node
|
||||
protector_length (Protector Length [max 60]) int 15
|
||||
|
||||
# Flips player around when accessing protected area to stop lag griefing
|
||||
protector_flip (Protector Flip) bool false
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
local S = core.get_translator("protector")
|
||||
|
||||
-- get protection radius
|
||||
-- get protection length
|
||||
|
||||
local r = protector.radius
|
||||
local r = protector.length
|
||||
|
||||
-- protector placement tool
|
||||
|
||||
@@ -18,7 +18,7 @@ core.register_craftitem("protector:tool", {
|
||||
|
||||
local name = user:get_player_name()
|
||||
|
||||
-- check for protector near player (2 block radius)
|
||||
-- check for protector near player (2 block search)
|
||||
local pos = user:get_pos()
|
||||
local pp = core.find_nodes_in_area(
|
||||
vector.subtract(pos, 2), vector.add(pos, 2),
|
||||
@@ -36,7 +36,7 @@ core.register_craftitem("protector:tool", {
|
||||
-- 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 gap = r + 1
|
||||
local pit = user:get_look_vertical()
|
||||
|
||||
-- set placement coords
|
||||
@@ -54,13 +54,18 @@ core.register_craftitem("protector:tool", {
|
||||
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
|
||||
local ov = 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"})
|
||||
|
||||
for _, npos in ipairs(ov) do
|
||||
if core.get_meta(npos):get_string("owner") ~= name then
|
||||
core.chat_send_player(name,
|
||||
S("Overlaps into above players protected area"))
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- does a protector already exist ?
|
||||
if #core.find_nodes_in_area(pos, pos,
|
||||
@@ -143,7 +148,7 @@ core.register_craftitem("protector:tool", {
|
||||
meta:set_string("members", "")
|
||||
end
|
||||
|
||||
core.add_entity(pos, "protector:display")
|
||||
core.add_entity({x=pos.x+r/2, y=pos.y+r/2, z=pos.z+r/2}, "protector:display")
|
||||
|
||||
core.chat_send_player(name,
|
||||
S("Protector placed at @1", core.pos_to_string(pos)))
|
||||
|
||||
Reference in New Issue
Block a user