Walls: add legacy wallet, cleanup
This commit is contained in:
parent
6b438d856d
commit
14e523f4db
@ -29,7 +29,7 @@ walls.register = function(wall_name, wall_desc, wall_texture_table, wall_mat, wa
|
||||
groups = {cracky = 3, wall = 1, stone = 2, not_in_creative_inventory = 1},
|
||||
sounds = wall_sounds,
|
||||
drop = wall_name .. "_inv",
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
after_place_node = function(pos)
|
||||
local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
local pos_above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
local node_under = minetest.get_node(pos_under).name
|
||||
@ -43,7 +43,7 @@ walls.register = function(wall_name, wall_desc, wall_texture_table, wall_mat, wa
|
||||
minetest.set_node(pos, {name = wall_name .. "_full"})
|
||||
end
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
after_dig_node = function(pos, _, _, digger)
|
||||
local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
local node_under = string.gsub(minetest.get_node(pos_under).name, "_full$", "")
|
||||
if minetest.get_item_group(node_under, "wall") == 1 and
|
||||
@ -70,7 +70,7 @@ walls.register = function(wall_name, wall_desc, wall_texture_table, wall_mat, wa
|
||||
groups = {cracky = 3, wall = 1, stone = 2, not_in_creative_inventory = 1},
|
||||
sounds = wall_sounds,
|
||||
drop = wall_name .. "_inv",
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
after_dig_node = function(pos, _, _, digger)
|
||||
local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
local node_under = (minetest.get_node(pos_under).name):gsub("_full$", "")
|
||||
if minetest.get_item_group(node_under, "wall") == 1 and
|
||||
@ -123,3 +123,6 @@ walls.register("walls:sandstone", "Sandstone Wall", {"default_sandstone_normal.p
|
||||
|
||||
walls.register("walls:redsandstone", "Red Sandstone Wall", {"default_redsandstone_normal.png"},
|
||||
"default:redsandstone", default.node_sound_stone_defaults())
|
||||
|
||||
-- Legacy, but more beautiful walls
|
||||
dofile(minetest.get_modpath("walls") .. "/legacy.lua")
|
||||
|
@ -1,7 +1,3 @@
|
||||
local function rshift(x, by)
|
||||
return math.floor(x / 2 ^ by)
|
||||
end
|
||||
|
||||
local directions = {
|
||||
{x = 1, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 1},
|
||||
@ -10,30 +6,28 @@ local directions = {
|
||||
{x = 0, y = -1, z = 0}
|
||||
}
|
||||
|
||||
function update_wall(pos)
|
||||
local typewall = 0
|
||||
local function update_wall(pos)
|
||||
local oldnode = minetest.get_node(pos)
|
||||
local oldname = oldnode.name
|
||||
|
||||
if minetest.get_node(pos).name:find("wallet:wall") == 1 then
|
||||
typewall = typewall + 1
|
||||
if minetest.get_item_group(oldname, "wall") == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_node(pos).name:find("wallet:wallmossy") == 1 then
|
||||
typewall = typewall + 1
|
||||
end
|
||||
|
||||
if typewall == 0 then return end
|
||||
|
||||
local sum = 0
|
||||
for i = 1, 4 do
|
||||
local node = minetest.get_node({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z})
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
local dir = directions[i]
|
||||
local node = minetest.get_node({x = pos.x + dir.x, y = pos.y + dir.y, z = pos.z + dir.z})
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if def and def.walkable and def.groups.wall then
|
||||
sum = sum + 2 ^ (i - 1)
|
||||
end
|
||||
end
|
||||
|
||||
local node = minetest.get_node({x = pos.x, y = pos.y+1, z = pos.z})
|
||||
local upnode = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
|
||||
if sum == 5 or sum == 10 then
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
local def = minetest.registered_nodes[upnode.name]
|
||||
if def and def.walkable then
|
||||
sum = sum + 11
|
||||
end
|
||||
end
|
||||
@ -42,42 +36,44 @@ function update_wall(pos)
|
||||
sum = 15
|
||||
end
|
||||
|
||||
if typewall == 1 then
|
||||
minetest.add_node(pos, {name = "wallet:wall_"..sum})
|
||||
else
|
||||
minetest.add_node(pos, {name = "wallet:wallmossy_"..sum})
|
||||
if oldname:find("wallet:wallmossy") == 1 then
|
||||
minetest.add_node(pos, {name = "wallet:wallmossy" .. "_" .. sum})
|
||||
elseif oldname:find("wallet:wall") == 1 then
|
||||
minetest.add_node(pos, {name = "wallet:wall" .. "_" .. sum})
|
||||
end
|
||||
end
|
||||
|
||||
function update_wall_global(pos)
|
||||
for i = 1,5 do
|
||||
update_wall({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z})
|
||||
local function update_wall_global(pos)
|
||||
for i = 1, 5 do
|
||||
local dir = directions[i]
|
||||
update_wall({x = pos.x + dir.x, y = pos.y + dir.y, z = pos.z + dir.z})
|
||||
end
|
||||
end
|
||||
|
||||
local half_blocks = {
|
||||
{4/16, -0.5, -3/16, 0.5, 5/16, 3/16},
|
||||
{-3/16, -0.5, 4/16, 3/16, 5/16, 0.5},
|
||||
{-0.5, -0.5, -3/16, -4/16, 5/16, 3/16},
|
||||
{-3/16, -0.5, -0.5, 3/16, 5/16, -4/16}
|
||||
{ 1/4, -0.5, -3/16, 0.5, 5/16, 3/16},
|
||||
{-3/16, -0.5, 1/4, 3/16, 5/16, 0.5},
|
||||
{-0.5, -0.5, -3/16, -1/4, 5/16, 3/16},
|
||||
{-3/16, -0.5, -0.5, 3/16, 5/16, -1/4}
|
||||
}
|
||||
|
||||
local pillar = {-4/16, -0.5, -4/16, 4/16, 0.5, 4/16}
|
||||
local pillar = {-1/4, -0.5, -1/4, 1/4, 0.5, 1/4}
|
||||
|
||||
local full_blocks = {
|
||||
{-0.5, -0.5, -3/16, 0.5, 5/16, 3/16},
|
||||
{-3/16, -0.5, -0.5, 3/16, 5/16, 0.5}
|
||||
{-0.5, -0.5, -3/16, 0.5, 5/16, 3/16},
|
||||
{-3/16, -0.5, -0.5, 3/16, 5/16, 0.5}
|
||||
}
|
||||
|
||||
local collision = {
|
||||
{-4/16, -1, -4/16, 4/16, 1, 4/16}
|
||||
{-1/4, -0.5, -1/4, 1/4, 1, 1/4}
|
||||
}
|
||||
|
||||
for i = 0, 15 do
|
||||
local floor = math.floor
|
||||
for i = 1, 15 do
|
||||
local need = {}
|
||||
local need_pillar = false
|
||||
for j = 1, 4 do
|
||||
if rshift(i, j - 1) % 2 == 1 then
|
||||
if floor(i / 2 ^ (j - 1)) % 2 == 1 then
|
||||
need[j] = true
|
||||
end
|
||||
end
|
||||
@ -86,28 +82,33 @@ for i = 0, 15 do
|
||||
if need[1] and need[3] then
|
||||
need[1] = nil
|
||||
need[3] = nil
|
||||
table.insert(take, full_blocks[1])
|
||||
take[#take+1] = full_blocks[1]
|
||||
end
|
||||
if need[2] and need[4] then
|
||||
need[2] = nil
|
||||
need[4] = nil
|
||||
table.insert(take, full_blocks[2])
|
||||
take[#take+1] = full_blocks[2]
|
||||
end
|
||||
for k in pairs(need) do
|
||||
table.insert(take, half_blocks[k])
|
||||
take[#take+1] = half_blocks[k]
|
||||
need_pillar = true
|
||||
end
|
||||
if i == 15 or i == 0 then need_pillar = true end
|
||||
if need_pillar then table.insert(take, pillar) end
|
||||
if i == 15 then need_pillar = true end
|
||||
if need_pillar then
|
||||
take[#take+1] = pillar
|
||||
end
|
||||
|
||||
minetest.register_node("wallet:wall_"..i, {
|
||||
-- Wall
|
||||
minetest.register_node(":wallet:wall_" .. i, {
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = collision
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
is_ground_content = false,
|
||||
tiles = {"default_cobble.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drop = "wallet:wall",
|
||||
node_box = {
|
||||
@ -115,25 +116,32 @@ for i = 0, 15 do
|
||||
fixed = take
|
||||
}
|
||||
})
|
||||
|
||||
-- Mossy wall
|
||||
minetest.register_node(":wallet:wallmossy_" .. i, {
|
||||
drawtype = "nodebox",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = collision
|
||||
},
|
||||
tiles = {"default_mossycobble.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drop = "wallet:wallmossy",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = take
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_node("wallet:wall_0", {
|
||||
drawtype = "nodebox",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = collision
|
||||
},
|
||||
tiles = {"default_cobble.png"},
|
||||
paramtype = "light",
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drop = "wallet:wall",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = pillar
|
||||
}
|
||||
})
|
||||
minetest.register_alias("wallet:wall_0", "wallet:wall_15")
|
||||
minetest.register_alias("wallet:wallmossy_0", "wallet:wallmossy_15")
|
||||
|
||||
minetest.register_node("wallet:wall_16", {
|
||||
-- Wall
|
||||
minetest.register_node(":wallet:wall_16", {
|
||||
drawtype = "nodebox",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
@ -141,6 +149,8 @@ minetest.register_node("wallet:wall_16", {
|
||||
},
|
||||
tiles = {"default_cobble.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drop = "wallet:wall",
|
||||
node_box = {
|
||||
@ -149,7 +159,7 @@ minetest.register_node("wallet:wall_16", {
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("wallet:wall_21", {
|
||||
minetest.register_node(":wallet:wall_21", {
|
||||
drawtype = "nodebox",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
@ -157,6 +167,8 @@ minetest.register_node("wallet:wall_21", {
|
||||
},
|
||||
tiles = {"default_cobble.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drop = "wallet:wall",
|
||||
node_box = {
|
||||
@ -165,7 +177,7 @@ minetest.register_node("wallet:wall_21", {
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("wallet:wall", {
|
||||
minetest.register_node(":wallet:wall", {
|
||||
description = "Cobblestone Wall",
|
||||
paramtype = "light",
|
||||
tiles = {"default_cobble.png"},
|
||||
@ -176,13 +188,12 @@ minetest.register_node("wallet:wall", {
|
||||
fixed = {
|
||||
pillar,
|
||||
half_blocks[1],
|
||||
half_blocks[3],
|
||||
half_blocks[3]
|
||||
}
|
||||
},
|
||||
on_construct = update_wall
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "wallet:wall 6",
|
||||
recipe = {
|
||||
@ -191,69 +202,8 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- Mossy wallet
|
||||
|
||||
for i = 0, 15 do
|
||||
local need = {}
|
||||
local need_pillar = false
|
||||
for j = 1, 4 do
|
||||
if rshift(i, j - 1) % 2 == 1 then
|
||||
need[j] = true
|
||||
end
|
||||
end
|
||||
|
||||
local take = {}
|
||||
if need[1] and need[3] then
|
||||
need[1] = nil
|
||||
need[3] = nil
|
||||
table.insert(take, full_blocks[1])
|
||||
end
|
||||
if need[2] and need[4] then
|
||||
need[2] = nil
|
||||
need[4] = nil
|
||||
table.insert(take, full_blocks[2])
|
||||
end
|
||||
for k in pairs(need) do
|
||||
table.insert(take, half_blocks[k])
|
||||
need_pillar = true
|
||||
end
|
||||
if i == 15 or i == 0 then need_pillar = true end
|
||||
if need_pillar then table.insert(take, pillar) end
|
||||
|
||||
minetest.register_node("wallet:wallmossy_"..i, {
|
||||
drawtype = "nodebox",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = collision
|
||||
},
|
||||
tiles = {"default_mossycobble.png"},
|
||||
paramtype = "light",
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drop = "wallet:wallmossy",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = take
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_node("wallet:wallmossy_0", {
|
||||
drawtype = "nodebox",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = collision
|
||||
},
|
||||
tiles = {"default_mossycobble.png"},
|
||||
paramtype = "light",
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drop = "wallet:wallmossy",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = pillar
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("wallet:wallmossy_16", {
|
||||
-- Mossy wall
|
||||
minetest.register_node(":wallet:wallmossy_16", {
|
||||
drawtype = "nodebox",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
@ -261,6 +211,8 @@ minetest.register_node("wallet:wallmossy_16", {
|
||||
},
|
||||
tiles = {"default_mossycobble.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drop = "wallet:wallmossy",
|
||||
node_box = {
|
||||
@ -269,7 +221,7 @@ minetest.register_node("wallet:wallmossy_16", {
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("wallet:wallmossy_21", {
|
||||
minetest.register_node(":wallet:wallmossy_21", {
|
||||
drawtype = "nodebox",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
@ -277,6 +229,8 @@ minetest.register_node("wallet:wallmossy_21", {
|
||||
},
|
||||
tiles = {"default_mossycobble.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drop = "wallet:wallmossy",
|
||||
node_box = {
|
||||
@ -285,7 +239,7 @@ minetest.register_node("wallet:wallmossy_21", {
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("wallet:wallmossy", {
|
||||
minetest.register_node(":wallet:wallmossy", {
|
||||
description = "Mossy Cobblestone Wall",
|
||||
paramtype = "light",
|
||||
collision_box = {
|
||||
@ -293,6 +247,8 @@ minetest.register_node("wallet:wallmossy", {
|
||||
fixed = collision
|
||||
},
|
||||
tiles = {"default_mossycobble.png"},
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 3, wall = 1, stone = 2},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -300,16 +256,17 @@ minetest.register_node("wallet:wallmossy", {
|
||||
fixed = {
|
||||
pillar,
|
||||
half_blocks[1],
|
||||
half_blocks[3],
|
||||
half_blocks[3]
|
||||
}
|
||||
},
|
||||
on_construct = update_wall
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "wallet:wallmossy 6",
|
||||
recipe = {
|
||||
{"default:mossycobble", "default:mossycobble", "default:mossycobble"},
|
||||
{"default:mossycobble", "default:mossycobble", "default:mossycobble"}
|
||||
{"default:mossycobble", "default:mossycobble", "default:mossycobble"},
|
||||
{"default:mossycobble", "default:mossycobble", "default:mossycobble"}
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user