WorldEdit's //orient command doesn't actually work. In fact, it'll rotate the contents of some nodes, but not others.
Yesterday, somebody needed to do a 180-degree rotation of a city. We tried //rotate y 180 to rotate the nodes followed by //orient 180 to rotate the node contents.
We found that the 1st operation worked but the 2nd operation did not.
To solve the problem, I patched the WE //param2 command just temporarily. The change modified //param2 to make it rotate node contents, in all cases, by 180 degrees.
That worked. However, since it added a param2 value to all nodes, it significantly increased the on-disk sizes of buildings.
I added a tweak to skip a few types of nodes and that helped. However, there is still a noticeable size increase.
Since the patch works well enough for its purposes, I'll share it here. However, it should only be applied temporarily as it breaks normal operation of //param2.
Yesterday, somebody needed to do a 180-degree rotation of a city. We tried //rotate y 180 to rotate the nodes followed by //orient 180 to rotate the node contents.
We found that the 1st operation worked but the 2nd operation did not.
To solve the problem, I patched the WE //param2 command just temporarily. The change modified //param2 to make it rotate node contents, in all cases, by 180 degrees.
That worked. However, since it added a param2 value to all nodes, it significantly increased the on-disk sizes of buildings.
I added a tweak to skip a few types of nodes and that helped. However, there is still a noticeable size increase.
Since the patch works well enough for its purposes, I'll share it here. However, it should only be applied temporarily as it breaks normal operation of //param2.
--- worldedit.old/manipulations.lua
+++ worldedit/manipulations.lua
@@ -3,6 +3,24 @@
local mh = worldedit.manip_helpers
+local param2_rotmap = {
+ _0 = 2 , _1 = 3 , _2 = 0 ,
+ _3 = 1 , _4 = 10 , _5 = 11 ,
+ _6 = 8 , _7 = 9 , _8 = 6 ,
+ _9 = 7 , _10 = 4 , _11 = 5 ,
+ _12 = 18 , _13 = 19 , _14 = 16 ,
+ _15 = 17 , _16 = 14 , _17 = 15 ,
+ _18 = 12 , _19 = 13 , _20 = 22 ,
+ _21 = 23 , _22 = 20 , _23 = 21 ,
+}
+
+local sr = {}
+local mgcid = minetest.get_content_id
+
+sr [mgcid ("default:dirt_with_grass" )] = 1
+sr [mgcid ("default:sandstonebrick" )] = 1
+sr [mgcid ("default:stone" )] = 1
+sr [mgcid ("air" )] = 1
--- Sets a region to `node_names`.
-- @param pos1
@@ -48,11 +66,23 @@
local manip, area = mh.init(pos1, pos2)
local param2_data = manip:get_param2_data()
+ local core_data = manip:get_data()
-- Set param2 for every node
- for i in area:iterp(pos1, pos2) do
- param2_data[i] = param2
- end
+
+-- RJK: Temporary patch (not for ongoing use)
+-- This code rotates node contents 180 degrees
+-- Work in cases where //orient doesn't work
+-- But superfluous param2 values will be added
+-- This will increase file sizes
+
+ for i in area:iterp (pos1, pos2) do
+ if sr [core_data [i]] == nil then
+ local p2 = param2_data [i]
+ if p2 == nil then p2 = 0 end
+ param2_data [i] = param2_rotmap ["_" .. p2]
+ end
+ end
-- Update map
manip:set_param2_data(param2_data)
+++ worldedit/manipulations.lua
@@ -3,6 +3,24 @@
local mh = worldedit.manip_helpers
+local param2_rotmap = {
+ _0 = 2 , _1 = 3 , _2 = 0 ,
+ _3 = 1 , _4 = 10 , _5 = 11 ,
+ _6 = 8 , _7 = 9 , _8 = 6 ,
+ _9 = 7 , _10 = 4 , _11 = 5 ,
+ _12 = 18 , _13 = 19 , _14 = 16 ,
+ _15 = 17 , _16 = 14 , _17 = 15 ,
+ _18 = 12 , _19 = 13 , _20 = 22 ,
+ _21 = 23 , _22 = 20 , _23 = 21 ,
+}
+
+local sr = {}
+local mgcid = minetest.get_content_id
+
+sr [mgcid ("default:dirt_with_grass" )] = 1
+sr [mgcid ("default:sandstonebrick" )] = 1
+sr [mgcid ("default:stone" )] = 1
+sr [mgcid ("air" )] = 1
--- Sets a region to `node_names`.
-- @param pos1
@@ -48,11 +66,23 @@
local manip, area = mh.init(pos1, pos2)
local param2_data = manip:get_param2_data()
+ local core_data = manip:get_data()
-- Set param2 for every node
- for i in area:iterp(pos1, pos2) do
- param2_data[i] = param2
- end
+
+-- RJK: Temporary patch (not for ongoing use)
+-- This code rotates node contents 180 degrees
+-- Work in cases where //orient doesn't work
+-- But superfluous param2 values will be added
+-- This will increase file sizes
+
+ for i in area:iterp (pos1, pos2) do
+ if sr [core_data [i]] == nil then
+ local p2 = param2_data [i]
+ if p2 == nil then p2 = 0 end
+ param2_data [i] = param2_rotmap ["_" .. p2]
+ end
+ end
-- Update map
manip:set_param2_data(param2_data)
If this patch is applied, the WE //param2 command will be modified so that //param2 0 will correctly rotate the contents of nodes by 180 degrees. The patch should be removed after use.
We might modify the patch later on so that it adds a permanent command named, possibly, //orient180.
We might modify the patch later on so that it adds a permanent command named, possibly, //orient180.