mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-22 12:52:22 +01:00
Add translation support
This commit is contained in:
parent
aca830fd22
commit
4179917eb4
@ -9,7 +9,6 @@ read_globals = {
|
|||||||
"VoxelManip", "VoxelArea",
|
"VoxelManip", "VoxelArea",
|
||||||
"PseudoRandom", "ItemStack",
|
"PseudoRandom", "ItemStack",
|
||||||
"AreaStore",
|
"AreaStore",
|
||||||
"intllib",
|
|
||||||
"default",
|
"default",
|
||||||
table = { fields = { "copy", "getn" } }
|
table = { fields = { "copy", "getn" } }
|
||||||
}
|
}
|
||||||
|
242
chatcommands.lua
242
chatcommands.lua
@ -1,15 +1,16 @@
|
|||||||
|
local S = minetest.get_translator("areas")
|
||||||
|
|
||||||
minetest.register_chatcommand("protect", {
|
minetest.register_chatcommand("protect", {
|
||||||
params = "<AreaName>",
|
params = S("<AreaName>"),
|
||||||
description = "Protect your own area",
|
description = S("Protect your own area"),
|
||||||
privs = {[areas.config.self_protection_privilege]=true},
|
privs = {[areas.config.self_protection_privilege]=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if param == "" then
|
if param == "" then
|
||||||
return false, "Invalid usage, see /help protect."
|
return false, S("Invalid usage, see /help @1.", "protect")
|
||||||
end
|
end
|
||||||
local pos1, pos2 = areas:getPos(name)
|
local pos1, pos2 = areas:getPos(name)
|
||||||
if not (pos1 and pos2) then
|
if not (pos1 and pos2) then
|
||||||
return false, "You need to select an area first."
|
return false, S("You need to select an area first.")
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.log("action", "/protect invoked, owner="..name..
|
minetest.log("action", "/protect invoked, owner="..name..
|
||||||
@ -19,38 +20,37 @@ minetest.register_chatcommand("protect", {
|
|||||||
|
|
||||||
local canAdd, errMsg = areas:canPlayerAddArea(pos1, pos2, name)
|
local canAdd, errMsg = areas:canPlayerAddArea(pos1, pos2, name)
|
||||||
if not canAdd then
|
if not canAdd then
|
||||||
return false, "You can't protect that area: "..errMsg
|
return false, S("You can't protect that area: @1", errMsg)
|
||||||
end
|
end
|
||||||
|
|
||||||
local id = areas:add(name, param, pos1, pos2, nil)
|
local id = areas:add(name, param, pos1, pos2, nil)
|
||||||
areas:save()
|
areas:save()
|
||||||
|
|
||||||
return true, "Area protected. ID: "..id
|
return true, S("Area protected. ID: @1", id)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("set_owner", {
|
minetest.register_chatcommand("set_owner", {
|
||||||
params = "<PlayerName> <AreaName>",
|
params = S("<PlayerName>").." "..S("<AreaName>"),
|
||||||
description = "Protect an area beetween two positions and give"
|
description = S("Protect an area beetween two positions and give"
|
||||||
.." a player access to it without setting the parent of the"
|
.." a player access to it without setting the parent of the"
|
||||||
.." area to any existing area",
|
.." area to any existing area"),
|
||||||
privs = areas.adminPrivs,
|
privs = areas.adminPrivs,
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local ownerName, areaName = param:match('^(%S+)%s(.+)$')
|
local ownerName, areaName = param:match('^(%S+)%s(.+)$')
|
||||||
|
|
||||||
if not ownerName then
|
if not ownerName then
|
||||||
return false, "Incorrect usage, see /help set_owner."
|
return false, S("Invalid usage, see /help @1.", "set_owner")
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos1, pos2 = areas:getPos(name)
|
local pos1, pos2 = areas:getPos(name)
|
||||||
if not (pos1 and pos2) then
|
if not (pos1 and pos2) then
|
||||||
return false, "You need to select an area first."
|
return false, S("You need to select an area first.")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not areas:player_exists(ownerName) then
|
if not areas:player_exists(ownerName) then
|
||||||
return false, "The player \""
|
return false, S("The player \"@1\" does not exist.", ownerName)
|
||||||
..ownerName.."\" does not exist."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.log("action", name.." runs /set_owner. Owner = "..ownerName..
|
minetest.log("action", name.." runs /set_owner. Owner = "..ownerName..
|
||||||
@ -62,34 +62,34 @@ minetest.register_chatcommand("set_owner", {
|
|||||||
areas:save()
|
areas:save()
|
||||||
|
|
||||||
minetest.chat_send_player(ownerName,
|
minetest.chat_send_player(ownerName,
|
||||||
"You have been granted control over area #"..
|
S("You have been granted control over area #@1. "..
|
||||||
id..". Type /list_areas to show your areas.")
|
"Type /list_areas to show your areas.", id))
|
||||||
return true, "Area protected. ID: "..id
|
return true, S("Area protected. ID: @1", id)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("add_owner", {
|
minetest.register_chatcommand("add_owner", {
|
||||||
params = "<ParentID> <Player> <AreaName>",
|
params = S("<ParentID>").." "..S("<PlayerName>").." "..S("<AreaName>"),
|
||||||
description = "Give a player access to a sub-area beetween two"
|
description = S("Give a player access to a sub-area beetween two"
|
||||||
.." 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, "Incorrect usage, see /help add_owner")
|
minetest.chat_send_player(name, S("Invalid usage, see /help @1.", "add_owner"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos1, pos2 = areas:getPos(name)
|
local pos1, pos2 = areas:getPos(name)
|
||||||
if not (pos1 and pos2) then
|
if not (pos1 and pos2) then
|
||||||
return false, "You need to select an area first."
|
return false, S("You need to select an area first.")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not areas:player_exists(ownerName) then
|
if not areas:player_exists(ownerName) then
|
||||||
return false, "The player \""..ownerName.."\" does not exist."
|
return false, S("The player \"@1\" does not exist.", ownerName)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.log("action", name.." runs /add_owner. Owner = "..ownerName..
|
minetest.log("action", name.." runs /add_owner. Owner = "..ownerName..
|
||||||
@ -101,52 +101,52 @@ minetest.register_chatcommand("add_owner", {
|
|||||||
pid = tonumber(pid)
|
pid = tonumber(pid)
|
||||||
if (not areas:isAreaOwner(pid, name)) or
|
if (not areas:isAreaOwner(pid, name)) or
|
||||||
(not areas:isSubarea(pos1, pos2, pid)) then
|
(not areas:isSubarea(pos1, pos2, pid)) then
|
||||||
return false, "You can't protect that area."
|
return false, S("You can't protect that area.")
|
||||||
end
|
end
|
||||||
|
|
||||||
local id = areas:add(ownerName, areaName, pos1, pos2, pid)
|
local id = areas:add(ownerName, areaName, pos1, pos2, pid)
|
||||||
areas:save()
|
areas:save()
|
||||||
|
|
||||||
minetest.chat_send_player(ownerName,
|
minetest.chat_send_player(ownerName,
|
||||||
"You have been granted control over area #"..
|
S("You have been granted control over area #@1. "..
|
||||||
id..". Type /list_areas to show your areas.")
|
"Type /list_areas to show your areas.", id))
|
||||||
return true, "Area protected. ID: "..id
|
return true, S("Area protected. ID: @1", id)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("rename_area", {
|
minetest.register_chatcommand("rename_area", {
|
||||||
params = "<ID> <newName>",
|
params = S("<ID>").." "..S("<newName>"),
|
||||||
description = "Rename a area that you own",
|
description = S("Rename a 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(.+)$")
|
||||||
if not id then
|
if not id then
|
||||||
return false, "Invalid usage, see /help rename_area."
|
return false, S("Invalid usage, see /help @1.", "rename_area")
|
||||||
end
|
end
|
||||||
|
|
||||||
id = tonumber(id)
|
id = tonumber(id)
|
||||||
if not id then
|
if not id then
|
||||||
return false, "That area doesn't exist."
|
return false, S("That area doesn't exist.")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not areas:isAreaOwner(id, name) then
|
if not areas:isAreaOwner(id, name) then
|
||||||
return true, "You don't own that area."
|
return true, S("You don't own that area.")
|
||||||
end
|
end
|
||||||
|
|
||||||
areas.areas[id].name = newName
|
areas.areas[id].name = newName
|
||||||
areas:save()
|
areas:save()
|
||||||
return true, "Area renamed."
|
return true, S("Area renamed.")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("find_areas", {
|
minetest.register_chatcommand("find_areas", {
|
||||||
params = "<regexp>",
|
params = S("<regexp>"),
|
||||||
description = "Find areas using a Lua regular expression",
|
description = S("Find areas using a Lua regular expression"),
|
||||||
privs = areas.adminPrivs,
|
privs = areas.adminPrivs,
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if param == "" then
|
if param == "" then
|
||||||
return false, "A regular expression is required."
|
return false, S("A regular expression is required.")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check expression for validity
|
-- Check expression for validity
|
||||||
@ -154,7 +154,7 @@ minetest.register_chatcommand("find_areas", {
|
|||||||
("Test [1]: Player (0,0,0) (0,0,0)"):find(param)
|
("Test [1]: Player (0,0,0) (0,0,0)"):find(param)
|
||||||
end
|
end
|
||||||
if not pcall(testRegExp) then
|
if not pcall(testRegExp) then
|
||||||
return false, "Invalid regular expression."
|
return false, S("Invalid regular expression.")
|
||||||
end
|
end
|
||||||
|
|
||||||
local matches = {}
|
local matches = {}
|
||||||
@ -167,14 +167,14 @@ minetest.register_chatcommand("find_areas", {
|
|||||||
if #matches > 0 then
|
if #matches > 0 then
|
||||||
return true, table.concat(matches, "\n")
|
return true, table.concat(matches, "\n")
|
||||||
else
|
else
|
||||||
return true, "No matches found."
|
return true, S("No matches found.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("list_areas", {
|
minetest.register_chatcommand("list_areas", {
|
||||||
description = "List your areas, or all areas if you are an admin.",
|
description = S("List your areas, or all areas if you are an admin."),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local admin = minetest.check_player_privs(name, areas.adminPrivs)
|
local admin = minetest.check_player_privs(name, areas.adminPrivs)
|
||||||
local areaStrings = {}
|
local areaStrings = {}
|
||||||
@ -184,7 +184,7 @@ minetest.register_chatcommand("list_areas", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #areaStrings == 0 then
|
if #areaStrings == 0 then
|
||||||
return true, "No visible areas."
|
return true, S("No visible areas.")
|
||||||
end
|
end
|
||||||
return true, table.concat(areaStrings, "\n")
|
return true, table.concat(areaStrings, "\n")
|
||||||
end
|
end
|
||||||
@ -192,154 +192,154 @@ minetest.register_chatcommand("list_areas", {
|
|||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("recursive_remove_areas", {
|
minetest.register_chatcommand("recursive_remove_areas", {
|
||||||
params = "<id>",
|
params = S("<ID>"),
|
||||||
description = "Recursively remove areas using an id",
|
description = S("Recursively remove areas using an id"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local id = tonumber(param)
|
local id = tonumber(param)
|
||||||
if not id then
|
if not id then
|
||||||
return false, "Invalid usage, see"
|
return false, S("Invalid usage, see"
|
||||||
.." /help recursive_remove_areas"
|
.." /help @1.", "recursive_remove_areas")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not areas:isAreaOwner(id, name) then
|
if not areas:isAreaOwner(id, name) then
|
||||||
return false, "Area "..id.." does not exist or is"
|
return false, S("Area @1 does not exist or is"
|
||||||
.." not owned by you."
|
.." not owned by you.", id)
|
||||||
end
|
end
|
||||||
|
|
||||||
areas:remove(id, true)
|
areas:remove(id, true)
|
||||||
areas:save()
|
areas:save()
|
||||||
return true, "Removed area "..id.." and it's sub areas."
|
return true, S("Removed area @1 and it's sub areas.", id)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("remove_area", {
|
minetest.register_chatcommand("remove_area", {
|
||||||
params = "<id>",
|
params = S("<ID>"),
|
||||||
description = "Remove an area using an id",
|
description = S("Remove an area using an id"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local id = tonumber(param)
|
local id = tonumber(param)
|
||||||
if not id then
|
if not id then
|
||||||
return false, "Invalid usage, see /help remove_area"
|
return false, S("Invalid usage, see /help @1.", "remove_area")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not areas:isAreaOwner(id, name) then
|
if not areas:isAreaOwner(id, name) then
|
||||||
return false, "Area "..id.." does not exist or"
|
return false, S("Area @1 does not exist or"
|
||||||
.." is not owned by you."
|
.." is not owned by you.", id)
|
||||||
end
|
end
|
||||||
|
|
||||||
areas:remove(id)
|
areas:remove(id)
|
||||||
areas:save()
|
areas:save()
|
||||||
return true, "Removed area "..id
|
return true, S("Removed area @1", id)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("change_owner", {
|
minetest.register_chatcommand("change_owner", {
|
||||||
params = "<ID> <NewOwner>",
|
params = S("<ID>").." "..S("<NewOwner>"),
|
||||||
description = "Change the owner of an area using it's ID",
|
description = S("Change the owner of an area using it's ID"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local id, newOwner = param:match("^(%d+)%s(%S+)$")
|
local id, newOwner = param:match("^(%d+)%s(%S+)$")
|
||||||
if not id then
|
if not id then
|
||||||
return false, "Invalid usage, see"
|
return false, S("Invalid usage, see"
|
||||||
.." /help change_owner."
|
.." /help @1.", "change_owner")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not areas:player_exists(newOwner) then
|
if not areas:player_exists(newOwner) then
|
||||||
return false, "The player \""..newOwner
|
return false, S("The player \"@1\" does not exist.", newOwner)
|
||||||
.."\" does not exist."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
id = tonumber(id)
|
id = tonumber(id)
|
||||||
if not areas:isAreaOwner(id, name) then
|
if not areas:isAreaOwner(id, name) then
|
||||||
return false, "Area "..id.." does not exist"
|
return false, S("Area @1 does not exist"
|
||||||
.." or is not owned by you."
|
.." or is not owned by you.", id)
|
||||||
end
|
end
|
||||||
areas.areas[id].owner = newOwner
|
areas.areas[id].owner = newOwner
|
||||||
areas:save()
|
areas:save()
|
||||||
minetest.chat_send_player(newOwner,
|
minetest.chat_send_player(newOwner,
|
||||||
("%s has given you control over the area %q (ID %d).")
|
S("@1 has given you control over the area \"@2\" (ID @3).",
|
||||||
:format(name, areas.areas[id].name, id))
|
name, areas.areas[id].name, id))
|
||||||
return true, "Owner changed."
|
return true, S("Owner changed.")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("area_open", {
|
minetest.register_chatcommand("area_open", {
|
||||||
params = "<ID>",
|
params = S("<ID>"),
|
||||||
description = "Toggle an area open (anyone can interact) or closed",
|
description = S("Toggle an area open (anyone can interact) or closed"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local id = tonumber(param)
|
local id = tonumber(param)
|
||||||
if not id then
|
if not id then
|
||||||
return false, "Invalid usage, see /help area_open."
|
return false, S("Invalid usage, see /help @1.", "area_open")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not areas:isAreaOwner(id, name) then
|
if not areas:isAreaOwner(id, name) then
|
||||||
return false, "Area "..id.." does not exist"
|
return false, S("Area @1 does not exist"
|
||||||
.." or is not owned by you."
|
.." or is not owned by you.", id)
|
||||||
end
|
end
|
||||||
local open = not areas.areas[id].open
|
local open = not areas.areas[id].open
|
||||||
-- Save false as nil to avoid inflating the DB.
|
-- Save false as nil to avoid inflating the DB.
|
||||||
areas.areas[id].open = open or nil
|
areas.areas[id].open = open or nil
|
||||||
areas:save()
|
areas:save()
|
||||||
return true, ("Area %s."):format(open and "opened" or "closed")
|
return true, open and S("Area opened.") or S("Area closed.")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
if areas.factions_available then
|
if areas.factions_available then
|
||||||
minetest.register_chatcommand("area_faction_open", {
|
minetest.register_chatcommand("area_faction_open", {
|
||||||
params = "<ID>",
|
params = S("<ID>"),
|
||||||
description = "Toggle an area open/closed for members in your faction.",
|
description = S("Toggle an area open/closed for members in your faction."),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local id = tonumber(param)
|
local id = tonumber(param)
|
||||||
if not id then
|
if not id then
|
||||||
return false, "Invalid usage, see /help area_faction_open."
|
return false, S("Invalid usage, see /help @1.", "area_faction_open")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not areas:isAreaOwner(id, name) then
|
if not areas:isAreaOwner(id, name) then
|
||||||
return false, "Area "..id.." does not exist"
|
return false, S("Area @1 does not exist"
|
||||||
.." or is not owned by you."
|
.." or is not owned by you.", id)
|
||||||
end
|
end
|
||||||
local open = not areas.areas[id].faction_open
|
local open = not areas.areas[id].faction_open
|
||||||
-- Save false as nil to avoid inflating the DB.
|
-- Save false as nil to avoid inflating the DB.
|
||||||
areas.areas[id].faction_open = open or nil
|
areas.areas[id].faction_open = open or nil
|
||||||
areas:save()
|
areas:save()
|
||||||
return true, ("Area %s for faction members."):format(open and "opened" or "closed")
|
return true, open and S("Area opened for faction members.")
|
||||||
|
or S("Area closed for faction members.")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("move_area", {
|
minetest.register_chatcommand("move_area", {
|
||||||
params = "<ID>",
|
params = S("<ID>"),
|
||||||
description = "Move (or resize) an area to the current positions.",
|
description = S("Move (or resize) an area to the current positions."),
|
||||||
privs = areas.adminPrivs,
|
privs = areas.adminPrivs,
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local id = tonumber(param)
|
local id = tonumber(param)
|
||||||
if not id then
|
if not id then
|
||||||
return false, "Invalid usage, see /help move_area."
|
return false, S("Invalid usage, see /help @1.", "move_area")
|
||||||
end
|
end
|
||||||
|
|
||||||
local area = areas.areas[id]
|
local area = areas.areas[id]
|
||||||
if not area then
|
if not area then
|
||||||
return false, "Area does not exist."
|
return false, S("Area does not exist.")
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos1, pos2 = areas:getPos(name)
|
local pos1, pos2 = areas:getPos(name)
|
||||||
if not pos1 then
|
if not pos1 then
|
||||||
return false, "You need to select an area first."
|
return false, S("You need to select an area first.")
|
||||||
end
|
end
|
||||||
|
|
||||||
areas:move(id, area, pos1, pos2)
|
areas:move(id, area, pos1, pos2)
|
||||||
areas:save()
|
areas:save()
|
||||||
|
|
||||||
return true, "Area successfully moved."
|
return true, S("Area successfully moved.")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("area_info", {
|
minetest.register_chatcommand("area_info", {
|
||||||
description = "Get information about area configuration and usage.",
|
description = S("Get information about area configuration and usage."),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local lines = {}
|
local lines = {}
|
||||||
local privs = minetest.get_player_privs(name)
|
local privs = minetest.get_player_privs(name)
|
||||||
@ -362,26 +362,33 @@ minetest.register_chatcommand("area_info", {
|
|||||||
size_limit_high or size_limit
|
size_limit_high or size_limit
|
||||||
|
|
||||||
-- Privilege information
|
-- Privilege information
|
||||||
local self_prot_line = ("Self protection is %sabled"):format(
|
local self_prot_line = (self_prot and prot_priv) and
|
||||||
self_prot and "en" or "dis")
|
(has_prot_priv and
|
||||||
if self_prot and prot_priv then
|
(self_prot and
|
||||||
self_prot_line = self_prot_line..
|
S("Self protection is enabled and you have the "..
|
||||||
(" %s have the neccessary privilege (%q).")
|
"necessary privilege (\"@1\").", prot_priv) or
|
||||||
:format(
|
S("Self protection is disabled and you have the "..
|
||||||
has_prot_priv and "and you" or
|
"necessary privilege (\"@1\").", prot_priv)
|
||||||
"but you don't",
|
) or
|
||||||
prot_priv)
|
(self_prot and
|
||||||
else
|
S("Self protection is enabled but you don't have the "..
|
||||||
self_prot_line = self_prot_line.."."
|
"necessary privilege (\"@1\").", prot_priv) or
|
||||||
end
|
S("Self protection is disabled but you don't have the "..
|
||||||
|
"necessary privilege (\"@1\").", prot_priv)
|
||||||
|
)
|
||||||
|
) or
|
||||||
|
(self_prot and
|
||||||
|
S("Self protection is enabled.") or
|
||||||
|
S("Self protection is disabled.")
|
||||||
|
)
|
||||||
table.insert(lines, self_prot_line)
|
table.insert(lines, self_prot_line)
|
||||||
if privs.areas then
|
if privs.areas then
|
||||||
table.insert(lines, "You are an area"..
|
table.insert(lines, S("You are an area"..
|
||||||
" administrator (\"areas\" privilege).")
|
" administrator (\"areas\" privilege)."))
|
||||||
elseif has_high_limit then
|
elseif has_high_limit then
|
||||||
table.insert(lines,
|
table.insert(lines,
|
||||||
"You have extended area protection"..
|
S("You have extended area protection"..
|
||||||
" limits (\"areas_high_limit\" privilege).")
|
" limits (\"areas_high_limit\" privilege)."))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Area count
|
-- Area count
|
||||||
@ -391,26 +398,35 @@ minetest.register_chatcommand("area_info", {
|
|||||||
area_num = area_num + 1
|
area_num = area_num + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local count_line = ("You have %d area%s"):format(
|
local count_line = privs.areas and
|
||||||
area_num, area_num == 1 and "" or "s")
|
((area_num <= 1) and
|
||||||
if privs.areas then
|
S("You have @1 area and have no area "..
|
||||||
count_line = count_line..
|
"protection limits.", area_num) or
|
||||||
" and have no area protection limits."
|
S("You have @1 areas and have no area "..
|
||||||
elseif can_prot then
|
"protection limits.", area_num)
|
||||||
count_line = count_line..(", out of a maximum of %d.")
|
) or
|
||||||
:format(max_count)
|
(can_prot and (
|
||||||
end
|
(area_num <= 1) and
|
||||||
|
S("You have @1 area, out of a "..
|
||||||
|
"maximum of @2.", area_num, max_count) or
|
||||||
|
S("You have @1 areas, out of a "..
|
||||||
|
"maximum of @2.", area_num, max_count)
|
||||||
|
) or
|
||||||
|
(area_num <= 1) and
|
||||||
|
S("You have @1 area.", area_num) or
|
||||||
|
S("You have @1 areas.", area_num)
|
||||||
|
)
|
||||||
table.insert(lines, count_line)
|
table.insert(lines, count_line)
|
||||||
|
|
||||||
-- Area size limits
|
-- Area size limits
|
||||||
local function size_info(str, size)
|
local function size_info(str, size)
|
||||||
table.insert(lines, ("%s spanning up to %dx%dx%d.")
|
table.insert(lines, S("@1 spanning up to @2x@3x@4.",
|
||||||
:format(str, size.x, size.y, size.z))
|
str, size.x, size.y, size.z))
|
||||||
end
|
end
|
||||||
local function priv_limit_info(lpriv, lmax_count, lmax_size)
|
local function priv_limit_info(lpriv, lmax_count, lmax_size)
|
||||||
size_info(("Players with the %q privilege"..
|
size_info(S("Players with the \"@1\" privilege"..
|
||||||
" can protect up to %d areas"):format(
|
" can protect up to @2 areas", lpriv, lmax_count),
|
||||||
lpriv, lmax_count), lmax_size)
|
lmax_size)
|
||||||
end
|
end
|
||||||
if self_prot then
|
if self_prot then
|
||||||
if privs.areas then
|
if privs.areas then
|
||||||
@ -419,7 +435,7 @@ minetest.register_chatcommand("area_info", {
|
|||||||
priv_limit_info("areas_high_limit",
|
priv_limit_info("areas_high_limit",
|
||||||
limit_high, size_limit_high)
|
limit_high, size_limit_high)
|
||||||
elseif has_prot_priv then
|
elseif has_prot_priv then
|
||||||
size_info("You can protect areas", max_size)
|
size_info(S("You can protect areas"), max_size)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
6
hud.lua
6
hud.lua
@ -1,5 +1,5 @@
|
|||||||
-- This is inspired by the landrush mod by Bremaweb
|
-- This is inspired by the landrush mod by Bremaweb
|
||||||
|
local S = minetest.get_translator("areas")
|
||||||
areas.hud = {}
|
areas.hud = {}
|
||||||
areas.hud.refresh = 0
|
areas.hud.refresh = 0
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
area.faction_open = faction_info
|
area.faction_open = faction_info
|
||||||
table.insert(areaStrings, ("%s [%u] (%s%s%s)")
|
table.insert(areaStrings, ("%s [%u] (%s%s%s)")
|
||||||
:format(area.name, id, area.owner,
|
:format(area.name, id, area.owner,
|
||||||
area.open and ":open" or "",
|
area.open and S(":open") or "",
|
||||||
faction_info and ":"..faction_info or ""))
|
faction_info and ":"..faction_info or ""))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
table.insert(areaStrings, str)
|
table.insert(areaStrings, str)
|
||||||
end
|
end
|
||||||
|
|
||||||
local areaString = "Areas:"
|
local areaString = S("Areas:")
|
||||||
if #areaStrings > 0 then
|
if #areaStrings > 0 then
|
||||||
areaString = areaString.."\n"..
|
areaString = areaString.."\n"..
|
||||||
table.concat(areaStrings, "\n")
|
table.concat(areaStrings, "\n")
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
local S = minetest.get_translator("areas")
|
||||||
|
|
||||||
local old_is_protected = minetest.is_protected
|
local old_is_protected = minetest.is_protected
|
||||||
function minetest.is_protected(pos, name)
|
function minetest.is_protected(pos, name)
|
||||||
@ -11,7 +12,7 @@ minetest.register_on_protection_violation(function(pos, name)
|
|||||||
if not areas:canInteract(pos, name) then
|
if not areas:canInteract(pos, name) then
|
||||||
local owners = areas:getNodeOwners(pos)
|
local owners = areas:getNodeOwners(pos)
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
("%s is protected by %s."):format(
|
S("@1 is protected by @2.",
|
||||||
minetest.pos_to_string(pos),
|
minetest.pos_to_string(pos),
|
||||||
table.concat(owners, ", ")))
|
table.concat(owners, ", ")))
|
||||||
end
|
end
|
||||||
|
15
internal.lua
15
internal.lua
@ -1,3 +1,4 @@
|
|||||||
|
local S = minetest.get_translator("areas")
|
||||||
|
|
||||||
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
|
||||||
@ -212,8 +213,8 @@ function areas:canPlayerAddArea(pos1, pos2, name)
|
|||||||
-- and if the area is too big.
|
-- and if the area is too big.
|
||||||
if not self.config.self_protection or
|
if not self.config.self_protection or
|
||||||
not privs[areas.config.self_protection_privilege] then
|
not privs[areas.config.self_protection_privilege] then
|
||||||
return false, "Self protection is disabled or you do not have"
|
return false, S("Self protection is disabled or you do not have"
|
||||||
.." the necessary privilege."
|
.." the necessary privilege.")
|
||||||
end
|
end
|
||||||
|
|
||||||
local max_size = privs.areas_high_limit and
|
local max_size = privs.areas_high_limit and
|
||||||
@ -223,7 +224,7 @@ function areas:canPlayerAddArea(pos1, pos2, name)
|
|||||||
(pos2.x - pos1.x) > max_size.x or
|
(pos2.x - pos1.x) > max_size.x or
|
||||||
(pos2.y - pos1.y) > max_size.y or
|
(pos2.y - pos1.y) > max_size.y or
|
||||||
(pos2.z - pos1.z) > max_size.z then
|
(pos2.z - pos1.z) > max_size.z then
|
||||||
return false, "Area is too big."
|
return false, S("Area is too big.")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check number of areas the user has and make sure it not above the max
|
-- Check number of areas the user has and make sure it not above the max
|
||||||
@ -237,16 +238,16 @@ function areas:canPlayerAddArea(pos1, pos2, name)
|
|||||||
self.config.self_protection_max_areas_high or
|
self.config.self_protection_max_areas_high or
|
||||||
self.config.self_protection_max_areas
|
self.config.self_protection_max_areas
|
||||||
if count >= max_areas then
|
if count >= max_areas then
|
||||||
return false, "You have reached the maximum amount of"
|
return false, S("You have reached the maximum amount of"
|
||||||
.." areas that you are allowed to protect."
|
.." areas that you are allowed to protect.")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check intersecting areas
|
-- Check intersecting areas
|
||||||
local can, id = self:canInteractInArea(pos1, pos2, name)
|
local can, id = self:canInteractInArea(pos1, pos2, name)
|
||||||
if not can then
|
if not can then
|
||||||
local area = self.areas[id]
|
local area = self.areas[id]
|
||||||
return false, ("The area intersects with %s [%u] (%s).")
|
return false, S("The area intersects with @1 [@2] (@3).",
|
||||||
:format(area.name, id, area.owner)
|
area.name, id, area.owner)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
23
legacy.lua
23
legacy.lua
@ -1,25 +1,26 @@
|
|||||||
-- This file contains functions to convert from
|
-- This file contains functions to convert from
|
||||||
-- the old areas format and other compatability code.
|
-- the old areas format and other compatability code.
|
||||||
|
local S = minetest.get_translator("areas")
|
||||||
|
|
||||||
minetest.register_chatcommand("legacy_load_areas", {
|
minetest.register_chatcommand("legacy_load_areas", {
|
||||||
params = "<version>",
|
params = S("<version>"),
|
||||||
description = "Loads, converts, and saves the areas from"
|
description = S("Loads, converts, and saves the areas from"
|
||||||
.." a legacy save file.",
|
.." a legacy save file."),
|
||||||
privs = {areas=true, server=true},
|
privs = {areas=true, server=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
minetest.chat_send_player(name, "Converting areas...")
|
minetest.chat_send_player(name, S("Converting areas…"))
|
||||||
local version = tonumber(param)
|
local version = tonumber(param)
|
||||||
if version == 0 then
|
if version == 0 then
|
||||||
local err = areas:node_ownership_load()
|
local err = areas:node_ownership_load()
|
||||||
if err then
|
if err then
|
||||||
minetest.chat_send_player(name, "Error loading legacy file: "..err)
|
minetest.chat_send_player(name, S("Error loading legacy file: @1", err))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, "Invalid version number. (0 allowed)")
|
minetest.chat_send_player(name, S("Invalid version number. (0 allowed)"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name, "Legacy file loaded.")
|
minetest.chat_send_player(name, S("Legacy file loaded."))
|
||||||
|
|
||||||
for k, area in pairs(areas.areas) do
|
for k, area in pairs(areas.areas) do
|
||||||
-- New position format
|
-- New position format
|
||||||
@ -34,15 +35,15 @@ minetest.register_chatcommand("legacy_load_areas", {
|
|||||||
areas:sortPos(area.pos1, area.pos2)
|
areas:sortPos(area.pos1, area.pos2)
|
||||||
|
|
||||||
-- Add name
|
-- Add name
|
||||||
area.name = "unnamed"
|
area.name = S("unnamed")
|
||||||
|
|
||||||
-- Remove ID
|
-- Remove ID
|
||||||
area.id = nil
|
area.id = nil
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name, "Table format updated.")
|
minetest.chat_send_player(name, S("Table format updated."))
|
||||||
|
|
||||||
areas:save()
|
areas:save()
|
||||||
minetest.chat_send_player(name, "Converted areas saved. Done.")
|
minetest.chat_send_player(name, S("Converted areas saved. Done."))
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ if areas.config.legacy_table then
|
|||||||
{x=a.x2, y=a.y2, z=a.z2}
|
{x=a.x2, y=a.y2, z=a.z2}
|
||||||
a.x1, a.y1, a.z1, a.x2, a.y2, a.z2 =
|
a.x1, a.y1, a.z1, a.x2, a.y2, a.z2 =
|
||||||
nil, nil, nil, nil, nil, nil
|
nil, nil, nil, nil, nil, nil
|
||||||
a.name = a.name or "unnamed"
|
a.name = a.name or S("unnamed")
|
||||||
a.id = nil
|
a.id = nil
|
||||||
return rawset(areas.areas, key, a)
|
return rawset(areas.areas, key, a)
|
||||||
end
|
end
|
||||||
|
137
locale/template.txt
Normal file
137
locale/template.txt
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
# textdomain: areas
|
||||||
|
|
||||||
|
|
||||||
|
### chatcommands.lua ###
|
||||||
|
|
||||||
|
<AreaName>=
|
||||||
|
<NewOwner>=
|
||||||
|
<ParentID>=
|
||||||
|
<PlayerName>=
|
||||||
|
<newName>=
|
||||||
|
<regexp>=
|
||||||
|
@1 has given you control over the area "@2" (ID @3).=
|
||||||
|
@1 spanning up to @2x@3x@4.=
|
||||||
|
A regular expression is required.=
|
||||||
|
Area @1 does not exist or is not owned by you.=
|
||||||
|
Area closed for faction members.=
|
||||||
|
Area closed.=
|
||||||
|
Area does not exist.=
|
||||||
|
Area opened for faction members.=
|
||||||
|
Area opened.=
|
||||||
|
Area protected. ID: @1=
|
||||||
|
Area renamed.=
|
||||||
|
Area successfully moved.=
|
||||||
|
Change the owner of an area using it's ID=
|
||||||
|
Find areas using a Lua regular expression=
|
||||||
|
Get information about area configuration and usage.=
|
||||||
|
|
||||||
|
Give a player access to a sub-area beetween two positions that have already been protected, Use set_owner if you don't want the parent to be set.=
|
||||||
|
|
||||||
|
Invalid regular expression.=
|
||||||
|
List your areas, or all areas if you are an admin.=
|
||||||
|
Move (or resize) an area to the current positions.=
|
||||||
|
No matches found.=
|
||||||
|
No visible areas.=
|
||||||
|
Owner changed.=
|
||||||
|
Players with the "@1" privilege can protect up to @2 areas=
|
||||||
|
|
||||||
|
Protect an area beetween two positions and give a player access to it without setting the parent of the area to any existing area=
|
||||||
|
|
||||||
|
Protect your own area=
|
||||||
|
Recursively remove areas using an id=
|
||||||
|
Remove an area using an id=
|
||||||
|
Removed area @1=
|
||||||
|
Removed area @1 and it's sub areas.=
|
||||||
|
Rename a area that you own=
|
||||||
|
|
||||||
|
Self protection is disabled and you have the necessary privilege ("@1").=
|
||||||
|
|
||||||
|
Self protection is disabled but you don't have the necessary privilege ("@1").=
|
||||||
|
|
||||||
|
Self protection is disabled.=
|
||||||
|
|
||||||
|
Self protection is enabled and you have the necessary privilege ("@1").=
|
||||||
|
|
||||||
|
Self protection is enabled but you don't have the necessary privilege ("@1").=
|
||||||
|
|
||||||
|
Self protection is enabled.=
|
||||||
|
That area doesn't exist.=
|
||||||
|
The player "@1" does not exist.=
|
||||||
|
Toggle an area open (anyone can interact) or closed=
|
||||||
|
Toggle an area open/closed for members in your faction.=
|
||||||
|
You are an area administrator ("areas" privilege).=
|
||||||
|
You can protect areas=
|
||||||
|
You can't protect that area.=
|
||||||
|
You can't protect that area: @1=
|
||||||
|
You don't own that area.=
|
||||||
|
You have @1 area and have no area protection limits.=
|
||||||
|
You have @1 area, out of a maximum of @2.=
|
||||||
|
You have @1 area.=
|
||||||
|
You have @1 areas and have no area protection limits.=
|
||||||
|
You have @1 areas, out of a maximum of @2.=
|
||||||
|
You have @1 areas.=
|
||||||
|
|
||||||
|
You have been granted control over area #@1. Type /list_areas to show your areas.=
|
||||||
|
|
||||||
|
You have extended area protection limits ("areas_high_limit" privilege).=
|
||||||
|
|
||||||
|
You need to select an area first.=
|
||||||
|
|
||||||
|
### chatcommands.lua ###
|
||||||
|
### pos.lua ###
|
||||||
|
|
||||||
|
<ID>=
|
||||||
|
Invalid usage, see /help @1.=
|
||||||
|
|
||||||
|
### hud.lua ###
|
||||||
|
|
||||||
|
:open=
|
||||||
|
Areas:=
|
||||||
|
|
||||||
|
### interact.lua ###
|
||||||
|
|
||||||
|
@1 is protected by @2.=
|
||||||
|
|
||||||
|
### internal.lua ###
|
||||||
|
|
||||||
|
Area is too big.=
|
||||||
|
|
||||||
|
Self protection is disabled or you do not have the necessary privilege.=
|
||||||
|
|
||||||
|
The area intersects with @1 [@2] (@3).=
|
||||||
|
|
||||||
|
You have reached the maximum amount of areas that you are allowed to protect.=
|
||||||
|
|
||||||
|
|
||||||
|
### legacy.lua ###
|
||||||
|
|
||||||
|
<version>=
|
||||||
|
Converted areas saved. Done.=
|
||||||
|
Converting areas…=
|
||||||
|
Error loading legacy file: @1=
|
||||||
|
Invalid version number. (0 allowed)=
|
||||||
|
Legacy file loaded.=
|
||||||
|
|
||||||
|
Loads, converts, and saves the areas from a legacy save file.=
|
||||||
|
|
||||||
|
Table format updated.=
|
||||||
|
unnamed=
|
||||||
|
|
||||||
|
### pos.lua ###
|
||||||
|
|
||||||
|
<not set>=
|
||||||
|
Area @1 selected.=
|
||||||
|
Area position @1 set to @2=
|
||||||
|
Position @1 set to @2=
|
||||||
|
Position @1: =
|
||||||
|
Select a area by id.=
|
||||||
|
Select position @1 by punching a node.=
|
||||||
|
Select positions by punching two nodes.=
|
||||||
|
|
||||||
|
Set area protection region position @1 to your location or the one specified=
|
||||||
|
|
||||||
|
Set area protection region, position 1, or position 2 by punching nodes, or display the region=
|
||||||
|
|
||||||
|
The area @1 does not exist.=
|
||||||
|
Unable to get position.=
|
||||||
|
Unknown subcommand: @1=
|
66
pos.lua
66
pos.lua
@ -1,4 +1,4 @@
|
|||||||
|
local S = minetest.get_translator("areas")
|
||||||
-- 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
|
||||||
-- /area_pos{1,2} [X Y Z|X,Y,Z].
|
-- /area_pos{1,2} [X Y Z|X,Y,Z].
|
||||||
@ -22,27 +22,27 @@ local function posLimit(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("select_area", {
|
minetest.register_chatcommand("select_area", {
|
||||||
params = "<ID>",
|
params = S("<ID>"),
|
||||||
description = "Select a area by id.",
|
description = S("Select a area by id."),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local id = tonumber(param)
|
local id = tonumber(param)
|
||||||
if not id then
|
if not id then
|
||||||
return false, "Invalid usage, see /help select_area."
|
return false, S("Invalid usage, see /help @1.", "select_area")
|
||||||
end
|
end
|
||||||
if not areas.areas[id] then
|
if not areas.areas[id] then
|
||||||
return false, "The area "..id.." does not exist."
|
return false, S("The area @1 does not exist.", id)
|
||||||
end
|
end
|
||||||
|
|
||||||
areas:setPos1(name, areas.areas[id].pos1)
|
areas:setPos1(name, areas.areas[id].pos1)
|
||||||
areas:setPos2(name, areas.areas[id].pos2)
|
areas:setPos2(name, areas.areas[id].pos2)
|
||||||
return true, "Area "..id.." selected."
|
return true, S("Area @1 selected.", id)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("area_pos1", {
|
minetest.register_chatcommand("area_pos1", {
|
||||||
params = "[X Y Z|X,Y,Z]",
|
params = "[X Y Z|X,Y,Z]",
|
||||||
description = "Set area protection region position 1 to your"
|
description = S("Set area protection region position @1 to your"
|
||||||
.." location or the one specified",
|
.." location or the one specified", "1"),
|
||||||
privs = {},
|
privs = {},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local pos
|
local pos
|
||||||
@ -55,22 +55,22 @@ minetest.register_chatcommand("area_pos1", {
|
|||||||
if player then
|
if player then
|
||||||
pos = player:get_pos()
|
pos = player:get_pos()
|
||||||
else
|
else
|
||||||
return false, "Unable to get position."
|
return false, S("Unable to get position.")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return false, "Invalid usage, see /help area_pos1."
|
return false, S("Invalid usage, see /help @1.", "area_pos1")
|
||||||
end
|
end
|
||||||
pos = posLimit(vector.round(pos))
|
pos = posLimit(vector.round(pos))
|
||||||
areas:setPos1(name, pos)
|
areas:setPos1(name, pos)
|
||||||
return true, "Area position 1 set to "
|
return true, S("Area position @1 set to @2", "1",
|
||||||
..minetest.pos_to_string(pos)
|
minetest.pos_to_string(pos))
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("area_pos2", {
|
minetest.register_chatcommand("area_pos2", {
|
||||||
params = "[X Y Z|X,Y,Z]",
|
params = "[X Y Z|X,Y,Z]",
|
||||||
description = "Set area protection region position 2 to your"
|
description = S("Set area protection region position @1 to your"
|
||||||
.." location or the one specified",
|
.." location or the one specified", "2"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local pos
|
local pos
|
||||||
local found, _, x, y, z = param:find(
|
local found, _, x, y, z = param:find(
|
||||||
@ -82,48 +82,48 @@ minetest.register_chatcommand("area_pos2", {
|
|||||||
if player then
|
if player then
|
||||||
pos = player:get_pos()
|
pos = player:get_pos()
|
||||||
else
|
else
|
||||||
return false, "Unable to get position."
|
return false, S("Unable to get position.")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return false, "Invalid usage, see /help area_pos2."
|
return false, S("Invalid usage, see /help @1.", "area_pos2")
|
||||||
end
|
end
|
||||||
pos = posLimit(vector.round(pos))
|
pos = posLimit(vector.round(pos))
|
||||||
areas:setPos2(name, pos)
|
areas:setPos2(name, pos)
|
||||||
return true, "Area position 2 set to "
|
return true, S("Area position @1 set to @2", "2",
|
||||||
..minetest.pos_to_string(pos)
|
minetest.pos_to_string(pos))
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("area_pos", {
|
minetest.register_chatcommand("area_pos", {
|
||||||
params = "set/set1/set2/get",
|
params = "set/set1/set2/get",
|
||||||
description = "Set area protection region, position 1, or position 2"
|
description = S("Set area protection region, position 1, or position 2"
|
||||||
.." by punching nodes, or display the region",
|
.." by punching nodes, or display the region"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if param == "set" then -- Set both area positions
|
if param == "set" then -- Set both area positions
|
||||||
areas.set_pos[name] = "pos1"
|
areas.set_pos[name] = "pos1"
|
||||||
return true, "Select positions by punching two nodes."
|
return true, S("Select positions by punching two nodes.")
|
||||||
elseif param == "set1" then -- Set area position 1
|
elseif param == "set1" then -- Set area position 1
|
||||||
areas.set_pos[name] = "pos1only"
|
areas.set_pos[name] = "pos1only"
|
||||||
return true, "Select position 1 by punching a node."
|
return true, S("Select position @1 by punching a node.", "1")
|
||||||
elseif param == "set2" then -- Set area position 2
|
elseif param == "set2" then -- Set area position 2
|
||||||
areas.set_pos[name] = "pos2"
|
areas.set_pos[name] = "pos2"
|
||||||
return true, "Select position 2 by punching a node."
|
return true, S("Select position @1 by punching a node.", "2")
|
||||||
elseif param == "get" then -- Display current area positions
|
elseif param == "get" then -- Display current area positions
|
||||||
local pos1str, pos2str = "Position 1: ", "Position 2: "
|
local pos1str, pos2str = S("Position @1: ", "1"), S("Position @1: ", "2")
|
||||||
if areas.pos1[name] then
|
if areas.pos1[name] then
|
||||||
pos1str = pos1str..minetest.pos_to_string(areas.pos1[name])
|
pos1str = pos1str..minetest.pos_to_string(areas.pos1[name])
|
||||||
else
|
else
|
||||||
pos1str = pos1str.."<not set>"
|
pos1str = pos1str..S("<not set>")
|
||||||
end
|
end
|
||||||
if areas.pos2[name] then
|
if areas.pos2[name] then
|
||||||
pos2str = pos2str..minetest.pos_to_string(areas.pos2[name])
|
pos2str = pos2str..minetest.pos_to_string(areas.pos2[name])
|
||||||
else
|
else
|
||||||
pos2str = pos2str.."<not set>"
|
pos2str = pos2str..S("<not set>")
|
||||||
end
|
end
|
||||||
return true, pos1str.."\n"..pos2str
|
return true, pos1str.."\n"..pos2str
|
||||||
else
|
else
|
||||||
return false, "Unknown subcommand: "..param
|
return false, S("Unknown subcommand: @1", param)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@ -159,22 +159,22 @@ minetest.register_on_punchnode(function(pos, node, puncher)
|
|||||||
areas.markPos1(name)
|
areas.markPos1(name)
|
||||||
areas.set_pos[name] = "pos2"
|
areas.set_pos[name] = "pos2"
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
"Position 1 set to "
|
S("Position @1 set to @2", "1",
|
||||||
..minetest.pos_to_string(pos))
|
minetest.pos_to_string(pos)))
|
||||||
elseif areas.set_pos[name] == "pos1only" then
|
elseif areas.set_pos[name] == "pos1only" then
|
||||||
areas.pos1[name] = pos
|
areas.pos1[name] = pos
|
||||||
areas.markPos1(name)
|
areas.markPos1(name)
|
||||||
areas.set_pos[name] = nil
|
areas.set_pos[name] = nil
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
"Position 1 set to "
|
S("Position @1 set to @2", "1",
|
||||||
..minetest.pos_to_string(pos))
|
minetest.pos_to_string(pos)))
|
||||||
elseif areas.set_pos[name] == "pos2" then
|
elseif areas.set_pos[name] == "pos2" then
|
||||||
areas.pos2[name] = pos
|
areas.pos2[name] = pos
|
||||||
areas.markPos2(name)
|
areas.markPos2(name)
|
||||||
areas.set_pos[name] = nil
|
areas.set_pos[name] = nil
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
"Position 2 set to "
|
S("Position @1 set to @2", "2",
|
||||||
..minetest.pos_to_string(pos))
|
minetest.pos_to_string(pos)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user