mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-12-25 18:20:38 +01:00
Implement full facedir and color* in //orient
Thanks to entuland for the Rhotator facedir to matrix and matrix to facedir code, which helped creating the tables.
This commit is contained in:
parent
f242f2f722
commit
0aeee79af6
@ -529,20 +529,22 @@ end
|
|||||||
-- @param pos2
|
-- @param pos2
|
||||||
-- @param angle Angle in degrees (90 degree increments only).
|
-- @param angle Angle in degrees (90 degree increments only).
|
||||||
-- @return The number of nodes oriented.
|
-- @return The number of nodes oriented.
|
||||||
-- TODO: Support 6D facedir rotation along arbitrary axis.
|
|
||||||
function worldedit.orient(pos1, pos2, angle)
|
function worldedit.orient(pos1, pos2, angle)
|
||||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||||
local registered_nodes = minetest.registered_nodes
|
local registered_nodes = minetest.registered_nodes
|
||||||
|
|
||||||
local wallmounted = {
|
local wallmounted = {
|
||||||
[90] = {[0]=0, 1, 5, 4, 2, 3},
|
[90] = {0, 1, 5, 4, 2, 3, 0, 0},
|
||||||
[180] = {[0]=0, 1, 3, 2, 5, 4},
|
[180] = {0, 1, 3, 2, 5, 4, 0, 0},
|
||||||
[270] = {[0]=0, 1, 4, 5, 3, 2}
|
[270] = {0, 1, 4, 5, 3, 2, 0, 0}
|
||||||
}
|
}
|
||||||
local facedir = {
|
local facedir = {
|
||||||
[90] = {[0]=1, 2, 3, 0},
|
[90] = { 1, 2, 3, 0, 13, 14, 15, 12, 17, 18, 19, 16,
|
||||||
[180] = {[0]=2, 3, 0, 1},
|
9, 10, 11, 8, 5, 6, 7, 4, 23, 20, 21, 22},
|
||||||
[270] = {[0]=3, 0, 1, 2}
|
[180] = { 2, 3, 0, 1, 10, 11, 8, 9, 6, 7, 4, 5,
|
||||||
|
18, 19, 16, 17, 14, 15, 12, 13, 22, 23, 20, 21},
|
||||||
|
[270] = { 3, 0, 1, 2, 19, 16, 17, 18, 15, 12, 13, 14,
|
||||||
|
7, 4, 5, 6, 11, 8, 9, 10, 21, 22, 23, 20}
|
||||||
}
|
}
|
||||||
|
|
||||||
angle = angle % 360
|
angle = angle % 360
|
||||||
@ -558,8 +560,7 @@ function worldedit.orient(pos1, pos2, angle)
|
|||||||
worldedit.keep_loaded(pos1, pos2)
|
worldedit.keep_loaded(pos1, pos2)
|
||||||
|
|
||||||
local count = 0
|
local count = 0
|
||||||
local set_node, get_node, get_meta, swap_node = minetest.set_node,
|
local get_node, swap_node = minetest.get_node, minetest.swap_node
|
||||||
minetest.get_node, minetest.get_meta, minetest.swap_node
|
|
||||||
local pos = {x=pos1.x, y=0, z=0}
|
local pos = {x=pos1.x, y=0, z=0}
|
||||||
while pos.x <= pos2.x do
|
while pos.x <= pos2.x do
|
||||||
pos.y = pos1.y
|
pos.y = pos1.y
|
||||||
@ -569,17 +570,20 @@ function worldedit.orient(pos1, pos2, angle)
|
|||||||
local node = get_node(pos)
|
local node = get_node(pos)
|
||||||
local def = registered_nodes[node.name]
|
local def = registered_nodes[node.name]
|
||||||
if def then
|
if def then
|
||||||
if def.paramtype2 == "wallmounted" then
|
local paramtype2 = def.paramtype2
|
||||||
node.param2 = wallmounted_substitution[node.param2]
|
if paramtype2 == "wallmounted" or
|
||||||
local meta = get_meta(pos):to_table()
|
paramtype2 == "colorwallmounted" then
|
||||||
set_node(pos, node)
|
local orient = node.param2 % 8
|
||||||
get_meta(pos):from_table(meta)
|
node.param2 = node.param2 - orient +
|
||||||
|
wallmounted_substitution[orient + 1]
|
||||||
|
swap_node(pos, node)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
elseif def.paramtype2 == "facedir" then
|
elseif paramtype2 == "facedir" or
|
||||||
node.param2 = facedir_substitution[node.param2]
|
paramtype2 == "colorfacedir" then
|
||||||
local meta = get_meta(pos):to_table()
|
local orient = node.param2 % 32
|
||||||
set_node(pos, node)
|
node.param2 = node.param2 - orient +
|
||||||
get_meta(pos):from_table(meta)
|
facedir_substitution[orient + 1]
|
||||||
|
swap_node(pos, node)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user