Compare commits
10 Commits
c923871739
...
31f92fba9c
| Author | SHA1 | Date | |
|---|---|---|---|
|
31f92fba9c
|
|||
| cfbf56ef38 | |||
| eea7ffc3e8 | |||
| b4d6296107 | |||
| 56b33bb50f | |||
| 3e141f7080 | |||
| c08b5ff5ef | |||
| 958686fcd0 | |||
| 73bbe5fb95 | |||
| d294ddbda1 |
@@ -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:
|
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.
|
- Sets the area around each protection node so that other players cannot dig, place or enter through protected doors or chests.
|
||||||
|
|
||||||
protector_pvp = true
|
protector_pvp = true
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
-- translation and default name vars
|
-- translation and default name vars
|
||||||
|
|
||||||
local S = minetest.get_translator("protector")
|
local S = core.get_translator("protector")
|
||||||
local removal_names = ""
|
local removal_names = ""
|
||||||
local replace_names = ""
|
local replace_names = ""
|
||||||
|
|
||||||
-- remove protection command
|
-- remove protection command
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_remove", {
|
core.register_chatcommand("protector_remove", {
|
||||||
params = S("<names list>"),
|
params = S("<names list>"),
|
||||||
description = S("Remove Protectors around players (separate names with spaces)"),
|
description = S("Remove Protectors around players (separate names with spaces)"),
|
||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
@@ -16,7 +16,7 @@ minetest.register_chatcommand("protector_remove", {
|
|||||||
|
|
||||||
if param == "-" then
|
if param == "-" then
|
||||||
|
|
||||||
minetest.chat_send_player(name, S("Name List Reset"))
|
core.chat_send_player(name, S("Name List Reset"))
|
||||||
|
|
||||||
removal_names = "" ; return
|
removal_names = "" ; return
|
||||||
end
|
end
|
||||||
@@ -25,14 +25,14 @@ minetest.register_chatcommand("protector_remove", {
|
|||||||
removal_names = param
|
removal_names = param
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
core.chat_send_player(name,
|
||||||
S("Protector Names to remove: @1", removal_names))
|
S("Protector Names to remove: @1", removal_names))
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- replace protection command
|
-- replace protection command
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_replace", {
|
core.register_chatcommand("protector_replace", {
|
||||||
params = S("<owner name> <name to replace with>"),
|
params = S("<owner name> <name to replace with>"),
|
||||||
description = S("Replace Protector Owner with name provided"),
|
description = S("Replace Protector Owner with name provided"),
|
||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
@@ -42,7 +42,7 @@ minetest.register_chatcommand("protector_replace", {
|
|||||||
-- reset list to empty
|
-- reset list to empty
|
||||||
if param == "-" then
|
if param == "-" then
|
||||||
|
|
||||||
minetest.chat_send_player(name, S("Name List Reset"))
|
core.chat_send_player(name, S("Name List Reset"))
|
||||||
|
|
||||||
replace_names = "" ; return
|
replace_names = "" ; return
|
||||||
end
|
end
|
||||||
@@ -53,11 +53,11 @@ minetest.register_chatcommand("protector_replace", {
|
|||||||
local names = param:split(" ") ; if not names[2] then return end
|
local names = param:split(" ") ; if not names[2] then return end
|
||||||
|
|
||||||
if names[2] ~= string.match(names[2], "[%w_-]+") then
|
if names[2] ~= string.match(names[2], "[%w_-]+") then
|
||||||
minetest.chat_send_player(name, S("Invalid player name!")) ; return
|
core.chat_send_player(name, S("Invalid player name!")) ; return
|
||||||
end
|
end
|
||||||
|
|
||||||
if names[2]:len() > 25 then
|
if names[2]:len() > 25 then
|
||||||
minetest.chat_send_player(name, S("Player name too long")) ; return
|
core.chat_send_player(name, S("Player name too long")) ; return
|
||||||
end
|
end
|
||||||
|
|
||||||
replace_names = param
|
replace_names = param
|
||||||
@@ -68,7 +68,7 @@ minetest.register_chatcommand("protector_replace", {
|
|||||||
|
|
||||||
local names = replace_names:split(" ")
|
local names = replace_names:split(" ")
|
||||||
|
|
||||||
minetest.chat_send_player(name, S("Replacing Protector name @1 with @2",
|
core.chat_send_player(name, S("Replacing Protector name @1 with @2",
|
||||||
names[1] or "", names[2] or ""))
|
names[1] or "", names[2] or ""))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -76,7 +76,7 @@ minetest.register_chatcommand("protector_replace", {
|
|||||||
|
|
||||||
-- Abm to remove or replace protectors within active player area
|
-- Abm to remove or replace protectors within active player area
|
||||||
|
|
||||||
minetest.register_abm({
|
core.register_abm({
|
||||||
nodenames = {"protector:protect", "protector:protect2", "protector:protect_hidden"},
|
nodenames = {"protector:protect", "protector:protect2", "protector:protect_hidden"},
|
||||||
interval = 5,
|
interval = 5,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
@@ -86,7 +86,7 @@ minetest.register_abm({
|
|||||||
|
|
||||||
if removal_names == "" and replace_names == "" then return end
|
if removal_names == "" and replace_names == "" then return end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos) ; if not meta then return end
|
local meta = core.get_meta(pos) ; if not meta then return end
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
|
|
||||||
if removal_names ~= "" then
|
if removal_names ~= "" then
|
||||||
@@ -96,7 +96,7 @@ minetest.register_abm({
|
|||||||
for _, n in pairs(names) do
|
for _, n in pairs(names) do
|
||||||
|
|
||||||
if n == owner then
|
if n == owner then
|
||||||
minetest.set_node(pos, {name = "air"}) ; return
|
core.set_node(pos, {name = "air"}) ; return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -116,22 +116,22 @@ minetest.register_abm({
|
|||||||
|
|
||||||
-- show protection areas of nearby protectors owned by you (thanks agaran)
|
-- show protection areas of nearby protectors owned by you (thanks agaran)
|
||||||
|
|
||||||
local r = protector.radius
|
local r = protector.length
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_show_area", {
|
core.register_chatcommand("protector_show_area", {
|
||||||
params = "",
|
params = "",
|
||||||
description = S("Show protected areas of your nearby protectors"),
|
description = S("Show protected areas of your nearby protectors"),
|
||||||
privs = {},
|
privs = {},
|
||||||
|
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
|
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = core.get_player_by_name(name)
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
-- find the protector nodes
|
-- find the protector nodes
|
||||||
local pos = minetest.find_nodes_in_area(
|
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 + 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"})
|
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||||
|
|
||||||
local meta, owner
|
local meta, owner
|
||||||
@@ -139,12 +139,12 @@ minetest.register_chatcommand("protector_show_area", {
|
|||||||
-- show a maximum of 5 protected areas only
|
-- show a maximum of 5 protected areas only
|
||||||
for n = 1, math.min(#pos, 5) do
|
for n = 1, math.min(#pos, 5) do
|
||||||
|
|
||||||
meta = minetest.get_meta(pos[n])
|
meta = core.get_meta(pos[n])
|
||||||
owner = meta:get_string("owner") or ""
|
owner = meta:get_string("owner") or ""
|
||||||
|
|
||||||
if owner == name
|
if owner == name
|
||||||
or minetest.check_player_privs(name, {protection_bypass = true}) then
|
or core.check_player_privs(name, {protection_bypass = true}) then
|
||||||
minetest.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
|
end
|
||||||
end
|
end
|
||||||
@@ -152,7 +152,7 @@ minetest.register_chatcommand("protector_show_area", {
|
|||||||
|
|
||||||
-- ability to hide protection blocks (borrowed from doors mod :)
|
-- ability to hide protection blocks (borrowed from doors mod :)
|
||||||
|
|
||||||
minetest.register_node("protector:protect_hidden", {
|
core.register_node("protector:protect_hidden", {
|
||||||
description = "Hidden Protector",
|
description = "Hidden Protector",
|
||||||
drawtype = "airlike",
|
drawtype = "airlike",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@@ -176,14 +176,14 @@ minetest.register_node("protector:protect_hidden", {
|
|||||||
|
|
||||||
-- make own protectors visible in area
|
-- make own protectors visible in area
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_show", {
|
core.register_chatcommand("protector_show", {
|
||||||
params = "",
|
params = "",
|
||||||
description = S("Show your nearby protection blocks"),
|
description = S("Show your nearby protection blocks"),
|
||||||
privs = {interact = true},
|
privs = {interact = true},
|
||||||
|
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
|
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = core.get_player_by_name(name)
|
||||||
|
|
||||||
if not player then
|
if not player then
|
||||||
return false, S("Player not found.")
|
return false, S("Player not found.")
|
||||||
@@ -191,21 +191,21 @@ minetest.register_chatcommand("protector_show", {
|
|||||||
|
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
local a = minetest.find_nodes_in_area(
|
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 + r, y = pos.y + r, z = pos.z + r},
|
{x = pos.x, y = pos.y, z = pos.z},
|
||||||
{"protector:protect_hidden"})
|
{"protector:protect_hidden"})
|
||||||
|
|
||||||
local meta, owner
|
local meta, owner
|
||||||
|
|
||||||
for _, row in pairs(a) do
|
for _, row in pairs(a) do
|
||||||
|
|
||||||
meta = minetest.get_meta(row)
|
meta = core.get_meta(row)
|
||||||
owner = meta:get_string("owner") or ""
|
owner = meta:get_string("owner") or ""
|
||||||
|
|
||||||
if owner == name
|
if owner == name
|
||||||
or minetest.check_player_privs(name, {protection_bypass = true}) then
|
or core.check_player_privs(name, {protection_bypass = true}) then
|
||||||
minetest.swap_node(row, {name = "protector:protect"})
|
core.swap_node(row, {name = "protector:protect"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -213,14 +213,14 @@ minetest.register_chatcommand("protector_show", {
|
|||||||
|
|
||||||
-- make own protectors invisible in area
|
-- make own protectors invisible in area
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_hide", {
|
core.register_chatcommand("protector_hide", {
|
||||||
params = "",
|
params = "",
|
||||||
description = S("Hide your nearby protection blocks"),
|
description = S("Hide your nearby protection blocks"),
|
||||||
privs = {interact = true},
|
privs = {interact = true},
|
||||||
|
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
|
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = core.get_player_by_name(name)
|
||||||
|
|
||||||
if not player then
|
if not player then
|
||||||
return false, S("Player not found.")
|
return false, S("Player not found.")
|
||||||
@@ -228,21 +228,21 @@ minetest.register_chatcommand("protector_hide", {
|
|||||||
|
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
local a = minetest.find_nodes_in_area(
|
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 + r, y = pos.y + r, z = pos.z + r},
|
{x = pos.x, y = pos.y, z = pos.z},
|
||||||
{"protector:protect", "protector:protect2"})
|
{"protector:protect", "protector:protect2"})
|
||||||
|
|
||||||
local meta, owner
|
local meta, owner
|
||||||
|
|
||||||
for _, row in pairs(a) do
|
for _, row in pairs(a) do
|
||||||
|
|
||||||
meta = minetest.get_meta(row)
|
meta = core.get_meta(row)
|
||||||
owner = meta:get_string("owner") or ""
|
owner = meta:get_string("owner") or ""
|
||||||
|
|
||||||
if owner == name
|
if owner == name
|
||||||
or minetest.check_player_privs(name, {protection_bypass = true}) then
|
or core.check_player_privs(name, {protection_bypass = true}) then
|
||||||
minetest.swap_node(row, {name = "protector:protect_hidden"})
|
core.swap_node(row, {name = "protector:protect_hidden"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
|
|
||||||
-- translation
|
-- translation
|
||||||
|
|
||||||
local S = minetest.get_translator("protector")
|
local S = core.get_translator("protector")
|
||||||
local F = minetest.formspec_escape
|
local F = core.formspec_escape
|
||||||
|
|
||||||
-- MineClone support
|
-- MineClone support
|
||||||
|
|
||||||
local mcl = minetest.get_modpath("mcl_core")
|
local mcl = core.get_modpath("mcl_core")
|
||||||
local mcf = minetest.get_modpath("mcl_formspec")
|
local mcf = core.get_modpath("mcl_formspec")
|
||||||
|
|
||||||
-- Are crafts enabled?
|
-- Are crafts enabled?
|
||||||
|
|
||||||
local protector_crafts = minetest.settings:get_bool("protector_crafts") ~= false
|
local protector_crafts = core.settings:get_bool("protector_crafts") ~= false
|
||||||
|
|
||||||
-- Protected Chest
|
-- Protected Chest
|
||||||
|
|
||||||
local chest_size = mcl and (9 * 3) or (8 * 4)
|
local chest_size = mcl and (9 * 3) or (8 * 4)
|
||||||
|
|
||||||
minetest.register_node("protector:chest", {
|
core.register_node("protector:chest", {
|
||||||
description = S("Protected Chest"),
|
description = S("Protected Chest"),
|
||||||
tiles = {
|
tiles = {
|
||||||
"default_chest_top.png", "default_chest_top.png",
|
"default_chest_top.png", "default_chest_top.png",
|
||||||
@@ -32,7 +32,7 @@ minetest.register_node("protector:chest", {
|
|||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
|
||||||
meta:set_string("infotext", S("Protected Chest"))
|
meta:set_string("infotext", S("Protected Chest"))
|
||||||
@@ -42,12 +42,12 @@ minetest.register_node("protector:chest", {
|
|||||||
|
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
|
||||||
if inv:is_empty("main") then
|
if inv:is_empty("main") then
|
||||||
|
|
||||||
if not minetest.is_protected(pos, player:get_player_name()) then
|
if not core.is_protected(pos, player:get_player_name()) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -55,26 +55,26 @@ minetest.register_node("protector:chest", {
|
|||||||
|
|
||||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
|
||||||
minetest.log("action", player:get_player_name()
|
core.log("action", player:get_player_name()
|
||||||
.. " moves stuff to protected chest at " .. minetest.pos_to_string(pos))
|
.. " moves stuff to protected chest at " .. core.pos_to_string(pos))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
|
||||||
minetest.log("action", player:get_player_name()
|
core.log("action", player:get_player_name()
|
||||||
.. " takes stuff from protected chest at " .. minetest.pos_to_string(pos))
|
.. " takes stuff from protected chest at " .. core.pos_to_string(pos))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_metadata_inventory_move = function(
|
on_metadata_inventory_move = function(
|
||||||
pos, from_list, from_index, to_list, to_index, count, player)
|
pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
|
||||||
minetest.log("action", player:get_player_name()
|
core.log("action", player:get_player_name()
|
||||||
.. " moves stuff inside protected chest at " .. minetest.pos_to_string(pos))
|
.. " moves stuff inside protected chest at " .. core.pos_to_string(pos))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if core.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ minetest.register_node("protector:chest", {
|
|||||||
|
|
||||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if core.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ minetest.register_node("protector:chest", {
|
|||||||
allow_metadata_inventory_move = function(
|
allow_metadata_inventory_move = function(
|
||||||
pos, from_list, from_index, to_list, to_index, count, player)
|
pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if core.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -102,9 +102,9 @@ minetest.register_node("protector:chest", {
|
|||||||
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
|
|
||||||
if minetest.is_protected(pos, clicker:get_player_name()) then return end
|
if core.is_protected(pos, clicker:get_player_name()) then return end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos) ; if not meta then return end
|
local meta = core.get_meta(pos) ; if not meta then return end
|
||||||
|
|
||||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||||
local formspec
|
local formspec
|
||||||
@@ -113,14 +113,14 @@ minetest.register_node("protector:chest", {
|
|||||||
if mcl and mcf then
|
if mcl and mcf then
|
||||||
|
|
||||||
formspec = "size[9,8.75]"
|
formspec = "size[9,8.75]"
|
||||||
.. "label[0,0;" .. minetest.formspec_escape(
|
.. "label[0,0;" .. core.formspec_escape(
|
||||||
minetest.colorize("#313131", "Protected Chest")) .. "]"
|
core.colorize("#313131", "Protected Chest")) .. "]"
|
||||||
.. "list[nodemeta:" .. spos .. ";main;0,0.5;9,3;]"
|
.. "list[nodemeta:" .. spos .. ";main;0,0.5;9,3;]"
|
||||||
.. mcl_formspec.get_itemslot_bg(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[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;]"
|
.. "image_button[4.0,3.5;1.05,0.8;protector_down_icon.png;protect_down;]"
|
||||||
.. "label[0,4.0;" .. minetest.formspec_escape(
|
.. "label[0,4.0;" .. core.formspec_escape(
|
||||||
minetest.colorize("#313131", "Inventory")) .. "]"
|
core.colorize("#313131", "Inventory")) .. "]"
|
||||||
.. "list[current_player;main;0,4.5;9,3;9]"
|
.. "list[current_player;main;0,4.5;9,3;9]"
|
||||||
.. mcl_formspec.get_itemslot_bg(0,4.5,9,3)
|
.. mcl_formspec.get_itemslot_bg(0,4.5,9,3)
|
||||||
.. "list[current_player;main;0,7.74;9,1;]"
|
.. "list[current_player;main;0,7.74;9,1;]"
|
||||||
@@ -148,8 +148,11 @@ minetest.register_node("protector:chest", {
|
|||||||
.. "listring[current_player;main]"
|
.. "listring[current_player;main]"
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.show_formspec(clicker:get_player_name(),
|
core.sound_play("default_chest_open", {
|
||||||
"protector:chest_" .. minetest.pos_to_string(pos), formspec)
|
gain = 0.3, pos = pos, max_hear_distance = 10}, true)
|
||||||
|
|
||||||
|
core.show_formspec(clicker:get_player_name(),
|
||||||
|
"protector:chest_" .. core.pos_to_string(pos), formspec)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_blast = function() end
|
on_blast = function() end
|
||||||
@@ -182,16 +185,16 @@ end
|
|||||||
|
|
||||||
-- Protected Chest formspec buttons
|
-- Protected Chest formspec buttons
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
if string.sub(formname, 0, 16) ~= "protector:chest_" then return end
|
if string.sub(formname, 0, 16) ~= "protector:chest_" then return end
|
||||||
|
|
||||||
local pos_s = string.sub(formname, 17)
|
local pos_s = string.sub(formname, 17)
|
||||||
local pos = minetest.string_to_pos(pos_s)
|
local pos = core.string_to_pos(pos_s)
|
||||||
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then return end
|
if core.is_protected(pos, player:get_player_name()) then return end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos) ; if not meta 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 chest_inv = meta:get_inventory() ; if not chest_inv then return end
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = player:get_inventory()
|
||||||
|
|
||||||
@@ -222,6 +225,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
meta:set_string("infotext", S("Protected Chest"))
|
meta:set_string("infotext", S("Protected Chest"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif fields.quit then
|
||||||
|
|
||||||
|
core.sound_play("default_chest_close", {
|
||||||
|
gain = 0.3, pos = pos, max_hear_distance = 10}, true)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -231,12 +238,12 @@ if protector_crafts then
|
|||||||
|
|
||||||
if mcl then
|
if mcl then
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:chest",
|
output = "protector:chest",
|
||||||
recipe = { {"mcl_chests:chest", "mcl_core:gold_ingot"} }
|
recipe = { {"mcl_chests:chest", "mcl_core:gold_ingot"} }
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:chest",
|
output = "protector:chest",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"group:wood", "group:wood", "group:wood"},
|
{"group:wood", "group:wood", "group:wood"},
|
||||||
@@ -245,7 +252,7 @@ if protector_crafts then
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:chest",
|
output = "protector:chest",
|
||||||
recipe = { {"default:chest", "default:copper_ingot"} }
|
recipe = { {"default:chest", "default:copper_ingot"} }
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
|
|
||||||
-- doors code from an old client re-used
|
-- doors code from an old client re-used
|
||||||
|
|
||||||
local S = minetest.get_translator("protector")
|
local S = core.get_translator("protector")
|
||||||
|
|
||||||
-- MineClone support
|
-- MineClone support
|
||||||
|
|
||||||
local mcl = minetest.get_modpath("mcl_core")
|
local mcl = core.get_modpath("mcl_core")
|
||||||
|
|
||||||
-- Are crafts enabled?
|
-- Are crafts enabled?
|
||||||
|
|
||||||
local protector_crafts = minetest.settings:get_bool("protector_crafts") ~= false
|
local protector_crafts = core.settings:get_bool("protector_crafts") ~= false
|
||||||
|
|
||||||
-- Registers a door
|
-- Registers a door
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ local function register_door(name, def)
|
|||||||
def.selection_box_bottom = box
|
def.selection_box_bottom = box
|
||||||
def.selection_box_top = box
|
def.selection_box_top = box
|
||||||
|
|
||||||
minetest.register_craftitem(name, {
|
core.register_craftitem(name, {
|
||||||
description = def.description,
|
description = def.description,
|
||||||
inventory_image = def.inventory_image,
|
inventory_image = def.inventory_image,
|
||||||
|
|
||||||
@@ -35,11 +35,11 @@ local function register_door(name, def)
|
|||||||
if pointed_thing.type ~= "node" then return itemstack end
|
if pointed_thing.type ~= "node" then return itemstack end
|
||||||
|
|
||||||
local ptu = pointed_thing.under
|
local ptu = pointed_thing.under
|
||||||
local nu = minetest.get_node(ptu)
|
local nu = core.get_node(ptu)
|
||||||
|
|
||||||
if minetest.registered_nodes[nu.name]
|
if core.registered_nodes[nu.name]
|
||||||
and minetest.registered_nodes[nu.name].on_rightclick then
|
and core.registered_nodes[nu.name].on_rightclick then
|
||||||
return minetest.registered_nodes[nu.name].on_rightclick(
|
return core.registered_nodes[nu.name].on_rightclick(
|
||||||
ptu, nu, placer, itemstack)
|
ptu, nu, placer, itemstack)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -48,19 +48,19 @@ local function register_door(name, def)
|
|||||||
|
|
||||||
pt2.y = pt2.y + 1
|
pt2.y = pt2.y + 1
|
||||||
|
|
||||||
if not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to
|
if not core.registered_nodes[core.get_node(pt).name].buildable_to
|
||||||
or not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to
|
or not core.registered_nodes[core.get_node(pt2).name].buildable_to
|
||||||
or not placer or not placer:is_player() then
|
or not placer or not placer:is_player() then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.is_protected(pt, placer:get_player_name())
|
if core.is_protected(pt, placer:get_player_name())
|
||||||
or minetest.is_protected(pt2, placer:get_player_name()) then
|
or core.is_protected(pt2, placer:get_player_name()) then
|
||||||
minetest.record_protection_violation(pt, placer:get_player_name())
|
core.record_protection_violation(pt, placer:get_player_name())
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
|
local p2 = core.dir_to_facedir(placer:get_look_dir())
|
||||||
local pt3 = {x = pt.x, y = pt.y, z = pt.z}
|
local pt3 = {x = pt.x, y = pt.y, z = pt.z}
|
||||||
|
|
||||||
if p2 == 0 then pt3.x = pt3.x - 1
|
if p2 == 0 then pt3.x = pt3.x - 1
|
||||||
@@ -69,22 +69,22 @@ local function register_door(name, def)
|
|||||||
elseif p2 == 3 then pt3.z = pt3.z - 1
|
elseif p2 == 3 then pt3.z = pt3.z - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_item_group(minetest.get_node(pt3).name, "prot_door") == 0 then
|
if core.get_item_group(core.get_node(pt3).name, "prot_door") == 0 then
|
||||||
minetest.set_node(pt, {name = name .. "_b_1", param2 = p2})
|
core.set_node(pt, {name = name .. "_b_1", param2 = p2})
|
||||||
minetest.set_node(pt2, {name = name .. "_t_1", param2 = p2})
|
core.set_node(pt2, {name = name .. "_t_1", param2 = p2})
|
||||||
else
|
else
|
||||||
minetest.set_node(pt, {name = name .. "_b_2", param2 = p2})
|
core.set_node(pt, {name = name .. "_b_2", param2 = p2})
|
||||||
minetest.set_node(pt2, {name = name .. "_t_2", param2 = p2})
|
core.set_node(pt2, {name = name .. "_t_2", param2 = p2})
|
||||||
|
|
||||||
minetest.get_meta(pt):set_int("right", 1)
|
core.get_meta(pt):set_int("right", 1)
|
||||||
minetest.get_meta(pt2):set_int("right", 1)
|
core.get_meta(pt2):set_int("right", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
if not core.settings:get_bool("creative_mode") then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.sound_play(def.sounds.place, {pos = pt2}, true)
|
core.sound_play(def.sounds.place, {pos = pt2}, true)
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
@@ -95,10 +95,10 @@ local function register_door(name, def)
|
|||||||
|
|
||||||
local function after_dig_node(pos, name, digger)
|
local function after_dig_node(pos, name, digger)
|
||||||
|
|
||||||
local node = minetest.get_node(pos)
|
local node = core.get_node(pos)
|
||||||
|
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
minetest.node_dig(pos, node, digger)
|
core.node_dig(pos, node, digger)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -106,19 +106,19 @@ local function register_door(name, def)
|
|||||||
|
|
||||||
pos.y = pos.y + dir
|
pos.y = pos.y + dir
|
||||||
|
|
||||||
if minetest.get_node(pos).name ~= check_name then return end
|
if core.get_node(pos).name ~= check_name then return end
|
||||||
|
|
||||||
local p2 = minetest.get_node(pos).param2
|
local p2 = core.get_node(pos).param2
|
||||||
|
|
||||||
p2 = params[p2 + 1]
|
p2 = params[p2 + 1]
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = replace_dir, param2 = p2})
|
core.swap_node(pos, {name = replace_dir, param2 = p2})
|
||||||
|
|
||||||
pos.y = pos.y - dir
|
pos.y = pos.y - dir
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = replace, param2=p2})
|
core.swap_node(pos, {name = replace, param2=p2})
|
||||||
|
|
||||||
minetest.sound_play(def.open_sound,
|
core.sound_play(def.open_sound,
|
||||||
{pos = pos, gain = 0.3, max_hear_distance = 10}, true)
|
{pos = pos, gain = 0.3, max_hear_distance = 10}, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -128,29 +128,29 @@ local function register_door(name, def)
|
|||||||
|
|
||||||
pos.y = pos.y + dir
|
pos.y = pos.y + dir
|
||||||
|
|
||||||
if minetest.get_node(pos).name ~= check_name then return false end
|
if core.get_node(pos).name ~= check_name then return false end
|
||||||
|
|
||||||
if minetest.is_protected(pos, user:get_player_name()) then
|
if core.is_protected(pos, user:get_player_name()) then
|
||||||
minetest.record_protection_violation(pos, user:get_player_name())
|
core.record_protection_violation(pos, user:get_player_name())
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local node2 = minetest.get_node(pos)
|
local node2 = core.get_node(pos)
|
||||||
|
|
||||||
node2.param2 = (node2.param2 + 1) % 4
|
node2.param2 = (node2.param2 + 1) % 4
|
||||||
|
|
||||||
minetest.swap_node(pos, node2)
|
core.swap_node(pos, node2)
|
||||||
|
|
||||||
pos.y = pos.y - dir
|
pos.y = pos.y - dir
|
||||||
|
|
||||||
node.param2 = (node.param2 + 1) % 4
|
node.param2 = (node.param2 + 1) % 4
|
||||||
|
|
||||||
minetest.swap_node(pos, node)
|
core.swap_node(pos, node)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(name .. "_b_1", {
|
core.register_node(name .. "_b_1", {
|
||||||
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1] .. "^[transformfx"},
|
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1] .. "^[transformfx"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
@@ -172,7 +172,7 @@ local function register_door(name, def)
|
|||||||
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
|
|
||||||
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
if not core.is_protected(pos, clicker:get_player_name()) then
|
||||||
on_rightclick(pos, 1, name .. "_t_1", name .. "_b_2",
|
on_rightclick(pos, 1, name .. "_t_1", name .. "_b_2",
|
||||||
name .. "_t_2", {1,2,3,0})
|
name .. "_t_2", {1,2,3,0})
|
||||||
end
|
end
|
||||||
@@ -187,7 +187,7 @@ local function register_door(name, def)
|
|||||||
on_blast = function() end
|
on_blast = function() end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name .. "_t_1", {
|
core.register_node(name .. "_t_1", {
|
||||||
tiles = {tt[2], tt[2], tt[2], tt[2], tt[1], tt[1] .. "^[transformfx"},
|
tiles = {tt[2], tt[2], tt[2], tt[2], tt[1], tt[1] .. "^[transformfx"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
@@ -208,7 +208,7 @@ local function register_door(name, def)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
if not core.is_protected(pos, clicker:get_player_name()) then
|
||||||
on_rightclick(pos, -1, name .. "_b_1", name .. "_t_2",
|
on_rightclick(pos, -1, name .. "_b_1", name .. "_t_2",
|
||||||
name .. "_b_2", {1,2,3,0})
|
name .. "_b_2", {1,2,3,0})
|
||||||
end
|
end
|
||||||
@@ -223,7 +223,7 @@ local function register_door(name, def)
|
|||||||
on_blast = function() end
|
on_blast = function() end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name .. "_b_2", {
|
core.register_node(name .. "_b_2", {
|
||||||
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1] .. "^[transformfx", tb[1]},
|
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1] .. "^[transformfx", tb[1]},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
@@ -244,7 +244,7 @@ local function register_door(name, def)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
if not core.is_protected(pos, clicker:get_player_name()) then
|
||||||
on_rightclick(pos, 1, name .. "_t_2", name .. "_b_1",
|
on_rightclick(pos, 1, name .. "_t_2", name .. "_b_1",
|
||||||
name .. "_t_1", {3,0,1,2})
|
name .. "_t_1", {3,0,1,2})
|
||||||
end
|
end
|
||||||
@@ -259,7 +259,7 @@ local function register_door(name, def)
|
|||||||
on_blast = function() end
|
on_blast = function() end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name .. "_t_2", {
|
core.register_node(name .. "_t_2", {
|
||||||
tiles = {tt[2], tt[2], tt[2], tt[2], tt[1] .. "^[transformfx", tt[1]},
|
tiles = {tt[2], tt[2], tt[2], tt[2], tt[1] .. "^[transformfx", tt[1]},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
@@ -280,7 +280,7 @@ local function register_door(name, def)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
if not core.is_protected(pos, clicker:get_player_name()) then
|
||||||
on_rightclick(pos, -1, name .. "_b_2", name .. "_t_1",
|
on_rightclick(pos, -1, name .. "_b_2", name .. "_t_1",
|
||||||
name .. "_b_1", {3,0,1,2})
|
name .. "_b_1", {3,0,1,2})
|
||||||
end
|
end
|
||||||
@@ -317,12 +317,12 @@ if protector_crafts then
|
|||||||
|
|
||||||
if mcl then
|
if mcl then
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = { {"mcl_doors:wooden_door", "mcl_core:gold_ingot"} }
|
recipe = { {"mcl_doors:wooden_door", "mcl_core:gold_ingot"} }
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = {
|
recipe = {
|
||||||
{"group:wood", "group:wood"},
|
{"group:wood", "group:wood"},
|
||||||
@@ -331,7 +331,7 @@ if protector_crafts then
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = { {"doors:door_wood", "default:copper_ingot"} }
|
recipe = { {"doors:door_wood", "default:copper_ingot"} }
|
||||||
})
|
})
|
||||||
@@ -360,12 +360,12 @@ if protector_crafts then
|
|||||||
|
|
||||||
if mcl then
|
if mcl then
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = { {"mcl_doors:iron_door", "mcl_core:gold_ingot"} }
|
recipe = { {"mcl_doors:iron_door", "mcl_core:gold_ingot"} }
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:steel_ingot", "default:steel_ingot"},
|
{"default:steel_ingot", "default:steel_ingot"},
|
||||||
@@ -374,7 +374,7 @@ if protector_crafts then
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = { {"doors:door_steel", "default:copper_ingot"} }
|
recipe = { {"doors:door_steel", "default:copper_ingot"} }
|
||||||
})
|
})
|
||||||
@@ -390,14 +390,14 @@ local function register_trapdoor(name, def)
|
|||||||
|
|
||||||
def.on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
def.on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
|
||||||
if minetest.is_protected(pos, clicker:get_player_name()) then return end
|
if core.is_protected(pos, clicker:get_player_name()) then return end
|
||||||
|
|
||||||
local newname = node.name == name_closed and name_opened or name_closed
|
local newname = node.name == name_closed and name_opened or name_closed
|
||||||
|
|
||||||
minetest.sound_play(def.open_sound,
|
core.sound_play(def.open_sound,
|
||||||
{pos = pos, gain = 0.3, max_hear_distance = 10}, true)
|
{pos = pos, gain = 0.3, max_hear_distance = 10}, true)
|
||||||
|
|
||||||
minetest.swap_node(pos,
|
core.swap_node(pos,
|
||||||
{name = newname, param1 = node.param1, param2 = node.param2})
|
{name = newname, param1 = node.param1, param2 = node.param2})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -435,8 +435,8 @@ local function register_trapdoor(name, def)
|
|||||||
def_opened.drop = name_closed
|
def_opened.drop = name_closed
|
||||||
def_opened.groups.not_in_creative_inventory = 1
|
def_opened.groups.not_in_creative_inventory = 1
|
||||||
|
|
||||||
minetest.register_node(name_opened, def_opened)
|
core.register_node(name_opened, def_opened)
|
||||||
minetest.register_node(name_closed, def_closed)
|
core.register_node(name_closed, def_closed)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Protected Wooden Trapdoor
|
-- Protected Wooden Trapdoor
|
||||||
@@ -458,12 +458,12 @@ if protector_crafts then
|
|||||||
|
|
||||||
if mcl then
|
if mcl then
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:trapdoor",
|
output = "protector:trapdoor",
|
||||||
recipe = { {"mcl_doors:trapdoor", "mcl_core:gold_ingot"} }
|
recipe = { {"mcl_doors:trapdoor", "mcl_core:gold_ingot"} }
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:trapdoor 2",
|
output = "protector:trapdoor 2",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"group:wood", "default:copper_ingot", "group:wood"},
|
{"group:wood", "default:copper_ingot", "group:wood"},
|
||||||
@@ -471,7 +471,7 @@ if protector_crafts then
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:trapdoor",
|
output = "protector:trapdoor",
|
||||||
recipe = { {"doors:trapdoor", "default:copper_ingot"} }
|
recipe = { {"doors:trapdoor", "default:copper_ingot"} }
|
||||||
})
|
})
|
||||||
@@ -500,12 +500,12 @@ if protector_crafts then
|
|||||||
|
|
||||||
if mcl then
|
if mcl then
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:trapdoor_steel",
|
output = "protector:trapdoor_steel",
|
||||||
recipe = { {"mcl_doors:iron_trapdoor", "mcl_core:gold_ingot"} }
|
recipe = { {"mcl_doors:iron_trapdoor", "mcl_core:gold_ingot"} }
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:trapdoor_steel",
|
output = "protector:trapdoor_steel",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:copper_ingot", "default:steel_ingot"},
|
{"default:copper_ingot", "default:steel_ingot"},
|
||||||
@@ -513,7 +513,7 @@ if protector_crafts then
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:trapdoor_steel",
|
output = "protector:trapdoor_steel",
|
||||||
recipe = { {"doors:trapdoor_steel", "default:copper_ingot"} }
|
recipe = { {"doors:trapdoor_steel", "default:copper_ingot"} }
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
|
|
||||||
-- translation and protector radius
|
-- translation and protector length
|
||||||
|
|
||||||
local S = minetest.get_translator("protector")
|
local S = core.get_translator("protector")
|
||||||
local radius = protector.radius
|
local length = protector.length
|
||||||
|
|
||||||
-- hud settings
|
-- hud settings
|
||||||
|
|
||||||
local hud = {}
|
local hud = {}
|
||||||
local hud_timer = 0
|
local hud_timer = 0
|
||||||
local hud_interval = (tonumber(minetest.settings:get("protector_hud_interval")) or 4)
|
local hud_interval = (tonumber(core.settings:get("protector_hud_interval")) or 4)
|
||||||
local hud_style = minetest.has_feature("hud_def_type_field")
|
local hud_style = core.has_feature("hud_def_type_field")
|
||||||
|
|
||||||
if hud_interval > 0 then
|
if hud_interval > 0 then
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
core.register_globalstep(function(dtime)
|
||||||
|
|
||||||
hud_timer = hud_timer + dtime
|
hud_timer = hud_timer + dtime
|
||||||
|
|
||||||
@@ -21,21 +21,21 @@ minetest.register_globalstep(function(dtime)
|
|||||||
|
|
||||||
hud_timer = 0
|
hud_timer = 0
|
||||||
|
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(core.get_connected_players()) do
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local pos = vector.round(player:get_pos())
|
local pos = vector.round(player:get_pos())
|
||||||
local hud_text = ""
|
local hud_text = ""
|
||||||
|
|
||||||
local protectors = minetest.find_nodes_in_area(
|
local protectors = core.find_nodes_in_area(
|
||||||
{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 + radius , y = pos.y + radius , z = pos.z + radius},
|
{x = pos.x, y = pos.y, z = pos.z},
|
||||||
{"protector:protect","protector:protect2", "protector:protect_hidden"})
|
{"protector:protect","protector:protect2", "protector:protect_hidden"})
|
||||||
|
|
||||||
if #protectors > 0 then
|
if #protectors > 0 then
|
||||||
|
|
||||||
local npos = protectors[1]
|
local npos = protectors[1]
|
||||||
local meta = minetest.get_meta(npos)
|
local meta = core.get_meta(npos)
|
||||||
local nodeowner = meta:get_string("owner")
|
local nodeowner = meta:get_string("owner")
|
||||||
local members = meta:get_string("members"):split(" ")
|
local members = meta:get_string("members"):split(" ")
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
core.register_on_leaveplayer(function(player)
|
||||||
hud[player:get_player_name()] = nil
|
hud[player:get_player_name()] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
-- default support (for use with MineClone2 and other [games]
|
-- default support (for use with MineClone2 and other [games]
|
||||||
|
|
||||||
if not minetest.global_exists("default") then
|
if not core.global_exists("default") then
|
||||||
|
|
||||||
default = {
|
default = {
|
||||||
node_sound_stone_defaults = function(table) return {} end,
|
node_sound_stone_defaults = function(table) return {} end,
|
||||||
@@ -11,7 +11,7 @@ if not minetest.global_exists("default") then
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("mcl_sounds") then
|
if core.get_modpath("mcl_sounds") then
|
||||||
default.node_sound_stone_defaults = mcl_sounds.node_sound_stone_defaults
|
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_wood_defaults = mcl_sounds.node_sound_wood_defaults
|
||||||
default.node_sound_metal_defaults = mcl_sounds.node_sound_metal_defaults
|
default.node_sound_metal_defaults = mcl_sounds.node_sound_metal_defaults
|
||||||
@@ -19,25 +19,25 @@ end
|
|||||||
|
|
||||||
-- modpath, formspec helper and translator
|
-- modpath, formspec helper and translator
|
||||||
|
|
||||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
local MP = core.get_modpath(core.get_current_modname())
|
||||||
local F = minetest.formspec_escape
|
local F = core.formspec_escape
|
||||||
local S = minetest.get_translator("protector")
|
local S = core.get_translator("protector")
|
||||||
|
|
||||||
-- global table
|
-- global table
|
||||||
|
|
||||||
protector = {
|
protector = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
max_shares = 12,
|
max_shares = 12,
|
||||||
radius = tonumber(minetest.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
|
-- playerfactions check
|
||||||
|
|
||||||
local factions_available = minetest.global_exists("factions")
|
local factions_available = core.global_exists("factions")
|
||||||
|
|
||||||
if factions_available then protector.max_shares = 8 end
|
if factions_available then protector.max_shares = 8 end
|
||||||
|
|
||||||
@@ -47,17 +47,17 @@ local math_floor, math_pi = math.floor, math.pi
|
|||||||
|
|
||||||
-- settings
|
-- settings
|
||||||
|
|
||||||
local protector_flip = minetest.settings:get_bool("protector_flip") or false
|
local protector_flip = core.settings:get_bool("protector_flip") or false
|
||||||
local protector_hurt = tonumber(minetest.settings:get("protector_hurt")) or 0
|
local protector_hurt = tonumber(core.settings:get("protector_hurt")) or 0
|
||||||
local protector_spawn = tonumber(minetest.settings:get("protector_spawn")
|
local protector_spawn = tonumber(core.settings:get("protector_spawn")
|
||||||
or minetest.settings:get("protector_pvp_spawn")) or 0
|
or core.settings:get("protector_pvp_spawn")) or 0
|
||||||
local protector_show = tonumber(minetest.settings:get("protector_show_interval")) or 5
|
local protector_show = tonumber(core.settings:get("protector_show_interval")) or 5
|
||||||
local protector_recipe = minetest.settings:get_bool("protector_recipe") ~= false
|
local protector_recipe = core.settings:get_bool("protector_recipe") ~= false
|
||||||
local protector_msg = minetest.settings:get_bool("protector_msg") ~= false
|
local protector_msg = core.settings:get_bool("protector_msg") ~= false
|
||||||
|
|
||||||
-- get static spawn position
|
-- get static spawn position
|
||||||
|
|
||||||
local statspawn = minetest.string_to_pos(minetest.settings:get("static_spawnpoint"))
|
local statspawn = core.string_to_pos(core.settings:get("static_spawnpoint"))
|
||||||
or {x = 0, y = 2, z = 0}
|
or {x = 0, y = 2, z = 0}
|
||||||
|
|
||||||
-- return list of members as a table
|
-- return list of members as a table
|
||||||
@@ -67,6 +67,13 @@ local function get_member_list(meta)
|
|||||||
return meta:get_string("members"):split(" ")
|
return meta:get_string("members"):split(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- return list of factions as a table
|
||||||
|
|
||||||
|
local function get_faction_list(meta)
|
||||||
|
|
||||||
|
return meta:get_string("factions"):split(" ")
|
||||||
|
end
|
||||||
|
|
||||||
-- write member list table in protector meta as string
|
-- write member list table in protector meta as string
|
||||||
|
|
||||||
local function set_member_list(meta, list)
|
local function set_member_list(meta, list)
|
||||||
@@ -74,6 +81,13 @@ local function set_member_list(meta, list)
|
|||||||
meta:set_string("members", table.concat(list, " "))
|
meta:set_string("members", table.concat(list, " "))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- write faction list table in protector meta as string
|
||||||
|
|
||||||
|
local function set_faction_list(meta, list)
|
||||||
|
|
||||||
|
meta:set_string("factions", table.concat(list, " "))
|
||||||
|
end
|
||||||
|
|
||||||
-- check for owner name
|
-- check for owner name
|
||||||
|
|
||||||
local function is_owner(meta, name)
|
local function is_owner(meta, name)
|
||||||
@@ -81,21 +95,73 @@ local function is_owner(meta, name)
|
|||||||
return name == meta:get_string("owner")
|
return name == meta:get_string("owner")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- add faction name to table as member
|
||||||
|
|
||||||
|
local function add_faction(meta, name)
|
||||||
|
|
||||||
|
if name ~= string.match(name, "[%w_-]+") and name ~= "*" then return end
|
||||||
|
|
||||||
|
if name:len() > 25 then return end
|
||||||
|
|
||||||
|
local list = get_faction_list(meta)
|
||||||
|
|
||||||
|
if #list >= 4 then return end
|
||||||
|
|
||||||
|
table.insert(list, name)
|
||||||
|
|
||||||
|
set_faction_list(meta, list)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- convert old faction tick-box to "*" for all owner factions
|
||||||
|
|
||||||
|
core.register_lbm({
|
||||||
|
label = "Protector update",
|
||||||
|
name = "protector:protector_update",
|
||||||
|
nodenames = {"protector:protect", "protector:protect2", "protector:protect_hidden"},
|
||||||
|
run_at_every_load = false,
|
||||||
|
action = function(pos, node, dtime_s)
|
||||||
|
|
||||||
|
local meta = core.get_meta(pos)
|
||||||
|
|
||||||
|
if meta:get_int("faction_members") == 1 then
|
||||||
|
|
||||||
|
meta:set_string("factions", "*")
|
||||||
|
meta:set_int("faction_members", 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
-- check for member name
|
-- check for member name
|
||||||
|
|
||||||
local function is_member(meta, name)
|
local function is_member(meta, name)
|
||||||
|
|
||||||
if factions_available and meta:get_int("faction_members") == 1 then
|
for _, n in pairs(get_member_list(meta)) do
|
||||||
|
|
||||||
|
if n == name then return true end
|
||||||
|
end
|
||||||
|
|
||||||
|
if factions_available then
|
||||||
|
|
||||||
if factions.version == nil then
|
if factions.version == nil then
|
||||||
|
|
||||||
-- backward compatibility
|
-- backward compatibility
|
||||||
if factions.get_player_faction(name) ~= nil
|
local player_faction = factions.get_player_faction(name)
|
||||||
and factions.get_player_faction(meta:get_string("owner")) ==
|
|
||||||
factions.get_player_faction(name) then
|
if player_faction ~= nil then
|
||||||
return true
|
|
||||||
|
for _, faction in pairs(get_faction_list(meta)) do
|
||||||
|
|
||||||
|
if (faction == "*"
|
||||||
|
and factions.get_player_faction(
|
||||||
|
meta:get_string("owner")) == player_faction)
|
||||||
|
or faction == player_faction then return true end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
for _, faction in pairs(get_faction_list(meta)) do
|
||||||
|
|
||||||
|
if faction == "*" then
|
||||||
|
|
||||||
-- is member if player and owner share at least one faction
|
-- is member if player and owner share at least one faction
|
||||||
local player_factions = factions.get_player_factions(name)
|
local player_factions = factions.get_player_factions(name)
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
@@ -104,15 +170,17 @@ local function is_member(meta, name)
|
|||||||
|
|
||||||
for _, f in ipairs(player_factions) do
|
for _, f in ipairs(player_factions) do
|
||||||
|
|
||||||
if factions.player_is_in_faction(f, owner) then return true end
|
if factions.player_is_in_faction(f, owner) then
|
||||||
end
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, n in pairs(get_member_list(meta)) do
|
elseif factions.player_is_in_faction(faction, name) then
|
||||||
|
return true
|
||||||
if n == name then return true end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -128,9 +196,6 @@ local function add_member(meta, name)
|
|||||||
-- Constant (20) defined by player.h
|
-- Constant (20) defined by player.h
|
||||||
if name:len() > 25 then return end
|
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)
|
local list = get_member_list(meta)
|
||||||
|
|
||||||
if #list >= protector.max_shares then return end
|
if #list >= protector.max_shares then return end
|
||||||
@@ -156,6 +221,22 @@ local function del_member(meta, name)
|
|||||||
set_member_list(meta, list)
|
set_member_list(meta, list)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- remove faction name from table
|
||||||
|
|
||||||
|
local function del_faction(meta, name)
|
||||||
|
|
||||||
|
local list = get_faction_list(meta)
|
||||||
|
|
||||||
|
for i, n in pairs(list) do
|
||||||
|
|
||||||
|
if n == name then
|
||||||
|
table.remove(list, i) ; break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
set_faction_list(meta, list)
|
||||||
|
end
|
||||||
|
|
||||||
-- protector interface
|
-- protector interface
|
||||||
|
|
||||||
local function protector_formspec(meta)
|
local function protector_formspec(meta)
|
||||||
@@ -165,40 +246,13 @@ local function protector_formspec(meta)
|
|||||||
.. default.gui_bg_img
|
.. default.gui_bg_img
|
||||||
.. "label[2.5,0;" .. F(S("-- Protector interface --")) .. "]"
|
.. "label[2.5,0;" .. F(S("-- Protector interface --")) .. "]"
|
||||||
.. "label[0,1;" .. F(S("PUNCH node to show protected area")) .. "]"
|
.. "label[0,1;" .. F(S("PUNCH node to show protected area")) .. "]"
|
||||||
.. "label[0,2;" .. F(S("Members:")) .. "]"
|
.. "label[0,1.5;" .. F(S("Members:")) .. "]"
|
||||||
.. "button_exit[2.5,6.2;3,0.5;close_me;" .. F(S("Close")) .. "]"
|
.. "button_exit[2.5,6.2;3,0.5;close_me;" .. F(S("Close")) .. "]"
|
||||||
.. "field_close_on_enter[protector_add_member;false]"
|
.. "field_close_on_enter[protector_add_member;false]"
|
||||||
|
|
||||||
local members = get_member_list(meta)
|
local members = get_member_list(meta)
|
||||||
|
|
||||||
local i = 0
|
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
|
for n = 1, #members do
|
||||||
|
|
||||||
@@ -206,12 +260,12 @@ local function protector_formspec(meta)
|
|||||||
|
|
||||||
-- show username
|
-- show username
|
||||||
formspec = formspec .. "button[" .. (i % 4 * 2)
|
formspec = formspec .. "button[" .. (i % 4 * 2)
|
||||||
.. "," .. math_floor(i / 4 + 3)
|
.. "," .. (math_floor(i / 4) + 2.5)
|
||||||
.. ";1.5,.5;protector_member;" .. F(members[n]) .. "]"
|
.. ";1.5,.5;protector_member;" .. F(members[n]) .. "]"
|
||||||
|
|
||||||
-- username remove button
|
-- username remove button
|
||||||
.. "button[" .. (i % 4 * 2 + 1.25) .. ","
|
.. "button[" .. (i % 4 * 2 + 1.25) .. ","
|
||||||
.. math_floor(i / 4 + 3)
|
.. (math_floor(i / 4) + 2.5)
|
||||||
.. ";.75,.5;protector_del_member_" .. F(members[n]) .. ";X]"
|
.. ";.75,.5;protector_del_member_" .. F(members[n]) .. ";X]"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -222,12 +276,48 @@ local function protector_formspec(meta)
|
|||||||
|
|
||||||
-- user name entry field
|
-- user name entry field
|
||||||
formspec = formspec .. "field[" .. (i % 4 * 2 + 1 / 3) .. ","
|
formspec = formspec .. "field[" .. (i % 4 * 2 + 1 / 3) .. ","
|
||||||
.. (math_floor(i / 4 + 3) + 1 / 3)
|
.. (math_floor(i / 4) + 2.5 + 1 / 3)
|
||||||
.. ";1.433,.5;protector_add_member;;]"
|
.. ";1.433,.5;protector_add_member;;]"
|
||||||
|
|
||||||
-- username add button
|
-- username add button
|
||||||
.."button[" .. (i % 4 * 2 + 1.25) .. ","
|
.."button[" .. (i % 4 * 2 + 1.25) .. ","
|
||||||
.. math_floor(i / 4 + 3) .. ";.75,.5;protector_submit;+]"
|
.. (math_floor(i / 4) + 2.5) .. ";.75,.5;protector_submit;+]"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if factions_available then
|
||||||
|
|
||||||
|
formspec = formspec .. "label[0,4.25;"
|
||||||
|
.. F(S("Factions: (use * to allow any of your factions)")) .. "]"
|
||||||
|
.. "field_close_on_enter[protector_add_faction;false]"
|
||||||
|
|
||||||
|
local member_factions = get_faction_list(meta)
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
for n = 1, #member_factions do
|
||||||
|
|
||||||
|
if i < 4 then
|
||||||
|
|
||||||
|
formspec = formspec .. "button[" .. (i % 4 * 2)
|
||||||
|
.. "," .. math_floor(i / 4 + 5)
|
||||||
|
.. ";1.5,.5;protector_faction;" .. F(member_factions[n]) .. "]"
|
||||||
|
.. "button[" .. (i % 4 * 2 + 1.25) .. ","
|
||||||
|
.. math_floor(i / 4 + 5)
|
||||||
|
.. ";.75,.5;protector_del_faction_" .. F(member_factions[n]) .. ";X]"
|
||||||
|
end
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if i < 4 then
|
||||||
|
|
||||||
|
formspec = formspec .. "field[" .. (i % 4 * 2 + 1 / 3) .. ","
|
||||||
|
.. (math_floor(i / 4 + 5) + 1 / 3)
|
||||||
|
.. ";1.433,.5;protector_add_faction;;]"
|
||||||
|
.."button[" .. (i % 4 * 2 + 1.25) .. ","
|
||||||
|
.. math_floor(i / 4 + 5) .. ";.75,.5;protector_submit_faction;+]"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return formspec
|
return formspec
|
||||||
@@ -254,7 +344,7 @@ local function show_msg(player_name, msg)
|
|||||||
-- if messages disabled or no player name provided
|
-- if messages disabled or no player name provided
|
||||||
if protector_msg == false or not player_name or player_name == "" then return end
|
if protector_msg == false or not player_name or player_name == "" then return end
|
||||||
|
|
||||||
minetest.chat_send_player(player_name, msg)
|
core.chat_send_player(player_name, msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Infolevel:
|
-- Infolevel:
|
||||||
@@ -268,8 +358,7 @@ function protector.can_dig(r, pos, digger, onlyowner, infolevel)
|
|||||||
if not digger or not pos then return false end
|
if not digger or not pos then return false end
|
||||||
|
|
||||||
-- protector_bypass privileged users can override protection
|
-- protector_bypass privileged users can override protection
|
||||||
if infolevel == 1
|
if infolevel == 1 and core.check_player_privs(digger, {protection_bypass = true}) then
|
||||||
and minetest.check_player_privs(digger, {protection_bypass = true}) then
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -280,22 +369,23 @@ function protector.can_dig(r, pos, digger, onlyowner, infolevel)
|
|||||||
if inside_spawn(pos, protector_spawn) then
|
if inside_spawn(pos, protector_spawn) then
|
||||||
|
|
||||||
show_msg(digger, S("Spawn @1 has been protected up to a @2 block radius.",
|
show_msg(digger, S("Spawn @1 has been protected up to a @2 block radius.",
|
||||||
minetest.pos_to_string(statspawn), protector_spawn))
|
core.pos_to_string(statspawn), protector_spawn))
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- find the protector nodes
|
-- find the protector nodes (protector is at the corner of its zone,
|
||||||
local pos = minetest.find_nodes_in_area(
|
-- 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 + 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"})
|
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||||
|
|
||||||
local meta, owner, members
|
local meta, owner, members
|
||||||
|
|
||||||
for n = 1, #pos do
|
for n = 1, #pos do
|
||||||
|
|
||||||
meta = minetest.get_meta(pos[n])
|
meta = core.get_meta(pos[n])
|
||||||
owner = meta:get_string("owner") or ""
|
owner = meta:get_string("owner") or ""
|
||||||
members = meta:get_string("members") or ""
|
members = meta:get_string("members") or ""
|
||||||
|
|
||||||
@@ -314,14 +404,14 @@ function protector.can_dig(r, pos, digger, onlyowner, infolevel)
|
|||||||
-- when using protector as tool, show protector information
|
-- when using protector as tool, show protector information
|
||||||
if infolevel == 2 then
|
if infolevel == 2 then
|
||||||
|
|
||||||
minetest.chat_send_player(digger,
|
core.chat_send_player(digger,
|
||||||
S("This area is owned by @1", owner) .. ".")
|
S("This area is owned by @1", owner) .. ".")
|
||||||
|
|
||||||
minetest.chat_send_player(digger,
|
core.chat_send_player(digger,
|
||||||
S("Protection located at: @1", minetest.pos_to_string(pos[n])))
|
S("Protection located at: @1", core.pos_to_string(pos[n])))
|
||||||
|
|
||||||
if members ~= "" then
|
if members ~= "" then
|
||||||
minetest.chat_send_player(digger, S("Members: @1.", members))
|
core.chat_send_player(digger, S("Members: @1.", members))
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -333,10 +423,10 @@ function protector.can_dig(r, pos, digger, onlyowner, infolevel)
|
|||||||
if infolevel == 2 then
|
if infolevel == 2 then
|
||||||
|
|
||||||
if #pos < 1 then
|
if #pos < 1 then
|
||||||
minetest.chat_send_player(digger, S("This area is not protected."))
|
core.chat_send_player(digger, S("This area is not protected."))
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.chat_send_player(digger, S("You can build here."))
|
core.chat_send_player(digger, S("You can build here."))
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@@ -344,9 +434,9 @@ end
|
|||||||
|
|
||||||
-- add protector hurt and flip to protection violation function
|
-- add protector hurt and flip to protection violation function
|
||||||
|
|
||||||
minetest.register_on_protection_violation(function(pos, name)
|
core.register_on_protection_violation(function(pos, name)
|
||||||
|
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = core.get_player_by_name(name)
|
||||||
|
|
||||||
if player and player:is_player() then
|
if player and player:is_player() then
|
||||||
|
|
||||||
@@ -354,8 +444,11 @@ minetest.register_on_protection_violation(function(pos, name)
|
|||||||
if protector_hurt > 0 and player:get_hp() > 0 then
|
if protector_hurt > 0 and player:get_hp() > 0 then
|
||||||
|
|
||||||
-- This delay fixes item duplication bug (thanks luk3yx)
|
-- This delay fixes item duplication bug (thanks luk3yx)
|
||||||
minetest.after(0.1, function(player)
|
core.after(0.1, function(player)
|
||||||
|
|
||||||
|
if player:get_pos() then
|
||||||
player:set_hp(player:get_hp() - protector_hurt)
|
player:set_hp(player:get_hp() - protector_hurt)
|
||||||
|
end
|
||||||
end, player)
|
end, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -386,16 +479,16 @@ end)
|
|||||||
|
|
||||||
-- backup old is_protected function
|
-- backup old is_protected function
|
||||||
|
|
||||||
local old_is_protected = minetest.is_protected
|
local old_is_protected = core.is_protected
|
||||||
|
|
||||||
-- check for protected area, return true if protected and digger isn't on list
|
-- check for protected area, return true if protected and digger isn't on list
|
||||||
|
|
||||||
function minetest.is_protected(pos, digger)
|
function core.is_protected(pos, digger)
|
||||||
|
|
||||||
digger = digger or "" -- nil check
|
digger = digger or "" -- nil check
|
||||||
|
|
||||||
-- is area protected against digger?
|
-- 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
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -413,32 +506,44 @@ local function check_overlap(itemstack, placer, pointed_thing)
|
|||||||
local name = placer:get_player_name()
|
local name = placer:get_player_name()
|
||||||
|
|
||||||
-- make sure protector doesn't overlap onto protected spawn area
|
-- 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
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
core.chat_send_player(name,
|
||||||
S("Spawn @1 has been protected up to a @2 block radius.",
|
S("Spawn @1 has been protected up to a @2 block radius.",
|
||||||
minetest.pos_to_string(statspawn), protector_spawn))
|
core.pos_to_string(statspawn), protector_spawn))
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- make sure protector doesn't overlap any other player's area
|
-- 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"})
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
for _, npos in ipairs(ov_nodes) do
|
||||||
S("Overlaps into above players protected area"))
|
|
||||||
|
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
|
return itemstack
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
return core.item_place(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- remove protector display entities
|
-- remove protector display entities
|
||||||
|
|
||||||
local function del_display(pos)
|
local function del_display(pos)
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
local objects = core.get_objects_inside_radius(pos, 0.5)
|
||||||
|
|
||||||
for _, v in ipairs(objects) do
|
for _, v in ipairs(objects) do
|
||||||
|
|
||||||
@@ -456,7 +561,7 @@ local player_pos = {}
|
|||||||
|
|
||||||
local stone_tex = "default_stone.png"
|
local stone_tex = "default_stone.png"
|
||||||
|
|
||||||
if minetest.get_modpath("nc_terrain") then
|
if core.get_modpath("nc_terrain") then
|
||||||
stone_tex = "nc_terrain_stone.png"
|
stone_tex = "nc_terrain_stone.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -483,7 +588,7 @@ local def = {
|
|||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
|
|
||||||
meta:set_string("owner", placer:get_player_name() or "")
|
meta:set_string("owner", placer:get_player_name() or "")
|
||||||
meta:set_string("members", "")
|
meta:set_string("members", "")
|
||||||
@@ -495,28 +600,29 @@ local def = {
|
|||||||
|
|
||||||
if pointed_thing.type ~= "node" then return end
|
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)
|
user:get_player_name(), false, 2)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker, itemstack)
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
local name = clicker:get_player_name()
|
local name = clicker:get_player_name()
|
||||||
|
|
||||||
if meta and protector.can_dig(1, pos, name, true, 1) then
|
if meta and protector.can_dig(1, pos, name, true, 1) then
|
||||||
|
|
||||||
player_pos[name] = pos
|
player_pos[name] = pos
|
||||||
|
|
||||||
minetest.show_formspec(name, "protector:node", protector_formspec(meta))
|
core.show_formspec(name, "protector:node", protector_formspec(meta))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
|
|
||||||
if minetest.is_protected(pos, puncher:get_player_name()) then return end
|
if core.is_protected(pos, puncher:get_player_name()) then return end
|
||||||
|
|
||||||
minetest.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,
|
end,
|
||||||
|
|
||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
@@ -531,21 +637,17 @@ local def = {
|
|||||||
|
|
||||||
-- protection node
|
-- protection node
|
||||||
|
|
||||||
minetest.register_node("protector:protect", table.copy(def))
|
core.register_node("protector:protect", table.copy(def))
|
||||||
|
|
||||||
-- default recipe and alternative for MineClone2
|
-- default recipe and alternative for MineClonia/Voxelibre
|
||||||
|
|
||||||
if protector_recipe then
|
if protector_recipe then
|
||||||
|
|
||||||
local item_gold = "default:gold_ingot"
|
local mcl = core.get_modpath("mcl_core")
|
||||||
local item_stone = "default:stone"
|
local item_gold = mcl and "mcl_core:gold_ingot" or "default:gold_ingot"
|
||||||
|
local item_stone = mcl and "mcl_core:stone" or "default:stone"
|
||||||
|
|
||||||
if minetest.get_modpath("mcl_core") then
|
core.register_craft({
|
||||||
item_gold = "mcl_core:gold_ingot"
|
|
||||||
item_stone = "mcl_core:stone"
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "protector:protect",
|
output = "protector:protect",
|
||||||
recipe = {
|
recipe = {
|
||||||
{item_stone, item_stone, item_stone},
|
{item_stone, item_stone, item_stone},
|
||||||
@@ -573,56 +675,70 @@ def.node_box = {
|
|||||||
}
|
}
|
||||||
def.selection_box = {type = "wallmounted"}
|
def.selection_box = {type = "wallmounted"}
|
||||||
|
|
||||||
minetest.register_node("protector:protect2", table.copy(def))
|
core.register_node("protector:protect2", table.copy(def))
|
||||||
|
|
||||||
-- recipes to switch between protectors
|
-- recipes to switch between protectors
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({ output = "protector:protect", recipe = {{"protector:protect2"}} })
|
||||||
output = "protector:protect", recipe = {{"protector:protect2"}}
|
core.register_craft({ output = "protector:protect2", recipe = {{"protector:protect"}} })
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "protector:protect2", recipe = {{"protector:protect"}}
|
|
||||||
})
|
|
||||||
|
|
||||||
-- check formspec buttons or when name entered
|
-- check formspec buttons or when name entered
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
if formname ~= "protector:node" then return end
|
if formname ~= "protector:node" then return end
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player and player:get_player_name()
|
||||||
local pos = player_pos[name]
|
local pos = name and player_pos[name]
|
||||||
|
|
||||||
if not name or not pos then return end
|
if not pos then return end
|
||||||
|
|
||||||
local add_member_input = fields.protector_add_member
|
local add_member_input = fields.protector_add_member
|
||||||
|
|
||||||
-- reset formspec until close button pressed
|
-- reset formspec until close button pressed
|
||||||
if (fields.close_me or fields.quit)
|
if (fields.close_me or fields.quit)
|
||||||
and (not add_member_input or add_member_input == "") then
|
and (not add_member_input or add_member_input == "") then
|
||||||
player_pos[name] = nil
|
player_pos[name] = nil ; return
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- only owner can add names
|
-- only owner can add names
|
||||||
if not protector.can_dig(1, pos, player:get_player_name(), true, 1) then
|
if not protector.can_dig(1, pos, name, true, 1) then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- are we adding member to a protection node ? (csm protection)
|
-- are we adding member to a protection node ? (csm protection)
|
||||||
local nod = minetest.get_node(pos).name
|
local nod = core.get_node(pos).name
|
||||||
|
|
||||||
if nod ~= "protector:protect" and nod ~= "protector:protect2" then
|
if nod ~= "protector:protect" and nod ~= "protector:protect2" then
|
||||||
player_pos[name] = nil
|
player_pos[name] = nil ; return
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos) ; if not meta then return end
|
local meta = core.get_meta(pos)
|
||||||
|
|
||||||
-- add faction members
|
if not meta then
|
||||||
if factions_available and fields.faction_members ~= nil then
|
player_pos[name] = nil ; return
|
||||||
meta:set_int("faction_members", fields.faction_members == "true" and 1 or 0)
|
end
|
||||||
|
|
||||||
|
if factions_available then
|
||||||
|
|
||||||
|
local add_faction_input = fields.protector_add_faction
|
||||||
|
|
||||||
|
-- add faction member [+]
|
||||||
|
if add_faction_input and add_faction_input ~= "" then
|
||||||
|
|
||||||
|
for _, i in pairs(add_faction_input:split(" ")) do
|
||||||
|
add_faction(meta, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- remove faction member [x]
|
||||||
|
for field, value in pairs(fields) do
|
||||||
|
|
||||||
|
if string.sub(field, 0,
|
||||||
|
string.len("protector_del_faction_")) == "protector_del_faction_" then
|
||||||
|
|
||||||
|
del_faction(meta, string.sub(field,
|
||||||
|
string.len("protector_del_faction_") + 1))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add member [+]
|
-- add member [+]
|
||||||
@@ -643,12 +759,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.show_formspec(name, formname, protector_formspec(meta))
|
core.show_formspec(name, formname, protector_formspec(meta))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- display entity shown when protector node is punched
|
-- display entity shown when protector node is punched
|
||||||
|
|
||||||
minetest.register_entity("protector:display", {
|
core.register_entity("protector:display", {
|
||||||
|
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
physical = false,
|
physical = false,
|
||||||
@@ -658,9 +774,7 @@ minetest.register_entity("protector:display", {
|
|||||||
visual_size = {x = 0.67, y = 0.67},
|
visual_size = {x = 0.67, y = 0.67},
|
||||||
textures = {"protector:display_node"},
|
textures = {"protector:display_node"},
|
||||||
glow = 10
|
glow = 10
|
||||||
},
|
}, timer = 0,
|
||||||
|
|
||||||
timer = 0,
|
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
|
|
||||||
@@ -674,22 +788,22 @@ minetest.register_entity("protector:display", {
|
|||||||
-- Display-zone node, Do NOT place the display as a node,
|
-- Display-zone node, Do NOT place the display as a node,
|
||||||
-- it is made to be used as an entity (see above)
|
-- 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
|
||||||
|
|
||||||
minetest.register_node("protector:display_node", {
|
core.register_node("protector:display_node", {
|
||||||
tiles = {"protector_display.png"},
|
tiles = {"protector_display.png"},
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed", fixed = {
|
||||||
fixed = {
|
{-(hl+.55), -(hl+.55), -(hl+.55), -(hl+.45), (hl+.55), (hl+.55)}, -- sides
|
||||||
{-(r+.55), -(r+.55), -(r+.55), -(r+.45), (r+.55), (r+.55)}, -- sides
|
{-(hl+.55), -(hl+.55), (hl+.45), (hl+.55), (hl+.55), (hl+.55)},
|
||||||
{-(r+.55), -(r+.55), (r+.45), (r+.55), (r+.55), (r+.55)},
|
{(hl+.45), -(hl+.55), -(hl+.55), (hl+.55), (hl+.55), (hl+.55)},
|
||||||
{(r+.45), -(r+.55), -(r+.55), (r+.55), (r+.55), (r+.55)},
|
{-(hl+.55), -(hl+.55), -(hl+.55), (hl+.55), (hl+.55), -(hl+.45)},
|
||||||
{-(r+.55), -(r+.55), -(r+.55), (r+.55), (r+.55), -(r+.45)},
|
{-(hl+.55), (hl+.45), -(hl+.55), (hl+.55), (hl+.55), (hl+.55)}, -- top
|
||||||
{-(r+.55), (r+.45), -(r+.55), (r+.55), (r+.55), (r+.55)}, -- top
|
{-(hl+.55), -(hl+.55), -(hl+.55), (hl+.55), -(hl+.45), (hl+.55)}, -- bottom
|
||||||
{-(r+.55), -(r+.55), -(r+.55), (r+.55), -(r+.45), (r+.55)}, -- bottom
|
|
||||||
{-.55,-.55,-.55, .55,.55,.55} -- middle (surrounding protector)
|
{-.55,-.55,-.55, .55,.55,.55} -- middle (surrounding protector)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -709,13 +823,13 @@ dofile(MP .. "/admin.lua")
|
|||||||
dofile(MP .. "/tool.lua")
|
dofile(MP .. "/tool.lua")
|
||||||
dofile(MP .. "/hud.lua")
|
dofile(MP .. "/hud.lua")
|
||||||
|
|
||||||
if minetest.get_modpath("lucky_block") then
|
if core.get_modpath("lucky_block") then
|
||||||
dofile(MP .. "/lucky_block.lua")
|
dofile(MP .. "/lucky_block.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- stop mesecon pistons from pushing protectors
|
-- stop mesecon pistons from pushing protectors
|
||||||
|
|
||||||
if minetest.get_modpath("mesecons_mvps") then
|
if core.get_modpath("mesecons_mvps") then
|
||||||
mesecon.register_mvps_stopper("protector:protect")
|
mesecon.register_mvps_stopper("protector:protect")
|
||||||
mesecon.register_mvps_stopper("protector:protect2")
|
mesecon.register_mvps_stopper("protector:protect2")
|
||||||
mesecon.register_mvps_stopper("protector:protect_hidden")
|
mesecon.register_mvps_stopper("protector:protect_hidden")
|
||||||
@@ -724,7 +838,7 @@ end
|
|||||||
|
|
||||||
-- player command to add member names to local protection
|
-- player command to add member names to local protection
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_add_member", {
|
core.register_chatcommand("protector_add_member", {
|
||||||
params = "",
|
params = "",
|
||||||
description = S("Add member names to local protection"),
|
description = S("Add member names to local protection"),
|
||||||
privs = {interact = true},
|
privs = {interact = true},
|
||||||
@@ -734,30 +848,30 @@ minetest.register_chatcommand("protector_add_member", {
|
|||||||
if param == "" then return end
|
if param == "" then return end
|
||||||
|
|
||||||
local to_add = param:split(" ")
|
local to_add = param:split(" ")
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = core.get_player_by_name(name)
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
-- find the protector nodes
|
-- find the protector nodes
|
||||||
local pos = minetest.find_nodes_in_area(
|
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 + 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"})
|
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||||
|
|
||||||
local meta, owner
|
local meta, owner
|
||||||
|
|
||||||
for n = 1, #pos do
|
for n = 1, #pos do
|
||||||
|
|
||||||
meta = minetest.get_meta(pos[n])
|
meta = core.get_meta(pos[n])
|
||||||
owner = meta:get_string("owner") or ""
|
owner = meta:get_string("owner") or ""
|
||||||
|
|
||||||
if owner == name
|
if owner == name
|
||||||
or minetest.check_player_privs(name, {protection_bypass = true}) then
|
or core.check_player_privs(name, {protection_bypass = true}) then
|
||||||
|
|
||||||
for m = 1, #to_add do
|
for m = 1, #to_add do
|
||||||
add_member(meta, to_add[m])
|
add_member(meta, to_add[m])
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.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
|
end
|
||||||
end
|
end
|
||||||
@@ -765,7 +879,7 @@ minetest.register_chatcommand("protector_add_member", {
|
|||||||
|
|
||||||
-- player command to remove member names from local protection
|
-- player command to remove member names from local protection
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_del_member", {
|
core.register_chatcommand("protector_del_member", {
|
||||||
params = "",
|
params = "",
|
||||||
description = S("Remove member names from local protection"),
|
description = S("Remove member names from local protection"),
|
||||||
privs = {interact = true},
|
privs = {interact = true},
|
||||||
@@ -775,30 +889,30 @@ minetest.register_chatcommand("protector_del_member", {
|
|||||||
if param == "" then return end
|
if param == "" then return end
|
||||||
|
|
||||||
local to_del = param:split(" ")
|
local to_del = param:split(" ")
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = core.get_player_by_name(name)
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
-- find the protector nodes
|
-- find the protector nodes
|
||||||
local pos = minetest.find_nodes_in_area(
|
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 + 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"})
|
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||||
|
|
||||||
local meta, owner
|
local meta, owner
|
||||||
|
|
||||||
for n = 1, #pos do
|
for n = 1, #pos do
|
||||||
|
|
||||||
meta = minetest.get_meta(pos[n])
|
meta = core.get_meta(pos[n])
|
||||||
owner = meta:get_string("owner") or ""
|
owner = meta:get_string("owner") or ""
|
||||||
|
|
||||||
if owner == name
|
if owner == name
|
||||||
or minetest.check_player_privs(name, {protection_bypass = true}) then
|
or core.check_player_privs(name, {protection_bypass = true}) then
|
||||||
|
|
||||||
for m = 1, #to_del do
|
for m = 1, #to_del do
|
||||||
del_member(meta, to_del[m])
|
del_member(meta, to_del[m])
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.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
|
end
|
||||||
end
|
end
|
||||||
@@ -806,3 +920,4 @@ minetest.register_chatcommand("protector_del_member", {
|
|||||||
|
|
||||||
|
|
||||||
print ("[MOD] Protector Redo loaded")
|
print ("[MOD] Protector Redo loaded")
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ Members:=Miembros:
|
|||||||
Close=Cerrar
|
Close=Cerrar
|
||||||
Protection located at: @1=Protección ubicada en: @1
|
Protection located at: @1=Protección ubicada en: @1
|
||||||
Members: @1.=Miembros: @1.
|
Members: @1.=Miembros: @1.
|
||||||
Allow faction access=
|
|
||||||
This area is not protected.=Esta área no está protegida.
|
This area is not protected.=Esta área no está protegida.
|
||||||
You can build here.=Puedes construir aquí.
|
You can build here.=Puedes construir aquí.
|
||||||
Overlaps into above players protected area=Se superpone en el área protegida de los jugadores anteriores
|
Overlaps into above players protected area=Se superpone en el área protegida de los jugadores anteriores
|
||||||
@@ -43,6 +42,7 @@ Protection Logo=Logotipo de la protección
|
|||||||
[MOD] Protector Redo loaded=[MOD] Protector recargado
|
[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.
|
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
|
This area is owned by @1=Esta área es propiedad de @1
|
||||||
|
Factions: (use * to allow any of your factions)=Facciones: (utiliza * para autorizar todas tus facciones)
|
||||||
|
|
||||||
### hud.lua ###
|
### hud.lua ###
|
||||||
Owner: @1=Propietario: @1
|
Owner: @1=Propietario: @1
|
||||||
|
|||||||
+17
-17
@@ -6,20 +6,20 @@
|
|||||||
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)
|
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>
|
<names list>=<liste de noms>
|
||||||
Replace Protector Owner with name provided=Remplacer le propriétaire du protecteur par le nom fourni
|
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>
|
<owner name> <name to replace with>=<nom du propriétaire> <nouveau nom>
|
||||||
Replacing Protector name '@1' with '@2'=
|
Replacing Protector name '@1' with '@2'=Remplacement du nom du protecteur '@1' par '@2'
|
||||||
Show protected areas of your nearby protectors=Affichez les zones protégées de vos protecteurs à proximité
|
Show protected areas of your nearby protectors=Afficher les zones protégées de vos protecteurs à proximité
|
||||||
Protector Names to remove: @1=Noms de protecteurs à supprimer : @1
|
Protector Names to remove: @1=Noms de protecteurs à supprimer : @1
|
||||||
Name List Reset=Liste de noms réinitialiser
|
Name List Reset=Liste de noms réinitialisée
|
||||||
Invalid player name!=
|
Invalid player name!=Nom de joueur invalide !
|
||||||
Player name too long=
|
Player name too long=Nom de joueur trop long
|
||||||
Player not found.=
|
Player not found.=Joueur inconnu.
|
||||||
|
|
||||||
### doors_chest.lua ###
|
### doors_chest.lua ###
|
||||||
Protected Wooden Door=Porte en bois protégée
|
Protected Wooden Door=Porte en bois protégée
|
||||||
Protected Steel Door=Porte en acier protégée
|
Protected Steel Door=Porte en acier protégée
|
||||||
Protected Trapdoor=Trappe protégé
|
Protected Trapdoor=Trappe protégée
|
||||||
Protected Steel Trapdoor=Trap en acier protégé
|
Protected Steel Trapdoor=Trappe en acier protégée
|
||||||
Protected Chest=Coffre protégé
|
Protected Chest=Coffre protégé
|
||||||
To Chest=Vers le coffre
|
To Chest=Vers le coffre
|
||||||
To Inventory=Vers l'inventaire
|
To Inventory=Vers l'inventaire
|
||||||
@@ -27,31 +27,31 @@ Protected Chest (@1)=Coffre protégé (@1)
|
|||||||
|
|
||||||
### init.lua ###
|
### init.lua ###
|
||||||
-- Protector interface --=-- Interface Protector --
|
-- Protector interface --=-- Interface Protector --
|
||||||
PUNCH node to show protected area=TAPÉ le bloc pour afficher la zone protégée
|
PUNCH node to show protected area=TAPER le bloc pour afficher la zone protégée
|
||||||
USE for area check=UTILISER pour vérifier la zone
|
USE for area check=UTILISER pour vérifier la zone
|
||||||
Members:=Membres :
|
Members:=Membres :
|
||||||
Close=Fermer
|
Close=Fermer
|
||||||
Protection located at: @1=Protection située à : @1
|
Protection located at: @1=Protection située à : @1
|
||||||
Members: @1.=Membres : @1.
|
Members: @1.=Membres : @1.
|
||||||
Allow faction access=
|
|
||||||
This area is not protected.=msgstr "Cette zone n'est pas protégée.
|
This area is not protected.=msgstr "Cette zone n'est pas protégée.
|
||||||
You can build here.=Vous pouvez construire ici.
|
You can build here.=Vous pouvez construire ici.
|
||||||
Overlaps into above players protected area=Vous chevauché une zone protégé.
|
Overlaps into above players protected area=La zone chevauche une autre zone protégée.
|
||||||
Protection Block=Bloc de protection
|
Protection Block=Bloc de protection
|
||||||
Protection (owned by @1)=Protection (détenue par @1)
|
Protection (owned by @1)=Protection (détenue par @1)
|
||||||
Protection Logo=Logo de protection
|
Protection Logo=Logo de protection
|
||||||
[MOD] Protector Redo loaded=[MOD] Protector Redo chargé
|
[MOD] Protector Redo loaded=[MOD] Protector Redo chargé
|
||||||
Spawn @1 has been protected up to a @2 block radius.=
|
Spawn @1 has been protected up to a @2 block radius.=Le spawn @1 est protégé dans un rayon de @2 blocs.
|
||||||
This area is owned by @1=Cette zone appartient à @1 !
|
This area is owned by @1=Cette zone appartient à @1 !
|
||||||
|
Factions: (use * to allow any of your factions)=Factions : (taper * pour autoriser toutes vos factions)
|
||||||
|
|
||||||
### hud.lua ###
|
### hud.lua ###
|
||||||
Owner: @1=Propriétaire : @1
|
Owner: @1=Propriétaire : @1
|
||||||
|
|
||||||
### tool.lua ###
|
### 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 Placer Tool (stand near protector, face direction and use)=Outil de placement du protecteur (se tenir près du protecteur, dans la bonne direction et utiliser)
|
||||||
Protector already in place!=Protecteur déjà en place !
|
Protector already in place!=Protecteur déjà en place !
|
||||||
No protectors available to place!=Aucun protecteur disponible à placer !
|
No protectors available to place!=Aucun protecteur disponible à placer !
|
||||||
Protector placed at @1=Protection située à : @1
|
Protector placed at @1=Protection située à : @1
|
||||||
Out of bounds!=
|
Out of bounds!=Hors limites !
|
||||||
Cannot place protector, already protected at @1=
|
Cannot place protector, already protected at @1=Le protecteur ne peut être placé, déjà protégé à @1
|
||||||
Cannot place protector, container at @1=
|
Cannot place protector, container at @1=Le protecteur ne peut être placé, conteneur à @1
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
|
|
||||||
-- get static spawn position
|
-- get static spawn position
|
||||||
|
|
||||||
local statspawn = minetest.string_to_pos(minetest.settings:get("static_spawnpoint"))
|
local statspawn = core.string_to_pos(core.settings:get("static_spawnpoint"))
|
||||||
or {x = 0, y = 2, z = 0}
|
or {x = 0, y = 2, z = 0}
|
||||||
|
|
||||||
-- is spawn protected
|
-- is spawn protected
|
||||||
|
|
||||||
local protector_spawn = tonumber(minetest.settings:get("protector_spawn")
|
local protector_spawn = tonumber(core.settings:get("protector_spawn")
|
||||||
or minetest.settings:get("protector_pvp_spawn")) or 0
|
or core.settings:get("protector_pvp_spawn")) or 0
|
||||||
|
|
||||||
-- is night-only pvp enabled
|
-- is night-only pvp enabled
|
||||||
|
|
||||||
local protector_night_pvp = minetest.settings:get_bool("protector_night_pvp")
|
local protector_night_pvp = core.settings:get_bool("protector_night_pvp")
|
||||||
|
|
||||||
-- disables PVP in your own protected areas
|
-- disables PVP in your own protected areas
|
||||||
|
|
||||||
if minetest.settings:get_bool("enable_pvp")
|
if core.settings:get_bool("enable_pvp")
|
||||||
and minetest.settings:get_bool("protector_pvp") then
|
and core.settings:get_bool("protector_pvp") then
|
||||||
|
|
||||||
if minetest.register_on_punchplayer then
|
if core.register_on_punchplayer then
|
||||||
|
|
||||||
minetest.register_on_punchplayer(function(player, hitter,
|
core.register_on_punchplayer(function(player, hitter,
|
||||||
time_from_last_punch, tool_capabilities, dir, damage)
|
time_from_last_punch, tool_capabilities, dir, damage)
|
||||||
|
|
||||||
if not player or not hitter then
|
if not player or not hitter then
|
||||||
@@ -46,7 +46,7 @@ and minetest.settings:get_bool("protector_pvp") then
|
|||||||
if protector_night_pvp then
|
if protector_night_pvp then
|
||||||
|
|
||||||
-- get time of day
|
-- get time of day
|
||||||
local tod = minetest.get_timeofday() or 0
|
local tod = core.get_timeofday() or 0
|
||||||
|
|
||||||
if tod > 0.2 and tod < 0.8 then
|
if tod > 0.2 and tod < 0.8 then
|
||||||
--
|
--
|
||||||
@@ -56,7 +56,7 @@ and minetest.settings:get_bool("protector_pvp") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- is player being punched inside a protected area ?
|
-- is player being punched inside a protected area ?
|
||||||
if minetest.is_protected(pos, hitter:get_player_name()) then
|
if core.is_protected(pos, hitter:get_player_name()) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
# Size of protected area around protection node limiting player interaction
|
# Length of protected cube from the corner of the protection node
|
||||||
protector_radius (Protector Radius [max 30]) int 5
|
protector_length (Protector Length [max 60]) int 15
|
||||||
|
|
||||||
# Flips player around when accessing protected area to stop lag griefing
|
# Flips player around when accessing protected area to stop lag griefing
|
||||||
protector_flip (Protector Flip) bool false
|
protector_flip (Protector Flip) bool false
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
|
|
||||||
-- protector placement tool (thanks to Shara for code and idea)
|
-- protector placement tool (thanks to Shara for code and idea)
|
||||||
|
|
||||||
local S = minetest.get_translator("protector")
|
local S = core.get_translator("protector")
|
||||||
|
|
||||||
-- get protection radius
|
-- get protection length
|
||||||
|
|
||||||
local r = protector.radius
|
local r = protector.length
|
||||||
|
|
||||||
-- protector placement tool
|
-- protector placement tool
|
||||||
|
|
||||||
minetest.register_craftitem("protector:tool", {
|
core.register_craftitem("protector:tool", {
|
||||||
description = S("Protector Placer Tool (stand near protector, face direction and use)"),
|
description = S("Protector Placer Tool (stand near protector, face direction and use)"),
|
||||||
inventory_image = "protector_tool.png",
|
inventory_image = "protector_tool.png",
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
@@ -18,9 +18,9 @@ minetest.register_craftitem("protector:tool", {
|
|||||||
|
|
||||||
local name = user:get_player_name()
|
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 pos = user:get_pos()
|
||||||
local pp = minetest.find_nodes_in_area(
|
local pp = core.find_nodes_in_area(
|
||||||
vector.subtract(pos, 2), vector.add(pos, 2),
|
vector.subtract(pos, 2), vector.add(pos, 2),
|
||||||
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
{"protector:protect", "protector:protect2", "protector:protect_hidden"})
|
||||||
|
|
||||||
@@ -29,13 +29,14 @@ minetest.register_craftitem("protector:tool", {
|
|||||||
pos = pp[1] -- take position of first protector found
|
pos = pp[1] -- take position of first protector found
|
||||||
|
|
||||||
-- get members on protector
|
-- get members on protector
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
local members = meta:get_string("members") or ""
|
local members = meta:get_string("members") or ""
|
||||||
|
local factions = meta:get_string("factions") or ""
|
||||||
|
|
||||||
-- get direction player is facing
|
-- get direction player is facing
|
||||||
local dir = minetest.dir_to_facedir( user:get_look_dir() )
|
local dir = core.dir_to_facedir( user:get_look_dir() )
|
||||||
local vec = {x = 0, y = 0, z = 0}
|
local vec = {x = 0, y = 0, z = 0}
|
||||||
local gap = (r * 2) + 1
|
local gap = r + 1
|
||||||
local pit = user:get_look_vertical()
|
local pit = user:get_look_vertical()
|
||||||
|
|
||||||
-- set placement coords
|
-- set placement coords
|
||||||
@@ -53,28 +54,33 @@ minetest.register_craftitem("protector:tool", {
|
|||||||
pos.z = pos.z + vec.z
|
pos.z = pos.z + vec.z
|
||||||
|
|
||||||
-- does placing a protector overlap existing area
|
-- 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"})
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
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"))
|
S("Overlaps into above players protected area"))
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- does a protector already exist ?
|
-- does a protector already exist ?
|
||||||
if #minetest.find_nodes_in_area(vector.subtract(pos, 1), vector.add(pos, 1),
|
if #core.find_nodes_in_area(pos, pos,
|
||||||
{"protector:protect", "protector:protect2",
|
{"protector:protect", "protector:protect2",
|
||||||
"protector:protect_hidden"}) > 0 then
|
"protector:protect_hidden"}) > 0 then
|
||||||
|
|
||||||
minetest.chat_send_player(name, S("Protector already in place!"))
|
core.chat_send_player(name, S("Protector already in place!"))
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- do not place protector out of map bounds or replace bedrock
|
-- do not place protector out of map bounds or replace bedrock
|
||||||
if #minetest.find_nodes_in_area(pos, pos, {"ignore", "mcl_core:bedrock"}) > 0 then
|
if #core.find_nodes_in_area(pos, pos, {"ignore", "mcl_core:bedrock"}) > 0 then
|
||||||
|
|
||||||
minetest.chat_send_player(name, S("Out of bounds!"))
|
core.chat_send_player(name, S("Out of bounds!"))
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -86,7 +92,7 @@ minetest.register_craftitem("protector:tool", {
|
|||||||
if not inv:contains_item("main", "protector:protect")
|
if not inv:contains_item("main", "protector:protect")
|
||||||
and not inv:contains_item("main", "protector:protect2") then
|
and not inv:contains_item("main", "protector:protect2") then
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
core.chat_send_player(name,
|
||||||
S("No protectors available to place!"))
|
S("No protectors available to place!"))
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -107,29 +113,29 @@ minetest.register_craftitem("protector:tool", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- do not replace containers with inventory space
|
-- do not replace containers with inventory space
|
||||||
local inv = minetest.get_inventory({type = "node", pos = pos})
|
local inv = core.get_inventory({type = "node", pos = pos})
|
||||||
|
|
||||||
if inv then
|
if inv then
|
||||||
minetest.chat_send_player(name,
|
core.chat_send_player(name,
|
||||||
S("Cannot place protector, container at @1",
|
S("Cannot place protector, container at @1",
|
||||||
minetest.pos_to_string(pos)))
|
core.pos_to_string(pos)))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- protection check for other mods like Areas
|
-- protection check for other mods like Areas
|
||||||
if minetest.is_protected(pos, name) then
|
if core.is_protected(pos, name) then
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
core.chat_send_player(name,
|
||||||
S("Cannot place protector, already protected at @1",
|
S("Cannot place protector, already protected at @1",
|
||||||
minetest.pos_to_string(pos)))
|
core.pos_to_string(pos)))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- place protector
|
-- place protector
|
||||||
minetest.set_node(pos, {name = nod, param2 = 1})
|
core.set_node(pos, {name = nod, param2 = 1})
|
||||||
|
|
||||||
-- set protector metadata
|
-- set protector metadata
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
|
|
||||||
meta:set_string("owner", name)
|
meta:set_string("owner", name)
|
||||||
meta:set_string("infotext", "Protection (owned by " .. name .. ")")
|
meta:set_string("infotext", "Protection (owned by " .. name .. ")")
|
||||||
@@ -137,12 +143,15 @@ minetest.register_craftitem("protector:tool", {
|
|||||||
-- copy members across if holding sneak when using tool
|
-- copy members across if holding sneak when using tool
|
||||||
if user:get_player_control().sneak then
|
if user:get_player_control().sneak then
|
||||||
meta:set_string("members", members)
|
meta:set_string("members", members)
|
||||||
|
meta:set_string("factions", factions)
|
||||||
else
|
else
|
||||||
meta:set_string("members", "")
|
meta:set_string("members", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
core.add_entity({x=pos.x+r/2, y=pos.y+r/2, z=pos.z+r/2}, "protector:display")
|
||||||
S("Protector placed at @1", minetest.pos_to_string(pos)))
|
|
||||||
|
core.chat_send_player(name,
|
||||||
|
S("Protector placed at @1", core.pos_to_string(pos)))
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -150,11 +159,11 @@ minetest.register_craftitem("protector:tool", {
|
|||||||
|
|
||||||
local df = "default:steel_ingot"
|
local df = "default:steel_ingot"
|
||||||
|
|
||||||
if minetest.get_modpath("mcl_core") then
|
if core.get_modpath("mcl_core") then
|
||||||
df = "mcl_core:iron_ingot"
|
df = "mcl_core:iron_ingot"
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "protector:tool",
|
output = "protector:tool",
|
||||||
recipe = {
|
recipe = {
|
||||||
{df, df, df},
|
{df, df, df},
|
||||||
|
|||||||
Reference in New Issue
Block a user