-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschematics.lua
37 lines (32 loc) · 1.29 KB
/
schematics.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
local dummy = cubictest.dummies.nodes
local test_position = {x=5,y=10,z=5}
-- minetest.place_schematic(pos, schematic, rotation, replacements, force_placement)
describe("minetest.place_schematic(pos, schematic, rotation, replacements, force_placement)", function()
it("rotates the facedir of nodes correctly by the supplied angle (minetest/minetest#3093)", function()
Given "a schematic with nodes of different facedir values"
local schematic = {
size = {x=24, y=1, z=1},
yslice_prob = { {ypos=0, prob=254}, },
data = {}
}
for facedir=0, 23 do
table.insert(schematic.data, {name=dummy.facedirected.name, prob=254, param2=facedir})
end
When "placing it without rotation"
minetest.place_schematic(test_position, schematic, 0, nil, true)
Then "don't rotate any node"
for x = 0, 23 do
local node = minetest.get_node_or_nil({x=test_position.x+x, y=test_position.y, z=test_position.z})
assert.is_not.Nil(node)
assert.equals(node.param2, x)
end
When "placing it with rotation"
minetest.place_schematic(test_position, schematic, 180, nil, true)
Then "don't skip rotation"
for x = 0, 23 do
local node = minetest.get_node_or_nil({x=test_position.x+23-x, y=test_position.y, z=test_position.z})
assert.is_not.Nil(node)
assert.is_not.equal(node.param2, x)
end
end)
end)