-- @param pos2\r
-- @param angle Angle in degrees (90 degree increments only).\r
-- @return The number of nodes oriented.\r
--- TODO: Support 6D facedir rotation along arbitrary axis.\r
function worldedit.orient(pos1, pos2, angle)\r
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
local registered_nodes = minetest.registered_nodes\r
\r
local wallmounted = {\r
- [90] = {[0]=0, 1, 5, 4, 2, 3},\r
- [180] = {[0]=0, 1, 3, 2, 5, 4},\r
- [270] = {[0]=0, 1, 4, 5, 3, 2}\r
+ [90] = {0, 1, 5, 4, 2, 3, 0, 0},\r
+ [180] = {0, 1, 3, 2, 5, 4, 0, 0},\r
+ [270] = {0, 1, 4, 5, 3, 2, 0, 0}\r
}\r
local facedir = {\r
- [90] = {[0]=1, 2, 3, 0},\r
- [180] = {[0]=2, 3, 0, 1},\r
- [270] = {[0]=3, 0, 1, 2}\r
+ [90] = { 1, 2, 3, 0, 13, 14, 15, 12, 17, 18, 19, 16,\r
+ 9, 10, 11, 8, 5, 6, 7, 4, 23, 20, 21, 22},\r
+ [180] = { 2, 3, 0, 1, 10, 11, 8, 9, 6, 7, 4, 5,\r
+ 18, 19, 16, 17, 14, 15, 12, 13, 22, 23, 20, 21},\r
+ [270] = { 3, 0, 1, 2, 19, 16, 17, 18, 15, 12, 13, 14,\r
+ 7, 4, 5, 6, 11, 8, 9, 10, 21, 22, 23, 20}\r
}\r
\r
angle = angle % 360\r
worldedit.keep_loaded(pos1, pos2)\r
\r
local count = 0\r
- local set_node, get_node, get_meta, swap_node = minetest.set_node,\r
- minetest.get_node, minetest.get_meta, minetest.swap_node\r
+ local get_node, swap_node = minetest.get_node, minetest.swap_node\r
local pos = {x=pos1.x, y=0, z=0}\r
while pos.x <= pos2.x do\r
pos.y = pos1.y\r
local node = get_node(pos)\r
local def = registered_nodes[node.name]\r
if def then\r
- if def.paramtype2 == "wallmounted" then\r
- node.param2 = wallmounted_substitution[node.param2]\r
- local meta = get_meta(pos):to_table()\r
- set_node(pos, node)\r
- get_meta(pos):from_table(meta)\r
+ local paramtype2 = def.paramtype2\r
+ if paramtype2 == "wallmounted" or\r
+ paramtype2 == "colorwallmounted" then\r
+ local orient = node.param2 % 8\r
+ node.param2 = node.param2 - orient +\r
+ wallmounted_substitution[orient + 1]\r
+ swap_node(pos, node)\r
count = count + 1\r
- elseif def.paramtype2 == "facedir" then\r
- node.param2 = facedir_substitution[node.param2]\r
- local meta = get_meta(pos):to_table()\r
- set_node(pos, node)\r
- get_meta(pos):from_table(meta)\r
+ elseif paramtype2 == "facedir" or\r
+ paramtype2 == "colorfacedir" then\r
+ local orient = node.param2 % 32\r
+ node.param2 = node.param2 - orient +\r
+ facedir_substitution[orient + 1]\r
+ swap_node(pos, node)\r
count = count + 1\r
end\r
end\r