mirror of
https://github.com/minetest-mods/areas.git
synced 2025-07-04 09:00:25 +02:00
Manual update due to conflict (part 2)
This adds part of PR #4 and they came from inpos/areas repo, this adds i18n : intllib po/pot method and french translation. Author is fat115
This commit is contained in:
parent
a23d2bad3a
commit
132b5289db
53
pos.lua
53
pos.lua
@ -1,10 +1,11 @@
|
||||
|
||||
-- I could depend on WorldEdit for this, but you need to have the 'worldedit'
|
||||
-- permission to use those commands and you don't have
|
||||
-- /area_pos{1,2} [X Y Z|X,Y,Z].
|
||||
-- Since this is mostly copied from WorldEdit it is mostly
|
||||
-- licensed under the AGPL. (select_area is a exception)
|
||||
|
||||
local S = areas.intllib
|
||||
|
||||
areas.marker1 = {}
|
||||
areas.marker2 = {}
|
||||
areas.set_pos = {}
|
||||
@ -13,26 +14,26 @@ areas.pos2 = {}
|
||||
|
||||
minetest.register_chatcommand("select_area", {
|
||||
params = "<ID>",
|
||||
description = "Select a area by id.",
|
||||
description = S("Select a area by id."),
|
||||
func = function(name, param)
|
||||
local id = tonumber(param)
|
||||
if not id then
|
||||
return false, "Invalid usage, see /help select_area."
|
||||
return false, S("Invalid usage, see /help select_area.")
|
||||
end
|
||||
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
|
||||
|
||||
areas:setPos1(name, areas.areas[id].pos1)
|
||||
areas:setPos2(name, areas.areas[id].pos2)
|
||||
return true, "Area "..id.." selected."
|
||||
return true, S("Area @1 selected.", id)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("area_pos1", {
|
||||
params = "[X Y Z|X,Y,Z]",
|
||||
description = "Set area protection region position 1 to your"
|
||||
.." location or the one specified",
|
||||
description = S("Set area protection region position 1 to your"
|
||||
.." location or the one specified"),
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
local pos = nil
|
||||
@ -45,22 +46,22 @@ minetest.register_chatcommand("area_pos1", {
|
||||
if player then
|
||||
pos = player:getpos()
|
||||
else
|
||||
return false, "Unable to get position."
|
||||
return false, S("Unable to get position.")
|
||||
end
|
||||
else
|
||||
return false, "Invalid usage, see /help area_pos1."
|
||||
return false, S("Invalid usage, see /help area_pos1.")
|
||||
end
|
||||
pos = vector.round(pos)
|
||||
areas:setPos1(name, pos)
|
||||
return true, "Area position 1 set to "
|
||||
return true, S("Area position 1 set to ")
|
||||
..minetest.pos_to_string(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("area_pos2", {
|
||||
params = "[X Y Z|X,Y,Z]",
|
||||
description = "Set area protection region position 2 to your"
|
||||
.." location or the one specified",
|
||||
description = S("Set area protection region position 2 to your"
|
||||
.." location or the one specified"),
|
||||
func = function(name, param)
|
||||
local pos = nil
|
||||
local found, _, x, y, z = param:find(
|
||||
@ -72,14 +73,14 @@ minetest.register_chatcommand("area_pos2", {
|
||||
if player then
|
||||
pos = player:getpos()
|
||||
else
|
||||
return false, "Unable to get position."
|
||||
return false, S("Unable to get position.")
|
||||
end
|
||||
else
|
||||
return false, "Invalid usage, see /help area_pos2."
|
||||
return false, S("Invalid usage, see /help area_pos2.")
|
||||
end
|
||||
pos = vector.round(pos)
|
||||
areas:setPos2(name, pos)
|
||||
return true, "Area position 2 set to "
|
||||
return true, S("Area position 2 set to ")
|
||||
..minetest.pos_to_string(pos)
|
||||
end,
|
||||
})
|
||||
@ -87,33 +88,33 @@ minetest.register_chatcommand("area_pos2", {
|
||||
|
||||
minetest.register_chatcommand("area_pos", {
|
||||
params = "set/set1/set2/get",
|
||||
description = "Set area protection region, position 1, or position 2"
|
||||
.." by punching nodes, or display the region",
|
||||
description = S("Set area protection region, position 1, or position 2"
|
||||
.." by punching nodes, or display the region"),
|
||||
func = function(name, param)
|
||||
if param == "set" then -- Set both area positions
|
||||
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
|
||||
areas.set_pos[name] = "pos1only"
|
||||
return true, "Select position 1 by punching a node."
|
||||
return true, S("Select position 1 by punching a node.")
|
||||
elseif param == "set2" then -- Set area position 2
|
||||
areas.set_pos[name] = "pos2"
|
||||
return true, "Select position 2 by punching a node."
|
||||
return true, S("Select position 2 by punching a node.")
|
||||
elseif param == "get" then -- Display current area positions
|
||||
local pos1str, pos2str = "Position 1: ", "Position 2: "
|
||||
if areas.pos1[name] then
|
||||
pos1str = pos1str..minetest.pos_to_string(areas.pos1[name])
|
||||
else
|
||||
pos1str = pos1str.."<not set>"
|
||||
pos1str = pos1str..S("<not set>")
|
||||
end
|
||||
if areas.pos2[name] then
|
||||
pos2str = pos2str..minetest.pos_to_string(areas.pos2[name])
|
||||
else
|
||||
pos2str = pos2str.."<not set>"
|
||||
pos2str = pos2str..S("<not set>")
|
||||
end
|
||||
return true, pos1str.."\n"..pos2str
|
||||
else
|
||||
return false, "Unknown subcommand: "..param
|
||||
return false, S("Unknown subcommand: ")..param
|
||||
end
|
||||
end,
|
||||
})
|
||||
@ -149,21 +150,21 @@ minetest.register_on_punchnode(function(pos, node, puncher)
|
||||
areas.markPos1(name)
|
||||
areas.set_pos[name] = "pos2"
|
||||
minetest.chat_send_player(name,
|
||||
"Position 1 set to "
|
||||
S("Position 1 set to ")
|
||||
..minetest.pos_to_string(pos))
|
||||
elseif areas.set_pos[name] == "pos1only" then
|
||||
areas.pos1[name] = pos
|
||||
areas.markPos1(name)
|
||||
areas.set_pos[name] = nil
|
||||
minetest.chat_send_player(name,
|
||||
"Position 1 set to "
|
||||
S("Position 1 set to ")
|
||||
..minetest.pos_to_string(pos))
|
||||
elseif areas.set_pos[name] == "pos2" then
|
||||
areas.pos2[name] = pos
|
||||
areas.markPos2(name)
|
||||
areas.set_pos[name] = nil
|
||||
minetest.chat_send_player(name,
|
||||
"Position 2 set to "
|
||||
S("Position 2 set to ")
|
||||
..minetest.pos_to_string(pos))
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user