mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2025-10-16 15:45:27 +02:00
Allow relative coordinate parsing
for //fixedpos, since that's the only relevant command closes #260
This commit is contained in:
@@ -99,6 +99,8 @@ Set the WorldEdit region position 1 or 2 to the position (`<x>`, `<y>`, `<z>`).
|
||||
//fixedpos set1 -30 5 28
|
||||
//fixedpos set2 1004 -200 432
|
||||
|
||||
Note that the `~` syntax can be used here to indicate a coordinate relative to the player.
|
||||
|
||||
### `//volume`
|
||||
|
||||
Display the volume of the current WorldEdit region.
|
||||
|
@@ -199,6 +199,23 @@ function worldedit.player_axis(name)
|
||||
return "z", dir.z > 0 and 1 or -1
|
||||
end
|
||||
|
||||
-- Wrapper for the engine's parse_coordinates
|
||||
-- @return vector or nil
|
||||
-- @note Not part of API
|
||||
function worldedit.parse_coordinates(x, y, z, player_name)
|
||||
local relpos
|
||||
local player = minetest.get_player_by_name(player_name or "")
|
||||
if player then
|
||||
relpos = player:get_pos()
|
||||
end
|
||||
-- we don't bother to support ~ in the fallback path here
|
||||
if not minetest.parse_coordinates then
|
||||
x, y, z = tonumber(x), tonumber(y), tonumber(z)
|
||||
return x and y and z and vector.new(x, y, z)
|
||||
end
|
||||
return minetest.parse_coordinates(x, y, z, relpos)
|
||||
end
|
||||
|
||||
|
||||
worldedit.register_command("about", {
|
||||
privs = {},
|
||||
|
@@ -51,6 +51,7 @@ select position @1 by punching a node=
|
||||
position @1: @2=
|
||||
position @1 not set=
|
||||
Set a WorldEdit region position to the position at (<x>, <y>, <z>)=
|
||||
invalid position=
|
||||
Display the volume of the current WorldEdit region=
|
||||
current region has a volume of @1 nodes (@2*@3*@4)=
|
||||
Remove all MapBlocks (16x16x16) containing the selected area from the map=
|
||||
|
@@ -62,6 +62,7 @@ select position @1 by punching a node=Wählen Sie Position @1 durch Hauen eines
|
||||
position @1: @2=Position @1: @2
|
||||
position @1 not set=Position @1 ist nicht gesetzt
|
||||
Set a WorldEdit region position to the position at (<x>, <y>, <z>)=Eine Position des WorldEdit-Gebiets auf (<x>, <y>, <z>) setzen
|
||||
invalid position=Ungültige Position
|
||||
Display the volume of the current WorldEdit region=Volumen des aktuellen WorldEdit-Gebiets anzeigen
|
||||
current region has a volume of @1 nodes (@2*@3*@4)=Das aktuelle Gebiet hat ein Volumen von @1 Blöcken (@2×@3×@4)
|
||||
Remove all MapBlocks (16x16x16) containing the selected area from the map=Alle Kartenblöcke (16×16×16) entfernen, die das gewählte Gebiet enthalten
|
||||
|
@@ -180,13 +180,18 @@ worldedit.register_command("fixedpos", {
|
||||
category = S("Region operations"),
|
||||
privs = {worldedit=true},
|
||||
parse = function(param)
|
||||
local found, _, flag, x, y, z = param:find("^(set[12])%s+([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)$")
|
||||
if found == nil then
|
||||
local found, _, flag, x, y, z = param:find("^(set[12])%s+(~?[+-]?%d+)%s+(~?[+-]?%d+)%s+(~?[+-]?%d+)$")
|
||||
if not found then
|
||||
return false
|
||||
end
|
||||
return true, flag, vector.new(tonumber(x), tonumber(y), tonumber(z))
|
||||
return true, flag, x, y, z
|
||||
end,
|
||||
func = function(name, flag, pos)
|
||||
func = function(name, flag, x, y, z)
|
||||
-- Parse here, since player name isn't known in parse()
|
||||
local pos = worldedit.parse_coordinates(x, y, z, name)
|
||||
if not pos then
|
||||
return false, S("invalid position")
|
||||
end
|
||||
if flag == "set1" then
|
||||
set_pos1(name, pos)
|
||||
else --flag == "set2"
|
||||
|
Reference in New Issue
Block a user