mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2025-10-15 23:25:39 +02:00
Allow relative coordinate parsing
for //fixedpos, since that's the only relevant command closes #260
This commit is contained in:
@@ -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 = {},
|
||||
|
Reference in New Issue
Block a user