From 4368f74e30fc528d49cfc4ade5522f673052d2c6 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 18 Feb 2021 02:33:26 +0000 Subject: [PATCH] Fix directionality in worldedit region update when scaling down --- README.md | 1 + worldeditadditions/lib/scale.lua | 2 ++ worldeditadditions/lib/scale_down.lua | 12 +++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f764a73..c7bd510 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ The detailed explanations have moved! Check them out [here](https://github.com/s ### Misc - [`//replacemix [] [] [ []] [ []] ....`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/master/Chat-Command-Reference.md#replacemix-target_node-chance-replace_node_a-chance_a-replace_node_b-chance_b-replace_node_n-chance_n-) - [`//floodfill [ []]`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/master/Chat-Command-Reference.md#floodfill-replace_node-radius-floodfill) + - [`//scale | [ [ ]]`]() ### Terrain - [`//overlay [] [] [ []] ...`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/master/Chat-Command-Reference.md#overlay-node_name_a-chance_a-node_name_b-chance_b-node_name_n-chance_n-) diff --git a/worldeditadditions/lib/scale.lua b/worldeditadditions/lib/scale.lua index bba8380..46b5b7c 100644 --- a/worldeditadditions/lib/scale.lua +++ b/worldeditadditions/lib/scale.lua @@ -49,6 +49,8 @@ function worldeditadditions.scale(pos1, pos2, scale, anchor) pos2 = stats.pos2 end + pos1, pos2 = worldedit.sort_pos(pos1, pos2) + stats_total.pos1 = pos1 stats_total.pos2 = pos2 diff --git a/worldeditadditions/lib/scale_down.lua b/worldeditadditions/lib/scale_down.lua index 10b79e3..0c9a1c8 100644 --- a/worldeditadditions/lib/scale_down.lua +++ b/worldeditadditions/lib/scale_down.lua @@ -43,8 +43,18 @@ function worldeditadditions.scale_down(pos1, pos2, scale, anchor) local node_id_air = minetest.get_content_id("air") + local pos1_small = vector.new(pos1) + local pos2_small = vector.new(pos2) - local stats = { updated = 0, scale = scale_down, pos1 = pos1, pos2 = vector.add(pos1, size_small) } + if anchor.x < 1 then pos1_small.x = pos2_small.x - size_small.x + else pos2_small.x = pos1_small.x + size_small.x end + if anchor.y < 1 then pos1_small.y = pos2_small.y - size_small.y + else pos2_small.y = pos1_small.y + size_small.y end + if anchor.z < 1 then pos1_small.z = pos2_small.z - size_small.z + else pos2_small.z = pos1_small.z + size_small.z end + + + local stats = { updated = 0, scale = scale_down, pos1 = pos1_small, pos2 = pos2_small } -- Zero out the area we're scaling down into for i in area:iterp(pos1, pos2) do data_copy[i] = node_id_air