Minor update
parent
3a17818e34
commit
96ca31dd7d
11
README.md
11
README.md
|
@ -96,12 +96,19 @@ Commands
|
||||||
* `/area_pos2 [X,Y,Z|X Y Z]` -- Sets area position two to your position or
|
* `/area_pos2 [X,Y,Z|X Y Z]` -- Sets area position two to your position or
|
||||||
the one supplied.
|
the one supplied.
|
||||||
|
|
||||||
|
* `/areas_cleanup` -- Removes all ownerless areas.
|
||||||
|
Useful for cleaning after user deletion, for example using /remove_player.
|
||||||
|
|
||||||
|
* `/area_open <ID>` -- Toggle open/closed the specified area for everyone.
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Copyright (C) 2013 ShadowNinja
|
Copyright (C) 2013-2017 ShadowNinja
|
||||||
|
|
||||||
Copyright (C) 2019-2020 MultiCraft Development Team
|
Copyright (C) 2015-2020 various contributors
|
||||||
|
|
||||||
|
Copyright (C) 2019-2021 MultiCraft Development Team
|
||||||
|
|
||||||
Licensed under the GNU LGPL version 3.0 or later.
|
Licensed under the GNU LGPL version 3.0 or later.
|
||||||
See https://www.gnu.org/licenses/lgpl-3.0.txt
|
See https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local S = intllib.make_gettext_pair()
|
local S = areas.S
|
||||||
|
|
||||||
minetest.register_chatcommand("protect", {
|
minetest.register_chatcommand("protect", {
|
||||||
params = S("<AreaName>"),
|
params = S("<AreaName>"),
|
||||||
|
@ -79,8 +79,7 @@ minetest.register_chatcommand("add_owner", {
|
||||||
.." positions that have already been protected,"
|
.." positions that have already been protected,"
|
||||||
.." Use set_owner if you don't want the parent to be set."),
|
.." Use set_owner if you don't want the parent to be set."),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local pid, ownerName, areaName
|
local pid, ownerName, areaName = param:match('^(%d+) ([^ ]+) (.+)$')
|
||||||
= param:match('^(%d+) ([^ ]+) (.+)$')
|
|
||||||
|
|
||||||
if not pid then
|
if not pid then
|
||||||
minetest.chat_send_player(name, S("Invalid usage, see /help @1.", "add_owner"))
|
minetest.chat_send_player(name, S("Invalid usage, see /help @1.", "add_owner"))
|
||||||
|
@ -120,7 +119,7 @@ minetest.register_chatcommand("add_owner", {
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("rename_area", {
|
minetest.register_chatcommand("rename_area", {
|
||||||
params = S("<ID>").." "..S("<NewName>"),
|
params = S("<ID>").." "..S("<newName>"),
|
||||||
description = S("Rename an area that you own"),
|
description = S("Rename an area that you own"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local id, newName = param:match("^(%d+)%s(.+)$")
|
local id, newName = param:match("^(%d+)%s(.+)$")
|
||||||
|
@ -199,8 +198,8 @@ minetest.register_chatcommand("list_areas", {
|
||||||
if #areaStrings == 0 then
|
if #areaStrings == 0 then
|
||||||
return true, S("No visible areas.")
|
return true, S("No visible areas.")
|
||||||
elseif #areaStrings > 100 then
|
elseif #areaStrings > 100 then
|
||||||
return true, S("Too many areas to list.")
|
return true, S("Too many areas to list.")
|
||||||
end
|
end
|
||||||
|
|
||||||
return true, table.concat(areaStrings, "\n")
|
return true, table.concat(areaStrings, "\n")
|
||||||
end
|
end
|
||||||
|
@ -381,7 +380,6 @@ minetest.register_chatcommand("area_info", {
|
||||||
area_num = area_num + 1
|
area_num = area_num + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(lines, S("You have @1 areas.", area_num))
|
table.insert(lines, S("You have @1 areas.", area_num))
|
||||||
|
|
||||||
-- Area limit
|
-- Area limit
|
||||||
|
@ -417,8 +415,7 @@ minetest.register_chatcommand("area_info", {
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("areas_cleanup", {
|
minetest.register_chatcommand("areas_cleanup", {
|
||||||
params = "<id>",
|
description = S("Removes all ownerless areas"),
|
||||||
description = "Removes all ownerless areas",
|
|
||||||
privs = areas.adminPrivs,
|
privs = areas.adminPrivs,
|
||||||
func = function()
|
func = function()
|
||||||
local total, count = 0, 0
|
local total, count = 0, 0
|
||||||
|
@ -436,6 +433,7 @@ minetest.register_chatcommand("areas_cleanup", {
|
||||||
end
|
end
|
||||||
areas:save()
|
areas:save()
|
||||||
|
|
||||||
return true, "Total areas: " .. total .. ", Removed: " .. count .. " areas! New count: " .. total - count
|
return true, "Total areas: " .. total .. ", Removed: " ..
|
||||||
|
count .. " areas. New count: " .. (total - count)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
9
hud.lua
9
hud.lua
|
@ -1,9 +1,12 @@
|
||||||
-- This is inspired by the landrush mod by Bremaweb
|
-- This is inspired by the landrush mod by Bremaweb
|
||||||
|
|
||||||
local S = intllib.make_gettext_pair()
|
local S = areas.S
|
||||||
|
|
||||||
areas.hud = {}
|
areas.hud = {}
|
||||||
|
|
||||||
|
local vround = vector.round
|
||||||
|
local tconcat = table.concat
|
||||||
|
|
||||||
hud.register("areas", {
|
hud.register("areas", {
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
position = {x = 0, y = 1},
|
position = {x = 0, y = 1},
|
||||||
|
@ -18,7 +21,7 @@ minetest.register_playerstep(function(_, playernames)
|
||||||
for _, name in pairs(playernames) do
|
for _, name in pairs(playernames) do
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
if not player or not player:is_player() then return end
|
if not player or not player:is_player() then return end
|
||||||
local pos = vector.round(player:get_pos())
|
local pos = vround(player:get_pos())
|
||||||
if minetest.is_valid_pos(pos) then
|
if minetest.is_valid_pos(pos) then
|
||||||
local areaStrings = {}
|
local areaStrings = {}
|
||||||
|
|
||||||
|
@ -40,7 +43,7 @@ minetest.register_playerstep(function(_, playernames)
|
||||||
if #areaStrings > 0 then
|
if #areaStrings > 0 then
|
||||||
areaString = S("Areas:")
|
areaString = S("Areas:")
|
||||||
areaString = areaString .. "\n" ..
|
areaString = areaString .. "\n" ..
|
||||||
table.concat(areaStrings, "\n")
|
tconcat(areaStrings, "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
local phud = areas.hud[name] or {}
|
local phud = areas.hud[name] or {}
|
||||||
|
|
14
init.lua
14
init.lua
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
areas = {}
|
areas = {}
|
||||||
|
|
||||||
areas.adminPrivs = {areas=true}
|
areas.S = intllib.make_gettext_pair()
|
||||||
|
|
||||||
|
areas.adminPrivs = {areas = true}
|
||||||
areas.startTime = os.clock()
|
areas.startTime = os.clock()
|
||||||
|
|
||||||
areas.modpath = minetest.get_modpath("areas")
|
areas.modpath = minetest.get_modpath("areas")
|
||||||
|
@ -19,16 +21,20 @@ dofile(areas.modpath.."/protector.lua")
|
||||||
|
|
||||||
areas:load()
|
areas:load()
|
||||||
|
|
||||||
|
local S = areas.S
|
||||||
|
|
||||||
minetest.register_privilege("areas", {
|
minetest.register_privilege("areas", {
|
||||||
description = "Can administer areas."
|
description = S("Can administer areas."),
|
||||||
|
give_to_singleplayer = false
|
||||||
})
|
})
|
||||||
minetest.register_privilege("areas_high_limit", {
|
minetest.register_privilege("areas_high_limit", {
|
||||||
description = "Can protect more, bigger areas."
|
description = S("Can protect more, bigger areas."),
|
||||||
|
give_to_singleplayer = false
|
||||||
})
|
})
|
||||||
|
|
||||||
if not minetest.registered_privileges[areas.config.self_protection_privilege] then
|
if not minetest.registered_privileges[areas.config.self_protection_privilege] then
|
||||||
minetest.register_privilege(areas.config.self_protection_privilege, {
|
minetest.register_privilege(areas.config.self_protection_privilege, {
|
||||||
description = "Can protect areas.",
|
description = S("Can protect areas."),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local S = intllib.make_gettext_pair()
|
local S = areas.S
|
||||||
|
|
||||||
local old_is_protected = minetest.is_protected
|
local old_is_protected = minetest.is_protected
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ minetest.register_on_protection_violation(function(pos, name)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
if player and player:is_player() then
|
if player and player:is_player() then
|
||||||
local hp = player:get_hp()
|
local hp = player:get_hp()
|
||||||
if hp and hp > 1 then
|
if hp and hp > 2 then
|
||||||
player:set_hp(hp - 1)
|
player:set_hp(hp - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local S = intllib.make_gettext_pair()
|
local S = areas.S
|
||||||
|
|
||||||
function areas:player_exists(name)
|
function areas:player_exists(name)
|
||||||
return minetest.get_auth_handler().get_auth(name) ~= nil
|
return minetest.get_auth_handler().get_auth(name) ~= nil
|
||||||
|
@ -159,7 +159,6 @@ function areas:move(id, area, pos1, pos2)
|
||||||
area.pos1 = pos1
|
area.pos1 = pos1
|
||||||
area.pos2 = pos2
|
area.pos2 = pos2
|
||||||
|
|
||||||
|
|
||||||
for i=1, #areas.registered_on_moves do
|
for i=1, #areas.registered_on_moves do
|
||||||
areas.registered_on_moves[i](id, area, pos1, pos2)
|
areas.registered_on_moves[i](id, area, pos1, pos2)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<NewOwner>=<НовыйВладелец>
|
<NewOwner>=<НовыйВладелец>
|
||||||
<ParentID>=<РодственныйID>
|
<ParentID>=<РодственныйID>
|
||||||
<PlayerName>=<ИмяИгрока>
|
<PlayerName>=<ИмяИгрока>
|
||||||
<NewName>=<НовоеИмя>
|
<newName>=<НовоеИмя>
|
||||||
@1 has given you control over the area "@2" (ID @3).=@1 дал вам контроль над областью "@2" (ID @3).
|
@1 has given you control over the area "@2" (ID @3).=@1 дал вам контроль над областью "@2" (ID @3).
|
||||||
@1 spanning up to @2x@3x@4.=@1 охватывает до @2x@3x@4.
|
@1 spanning up to @2x@3x@4.=@1 охватывает до @2x@3x@4.
|
||||||
A regular expression is required.=Требуется регулярное выражение.
|
A regular expression is required.=Требуется регулярное выражение.
|
||||||
|
@ -43,6 +43,7 @@ Recursively remove areas using an ID=Рекурсивно удаляет зон
|
||||||
Remove an area using an ID=Удаляет зону используя её ID
|
Remove an area using an ID=Удаляет зону используя её ID
|
||||||
Removed area @1=Удалена зона @1
|
Removed area @1=Удалена зона @1
|
||||||
Removed area @1 and it's sub areas.=Удалена зона @1 и её подзоны.
|
Removed area @1 and it's sub areas.=Удалена зона @1 и её подзоны.
|
||||||
|
Removes all ownerless areas=Удаляет все бесхозные зоны
|
||||||
Rename an area that you own=Переименовывает зону которой вы владеете
|
Rename an area that you own=Переименовывает зону которой вы владеете
|
||||||
Self protection is disabled.=Защита отключена.
|
Self protection is disabled.=Защита отключена.
|
||||||
Self protection is enabled.=Защита включена.
|
Self protection is enabled.=Защита включена.
|
||||||
|
@ -114,5 +115,5 @@ Unknown subcommand: @1=Неизвестная подкоманда: @1
|
||||||
Protector Block=Защитный Блок
|
Protector Block=Защитный Блок
|
||||||
You are not allowed to protect that area: @1=Вам не разрешено защищать эту область: @1
|
You are not allowed to protect that area: @1=Вам не разрешено защищать эту область: @1
|
||||||
You have already protected this area.=Вы уже защитили эту область.
|
You have already protected this area.=Вы уже защитили эту область.
|
||||||
The area from @1 to @1 has been protected as ID @1=Зона от @1 до @1 была защищена, ID @1
|
The area from @1 to @2 has been protected as ID @3=Зона от @1 до @2 была защищена, ID @3
|
||||||
Protected area @1, Owned by @1=Защищённая зона @1, Владелец: @1
|
Protected area @1, Owned by @2=Защищённая зона @1, Владелец: @2
|
||||||
|
|
2
pos.lua
2
pos.lua
|
@ -1,4 +1,4 @@
|
||||||
local S = intllib.make_gettext_pair()
|
local S = areas.S
|
||||||
|
|
||||||
-- I could depend on WorldEdit for this, but you need to have the 'worldedit'
|
-- I could depend on WorldEdit for this, but you need to have the 'worldedit'
|
||||||
-- permission to use those commands and you don't have
|
-- permission to use those commands and you don't have
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local S = intllib.make_gettext_pair()
|
local S = areas.S
|
||||||
|
|
||||||
local radius = minetest.settings:get("areasprotector_radius") or 8
|
local radius = minetest.settings:get("areasprotector_radius") or 8
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ minetest.register_node("areas:protector", {
|
||||||
local id = areas:add(name, S("Protector Block"), pos1, pos2)
|
local id = areas:add(name, S("Protector Block"), pos1, pos2)
|
||||||
areas:save()
|
areas:save()
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
(S("The area from @1 to @1 has been protected as ID @1",
|
(S("The area from @1 to @2 has been protected as ID @3",
|
||||||
cyan(minetest.pos_to_string(pos1)), cyan(minetest.pos_to_string(pos2)), cyan(id))))
|
cyan(minetest.pos_to_string(pos1)), cyan(minetest.pos_to_string(pos2)), cyan(id))))
|
||||||
minetest.set_node(pos, {name = "areas:protector"})
|
minetest.set_node(pos, {name = "areas:protector"})
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", (S("Protected area @1, Owned by @1", id, name)))
|
meta:set_string("infotext", S("Protected area @1, Owned by @2", id, name))
|
||||||
meta:set_int("area_id", id)
|
meta:set_int("area_id", id)
|
||||||
meta:set_string("owner", name)
|
meta:set_string("owner", name)
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
|
Loading…
Reference in New Issue