Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate worldedit_commands commands #229

Merged
merged 9 commits into from
Oct 23, 2023
43 changes: 22 additions & 21 deletions worldedit_commands/cuboid.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
local S = minetest.get_translator("worldedit_commands")

worldedit.register_command("outset", {
params = "[h/v] <amount>",
description = "Outset the selected region.",
description = S("Outset the selected region."),
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
Expand All @@ -11,7 +13,7 @@ worldedit.register_command("outset", {

local hv_test = dir:find("[^hv]+")
if hv_test ~= nil then
return false, "Invalid direction."
return false, S("Invalid direction: @1", dir)
end

return true, dir, tonumber(amount)
Expand All @@ -28,18 +30,18 @@ worldedit.register_command("outset", {
assert(worldedit.cuboid_linear_expand(name, 'y', 1, amount))
assert(worldedit.cuboid_linear_expand(name, 'y', -1, amount))
else
return false, "Invalid number of arguments"
return false, S("Invalid number of arguments")
end

worldedit.marker_update(name)
return true, "Region outset by " .. amount .. " blocks"
return true, S("Region outset by @1 nodes", amount)
end,
})


worldedit.register_command("inset", {
params = "[h/v] <amount>",
description = "Inset the selected region.",
description = S("Inset the selected region."),
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
Expand All @@ -48,7 +50,7 @@ worldedit.register_command("inset", {
return false
end
if dir:find("[^hv]") ~= nil then
return false, "Invalid direction."
return false, S("Invalid direction: @1", dir)
end

return true, dir, tonumber(amount)
Expand All @@ -65,18 +67,18 @@ worldedit.register_command("inset", {
assert(worldedit.cuboid_linear_expand(name, 'y', 1, -amount))
assert(worldedit.cuboid_linear_expand(name, 'y', -1, -amount))
else
return false, "Invalid number of arguments"
return false, S("Invalid number of arguments")
end

worldedit.marker_update(name)
return true, "Region inset by " .. amount .. " blocks"
return true, S("Region inset by @1 nodes", amount)
end,
})


worldedit.register_command("shift", {
params = "x/y/z/?/up/down/left/right/front/back [+/-]<amount>",
description = "Shifts the selection area without moving its contents",
description = S("Shifts the selection area without moving its contents"),
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
Expand All @@ -98,20 +100,20 @@ worldedit.register_command("shift", {
end

if axis == nil or dir == nil then
return false, "Invalid if looking straight up or down"
return false, S("Invalid if looking straight up or down")
end

assert(worldedit.cuboid_shift(name, axis, amount * dir))
worldedit.marker_update(name)

return true, "Region shifted by " .. amount .. " nodes"
return true, S("Region shifted by @1 nodes", amount)
end,
})


worldedit.register_command("expand", {
params = "[+/-]x/y/z/?/up/down/left/right/front/back <amount> [reverse amount]",
description = "Expands the selection in the selected absolute or relative axis",
description = S("Expands the selection in the selected absolute or relative axis"),
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
Expand All @@ -135,7 +137,7 @@ worldedit.register_command("expand", {
axis, dir = worldedit.translate_direction(name, direction)

if axis == nil or dir == nil then
return false, "Invalid if looking straight up or down"
return false, S("Invalid if looking straight up or down")
end
else
if direction == "?" then
Expand All @@ -153,14 +155,14 @@ worldedit.register_command("expand", {
worldedit.cuboid_linear_expand(name, axis, dir, amount)
worldedit.cuboid_linear_expand(name, axis, -dir, rev_amount)
worldedit.marker_update(name)
return true, "Region expanded by " .. (amount + rev_amount) .. " nodes"
return true, S("Region expanded by @1 nodes", amount + rev_amount)
end,
})


worldedit.register_command("contract", {
params = "[+/-]x/y/z/?/up/down/left/right/front/back <amount> [reverse amount]",
description = "Contracts the selection in the selected absolute or relative axis",
description = S("Contracts the selection in the selected absolute or relative axis"),
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
Expand All @@ -184,7 +186,7 @@ worldedit.register_command("contract", {
axis, dir = worldedit.translate_direction(name, direction)

if axis == nil or dir == nil then
return false, "Invalid if looking straight up or down"
return false, S("Invalid if looking straight up or down")
end
else
if direction == "?" then
Expand All @@ -202,13 +204,13 @@ worldedit.register_command("contract", {
worldedit.cuboid_linear_expand(name, axis, dir, -amount)
worldedit.cuboid_linear_expand(name, axis, -dir, -rev_amount)
worldedit.marker_update(name)
return true, "Region contracted by " .. (amount + rev_amount) .. " nodes"
return true, S("Region contracted by @1 nodes", amount + rev_amount)
end,
})

worldedit.register_command("cubeapply", {
params = "<size>/(<sizex> <sizey> <sizez>) <command> [parameters]",
description = "Select a cube with side length <size> around position 1 and run <command> on region",
description = S("Select a cube with side length <size> around position 1 and run <command> on region"),
privs = {worldedit=true},
require_pos = 1,
parse = function(param)
alek13 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -230,7 +232,7 @@ worldedit.register_command("cubeapply", {
end
local cmddef = worldedit.registered_commands[cmd]
if cmddef == nil or cmddef.require_pos ~= 2 then
return false, "invalid usage: //" .. cmd .. " cannot be used with cubeapply"
return false, S("invalid usage: //@1 cannot be used with cubeapply", cmd)
end
-- run parsing of target command
local parsed = {cmddef.parse(args)}
Expand All @@ -247,8 +249,7 @@ worldedit.register_command("cubeapply", {
local cmddef = assert(worldedit.registered_commands[cmd])
local success, missing_privs = minetest.check_player_privs(name, cmddef.privs)
if not success then
worldedit.player_notify(name, "Missing privileges: " ..
table.concat(missing_privs, ", "))
worldedit.player_notify(name, S("Missing privileges: @1", table.concat(missing_privs, ", ")))
return
end

Expand Down
Loading