1 local function rshift(x
, by
)
2 return math
.floor(x
/ 2 ^ by
)
8 {x
= -1, y
= 0, z
= 0},
9 {x
= 0, y
= 0, z
= -1},
10 {x
= 0, y
= -1, z
= 0},
13 local function update_wall(pos
)
14 local thisnode
= minetest
.env
:get_node(pos
)
16 if thisnode
.name
:find("wallet:wall") ~= 1 and
17 thisnode
.name
:find("wallet:wallmossy") ~= 1 then
22 -- Get the node's base name, including the underscore since we will need it
23 local basename
= thisnode
.name
:find("_")
24 if basename
== nil then -- New wall
25 basename
= thisnode
.name
.. "_"
26 else -- Already placed wall
27 basename
= thisnode
.name
:sub(1, basename
)
32 -- Neighbouring walkable nodes
34 local dir
= directions
[i
]
35 local node
= minetest
.env
:get_node({x
= pos
.x
+ dir
.x
, y
= pos
.y
+ dir
.y
, z
= pos
.z
+ dir
.z
})
36 if minetest
.registered_nodes
[node
.name
].walkable
then
37 sum
= sum
+ 2 ^
(i
- 1)
41 -- Torches or walkable nodes above the wall
42 local upnode
= minetest
.env
:get_node({x
= pos
.x
, y
= pos
.y
+1, z
= pos
.z
})
43 if sum
== 5 or sum
== 10 then
44 if minetest
.registered_nodes
[upnode
.name
].walkable
or upnode
.name
== "torches:floor" then
53 minetest
.env
:add_node(pos
, {name
= basename
..sum
})
56 function update_wall_global(pos
)
58 local dir
= directions
[i
]
59 update_wall({x
= pos
.x
+ dir
.x
, y
= pos
.y
+ dir
.y
, z
= pos
.z
+ dir
.z
})
64 {4/16, -0.5, -3/16, 0.5, 5/16, 3/16},
65 {-3/16, -0.5, 4/16, 3/16, 5/16, 0.5},
66 {-0.5, -0.5, -3/16, -4/16, 5/16, 3/16},
67 {-3/16, -0.5, -0.5, 3/16, 5/16, -4/16}
70 local pillar
= {-4/16, -0.5, -4/16, 4/16, 0.5, 4/16}
73 {-0.5, -0.5, -3/16, 0.5, 5/16, 3/16},
74 {-3/16, -0.5, -0.5, 3/16, 5/16, 0.5}
77 local function register_wall(nodename
, name
, texture
, invtex
)
80 local need_pillar
= false
82 if rshift(i
, j
- 1) % 2 == 1 then
88 if need
[1] == true and need
[3] == true then
91 table.insert(take
, full_blocks
[1])
93 if need
[2] == true and need
[4] == true then
96 table.insert(take
, full_blocks
[2])
98 for k
in pairs(need
) do
99 table.insert(take
, half_blocks
[k
])
102 if i
== 15 or i
== 0 then need_pillar
= true end
103 if need_pillar
then table.insert(take
, pillar
) end
105 minetest
.register_node(nodename
.."_"..i
, {
108 fixed
= {-4/16, -1, -4/16, 4/16, 1, 4/16}
110 drawtype
= "nodebox",
111 tile_images
= {texture
},
113 groups
= {snappy
=2,cracky
=3,oddly_breakable_by_hand
=3,fences
=1},
122 minetest
.register_node(nodename
.."_16", {
123 drawtype
= "nodebox",
126 fixed
= {-4/16, -1, -4/16, 4/16, 1, 4/16}
128 tile_images
= {texture
},
130 groups
= {snappy
=2,cracky
=3,oddly_breakable_by_hand
=3,fences
=1},
134 fixed
= {pillar
, full_blocks
[1]}
138 minetest
.register_node(nodename
.."_21", {
139 drawtype
= "nodebox",
142 fixed
= {-4/16, -1, -4/16, 4/16, 1, 4/16}
144 tile_images
= {texture
},
146 groups
= {snappy
=2,cracky
=3,oddly_breakable_by_hand
=3,fences
=1},
150 fixed
= {pillar
, full_blocks
[2]}
155 minetest
.register_node(nodename
, {
158 tile_images
= {texture
},
159 inventory_image
= invtex
,
161 drawtype
= "nodebox",
168 fixed
= {-4/16, -1, -4/16, 4/16, 1, 4/16}
170 collisionbox
= {-0.2, 0, -0.2, 0.2, 1.4, 0.2},
171 on_construct
= update_wall
177 register_wall("wallet:wall", "Cobblestone Wall", "default_cobble.png", "cobblestone_wallet.png")
178 minetest
.register_craft({
179 output
= 'wallet:wall 6',
181 {'default:cobble', 'default:cobble', 'default:cobble'},
182 {'default:cobble', 'default:cobble', 'default:cobble'}
188 register_wall("wallet:wallmossy", "Mossy Cobblestone Wall", "default_mossycobble.png", "cobblestonemossy_wallet.png")
189 minetest
.register_craft({
190 output
= 'wallet:wallmossy 6',
192 {'default:mossycobble', 'default:mossycobble', 'default:mossycobble'},
193 {'default:mossycobble', 'default:mossycobble', 'default:mossycobble'}
197 minetest
.register_on_placenode(update_wall_global
)
198 minetest
.register_on_dignode(update_wall_global
)