further cleaning
This commit is contained in:
parent
dc49a06701
commit
f8f38f4aa5
54
xwall.lua
54
xwall.lua
@ -13,10 +13,8 @@ local profiles = {
|
|||||||
{11, "_c3", 0}, {13, "_c3", 1}, {14, "_c3", 2}, {15, "_c4", 1}
|
{11, "_c3", 0}, {13, "_c3", 1}, {14, "_c3", 2}, {15, "_c4", 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i = 1, #profiles do
|
for _, p in pairs(profiles) do
|
||||||
local p = profiles[i]
|
xwall.get_candidate[p[1]] = {p[2], p[3]}
|
||||||
local p1, p2, p3 = p[1], p[2], p[3]
|
|
||||||
xwall.get_candidate[p1] = {p2, p3}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local directions = {
|
local directions = {
|
||||||
@ -30,8 +28,7 @@ function xwall.update_one_node(pos, name, digged)
|
|||||||
local pow2 = {1, 2, 4, 8}
|
local pow2 = {1, 2, 4, 8}
|
||||||
local id = 0
|
local id = 0
|
||||||
|
|
||||||
for i = 1, #directions do
|
for i, dir in pairs(directions) do
|
||||||
local dir = directions[i]
|
|
||||||
local node = minetest.get_node(vector.add(pos, dir))
|
local node = minetest.get_node(vector.add(pos, dir))
|
||||||
local ndef = minetest.registered_nodes[node.name]
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
|
|
||||||
@ -44,8 +41,8 @@ function xwall.update_one_node(pos, name, digged)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if digged then return candidates end
|
if digged then return candidates end
|
||||||
|
|
||||||
local newnode = xwall.get_candidate[id]
|
local newnode = xwall.get_candidate[id]
|
||||||
|
|
||||||
if newnode and newnode[1] then
|
if newnode and newnode[1] then
|
||||||
local newname = name:sub(1, name:len()-3)..newnode[1]
|
local newname = name:sub(1, name:len()-3)..newnode[1]
|
||||||
local regnode = minetest.registered_nodes[newname]
|
local regnode = minetest.registered_nodes[newname]
|
||||||
@ -64,41 +61,40 @@ function xwall.update(pos, name, active, has_been_digged)
|
|||||||
if not pos or not name or not minetest.registered_nodes[name] then return end
|
if not pos or not name or not minetest.registered_nodes[name] then return end
|
||||||
|
|
||||||
local c = xwall.update_one_node(pos, name, has_been_digged)
|
local c = xwall.update_one_node(pos, name, has_been_digged)
|
||||||
for j = 1, #directions do
|
for j, dir2 in pairs(directions) do
|
||||||
local dir2 = directions[j]
|
|
||||||
if c[j] ~= 0 and c[j] ~= "ignore" then
|
if c[j] ~= 0 and c[j] ~= "ignore" then
|
||||||
xwall.update_one_node(vector.add(pos, dir2), c[j], false)
|
xwall.update_one_node(vector.add(pos, dir2), c[j], false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function xwall.construct_node_box_data(node_box_list, center_node_box_list, node_box_line)
|
function xwall.construct_nodebox(nodebox_list, center_nodebox_list, nodebox_line)
|
||||||
local res = {}
|
local res = {}
|
||||||
res.c0, res.c1, res.c2, res.c3, res.c4 = {}, {}, {}, {}, {}
|
res.c0, res.c1, res.c2, res.c3, res.c4 = {}, {}, {}, {}, {}
|
||||||
|
|
||||||
for _, v in pairs(node_box_list) do
|
for _, v in pairs(nodebox_list) do
|
||||||
res.c1[#res.c1+1] = v
|
res.c1[#res.c1+1] = v
|
||||||
res.c2[#res.c2+1] = v
|
res.c2[#res.c2+1] = v
|
||||||
res.c3[#res.c3+1] = v
|
res.c3[#res.c3+1] = v
|
||||||
res.c4[#res.c4+1] = v
|
res.c4[#res.c4+1] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(node_box_list) do
|
for _, v in pairs(nodebox_list) do
|
||||||
res.c2[#res.c2+1] = {v[3], v[2], v[1], v[6], v[5], v[4]}
|
res.c2[#res.c2+1] = {v[3], v[2], v[1], v[6], v[5], v[4]}
|
||||||
res.c3[#res.c3+1] = {v[3], v[2], v[1], v[6], v[5], v[4]}
|
res.c3[#res.c3+1] = {v[3], v[2], v[1], v[6], v[5], v[4]}
|
||||||
res.c4[#res.c4+1] = {v[3], v[2], v[1], v[6], v[5], v[4]}
|
res.c4[#res.c4+1] = {v[3], v[2], v[1], v[6], v[5], v[4]}
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(node_box_list) do
|
for _, v in pairs(nodebox_list) do
|
||||||
res.c3[#res.c3+1] = {v[4], v[2], v[3]-0.5, v[1], v[5], v[6]-0.5}
|
res.c3[#res.c3+1] = {v[4], v[2], v[3]-0.5, v[1], v[5], v[6]-0.5}
|
||||||
res.c4[#res.c4+1] = {v[4], v[2], v[3]-0.5, v[1], v[5], v[6]-0.5}
|
res.c4[#res.c4+1] = {v[4], v[2], v[3]-0.5, v[1], v[5], v[6]-0.5}
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(node_box_list) do
|
for _, v in pairs(nodebox_list) do
|
||||||
res.c4[#res.c4+1] = {v[3]-0.5, v[2], v[4], v[6]-0.5, v[5], v[1]}
|
res.c4[#res.c4+1] = {v[3]-0.5, v[2], v[4], v[6]-0.5, v[5], v[1]}
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(center_node_box_list) do
|
for _, v in pairs(center_nodebox_list) do
|
||||||
res.c0[#res.c0+1] = v
|
res.c0[#res.c0+1] = v
|
||||||
res.c1[#res.c1+1] = v
|
res.c1[#res.c1+1] = v
|
||||||
res.c2[#res.c2+1] = v
|
res.c2[#res.c2+1] = v
|
||||||
@ -110,13 +106,13 @@ function xwall.construct_node_box_data(node_box_list, center_node_box_list, node
|
|||||||
res.c0 = nil
|
res.c0 = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
res.ln = node_box_line
|
res.ln = nodebox_line
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
function xwall.register_wall(name, tiles)
|
function xwall.register_wall(name, tiles)
|
||||||
local groups, def = {}, {}
|
local groups, def = {}, {}
|
||||||
local node_box_data = xwall.construct_node_box_data(
|
local nodebox_data = xwall.construct_nodebox(
|
||||||
{{-.1875,-.6875,0,.1875,.3125,.5}},
|
{{-.1875,-.6875,0,.1875,.3125,.5}},
|
||||||
{{-.25,-.6875,-.25,.25,.5,.25}},
|
{{-.25,-.6875,-.25,.25,.5,.25}},
|
||||||
{{-.1875,-.6875,-.5,.1875,.3125,.5}}
|
{{-.1875,-.6875,-.5,.1875,.3125,.5}}
|
||||||
@ -130,33 +126,33 @@ function xwall.register_wall(name, tiles)
|
|||||||
return groups
|
return groups
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in pairs(node_box_data) do
|
for k, v in pairs(nodebox_data) do
|
||||||
def = {
|
def = {
|
||||||
description = name:match("[%w_]+:(%a+)"):gsub("^%l", string.upper).." Wall",
|
description = name:gsub("^%l", string.upper).." Wall",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
tiles = {tiles},
|
tiles = {tiles},
|
||||||
drop = name.."_ln",
|
drop = "xdecor:"..name.."_wall_ln",
|
||||||
node_box = {type = "fixed", fixed = node_box_data[k]},
|
node_box = {type = "fixed", fixed = nodebox_data[k]},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
groups = group(k),
|
groups = group(k),
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
collision_box = {
|
collision_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-.5, -.5, -.25, .5, 1, .25}
|
fixed = {-.5,-.5,-.25,.5,1,.25}
|
||||||
},
|
},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
return xwall.update(pos, name.."_ln", true, nil)
|
return xwall.update(pos, "xdecor:"..name.."_wall_ln", true, nil)
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos, _, _, _)
|
after_dig_node = function(pos, _, _, _)
|
||||||
return xwall.update(pos, name.."_ln", true, true)
|
return xwall.update(pos, "xdecor:"..name.."_wall_ln", true, true)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
minetest.register_node(name.."_"..k, def)
|
minetest.register_node("xdecor:"..name.."_wall_"..k, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
xwall.register_wall("xdecor:cobble_wall", "default_cobble.png")
|
xwall.register_wall("cobble", "default_cobble.png")
|
||||||
xwall.register_wall("xdecor:mossycobble_wall", "default_mossycobble.png")
|
xwall.register_wall("mossycobble", "default_mossycobble.png")
|
||||||
|
Loading…
Reference in New Issue
Block a user