tidy code, re-add glass inner/outer slopes

This commit is contained in:
tenplus1 2023-05-21 14:38:42 +01:00
parent 8b4793a188
commit ad7fae1e67
2 changed files with 96 additions and 77 deletions

137
init.lua
View File

@ -11,6 +11,7 @@ function default.node_sound_wool_defaults(table)
return table return table
end end
-- add new 5.x snow sounds to 0.4.x client -- add new 5.x snow sounds to 0.4.x client
if not minetest.has_feature("object_use_texture_alpha") then if not minetest.has_feature("object_use_texture_alpha") then
@ -61,10 +62,7 @@ local set_textures = function(images, worldaligntex)
if type(image) == "string" then if type(image) == "string" then
stair_images[i] = { stair_images[i] = {name = image, backface_culling = true}
name = image,
backface_culling = true
}
if worldaligntex then if worldaligntex then
stair_images[i].align_style = "world" stair_images[i].align_style = "world"
@ -97,8 +95,7 @@ local stair_place = function(itemstack, placer, pointed_thing, stair_node)
local node_a = minetest.get_node(pos_a) local node_a = minetest.get_node(pos_a)
local def_a = minetest.registered_nodes[node_a.name] local def_a = minetest.registered_nodes[node_a.name]
if not def_a.buildable_to if not def_a.buildable_to or minetest.is_protected(pos_a, name) then
or minetest.is_protected(pos_a, name) then
return itemstack return itemstack
end end
@ -129,19 +126,7 @@ local stair_place = function(itemstack, placer, pointed_thing, stair_node)
end end
-- get node settings to use for stairs -- if recipeitem can be burned then stair can also
local function get_node_vars(nodename)
local def = minetest.registered_nodes[nodename] or {}
return def.light_source,
def.use_texture_alpha,
def.sunlight_propagates,
def.sounds
end
-- if recipeitem can be burned then stair can be as well
local function set_burn(recipeitem, stair_name, v) local function set_burn(recipeitem, stair_name, v)
local burntime = minetest.get_craft_result({ local burntime = minetest.get_craft_result({
@ -167,7 +152,7 @@ function stairs.register_stair(
new_groups.stair = 1 new_groups.stair = 1
local light, alpha, propa, soun = get_node_vars(recipeitem) local def = minetest.registered_nodes[recipeitem]
minetest.register_node(":stairs:stair_" .. subname, { minetest.register_node(":stairs:stair_" .. subname, {
description = description, description = description,
@ -176,11 +161,11 @@ function stairs.register_stair(
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
use_texture_alpha = alpha, use_texture_alpha = def.use_texture_alpha,
light_source = light, light_source = def.light_source,
sunlight_propagates = propa, sunlight_propagates = def.sunlight_propagates,
groups = new_groups, groups = new_groups,
sounds = snds or soun, sounds = snds or def.sounds,
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -190,9 +175,8 @@ function stairs.register_stair(
}, },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return stair_place(
return stair_place(itemstack, placer, pointed_thing, itemstack, placer, pointed_thing, "stairs:stair_" .. subname)
"stairs:stair_" .. subname)
end end
}) })
@ -242,7 +226,7 @@ function stairs.register_slab(
new_groups.slab = 1 new_groups.slab = 1
local light, alpha, propa, soun = get_node_vars(recipeitem) local def = minetest.registered_nodes[recipeitem]
minetest.register_node(":stairs:slab_" .. subname, { minetest.register_node(":stairs:slab_" .. subname, {
description = description, description = description,
@ -251,11 +235,11 @@ function stairs.register_slab(
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
use_texture_alpha = alpha, use_texture_alpha = def.use_texture_alpha,
light_source = light, light_source = def.light_source,
sunlight_propagates = propa, sunlight_propagates = def.sunlight_propagates,
groups = new_groups, groups = new_groups,
sounds = snds or soun, sounds = snds or def.sounds,
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5} fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}
@ -263,8 +247,8 @@ function stairs.register_slab(
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return stair_place(itemstack, placer, pointed_thing, return stair_place(
"stairs:slab_" .. subname) itemstack, placer, pointed_thing, "stairs:slab_" .. subname)
end end
}) })
@ -303,7 +287,7 @@ function stairs.register_stair_outer(
new_groups.stair = 1 new_groups.stair = 1
local light, alpha, propa, soun = get_node_vars(recipeitem) local def = minetest.registered_nodes[recipeitem]
minetest.register_node(":stairs:stair_outer_" .. subname, { minetest.register_node(":stairs:stair_outer_" .. subname, {
description = fdesc or "Outer " .. description, description = fdesc or "Outer " .. description,
@ -312,11 +296,11 @@ function stairs.register_stair_outer(
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
use_texture_alpha = alpha, use_texture_alpha = def.use_texture_alpha,
light_source = light, light_source = def.light_source,
sunlight_propagates = propa, sunlight_propagates = def.sunlight_propagates,
groups = new_groups, groups = new_groups,
sounds = snds or soun, sounds = snds or def.sounds,
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -327,8 +311,8 @@ function stairs.register_stair_outer(
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return stair_place(itemstack, placer, pointed_thing, return stair_place(
"stairs:stair_outer_" .. subname) itemstack, placer, pointed_thing, "stairs:stair_outer_" .. subname)
end end
}) })
@ -355,10 +339,8 @@ function stairs.register_stair_outer(
minetest.register_craft({ minetest.register_craft({
output = recipeitem .. " 2", output = recipeitem .. " 2",
recipe = { recipe = {
{"stairs:stair_outer_" .. subname, {"stairs:stair_outer_" .. subname, "stairs:stair_outer_" .. subname},
"stairs:stair_outer_" .. subname}, {"stairs:stair_outer_" .. subname, "stairs:stair_outer_" .. subname}
{"stairs:stair_outer_" .. subname,
"stairs:stair_outer_" .. subname}
} }
}) })
@ -375,7 +357,7 @@ function stairs.register_stair_inner(
new_groups.stair = 1 new_groups.stair = 1
local light, alpha, propa, soun = get_node_vars(recipeitem) local def = minetest.registered_nodes[recipeitem]
minetest.register_node(":stairs:stair_inner_" .. subname, { minetest.register_node(":stairs:stair_inner_" .. subname, {
description = fdesc or "Inner " .. description, description = fdesc or "Inner " .. description,
@ -384,11 +366,11 @@ function stairs.register_stair_inner(
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
use_texture_alpha = alpha, use_texture_alpha = def.use_texture_alpha,
light_source = light, light_source = def.light_source,
sunlight_propagates = propa, sunlight_propagates = def.sunlight_propagates,
groups = new_groups, groups = new_groups,
sounds = snds or soun, sounds = snds or def.sounds,
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -400,8 +382,8 @@ function stairs.register_stair_inner(
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return stair_place(itemstack, placer, pointed_thing, return stair_place(
"stairs:stair_inner_" .. subname) itemstack, placer, pointed_thing, "stairs:stair_inner_" .. subname)
end, end,
}) })
@ -428,10 +410,8 @@ function stairs.register_stair_inner(
minetest.register_craft({ minetest.register_craft({
output = recipeitem .. " 3", output = recipeitem .. " 3",
recipe = { recipe = {
{"stairs:stair_inner_" .. subname, {"stairs:stair_inner_" .. subname, "stairs:stair_inner_" .. subname},
"stairs:stair_inner_" .. subname}, {"stairs:stair_inner_" .. subname, "stairs:stair_inner_" .. subname}
{"stairs:stair_inner_" .. subname,
"stairs:stair_inner_" .. subname}
} }
}) })
@ -448,7 +428,7 @@ function stairs.register_slope(
new_groups.stair = 1 new_groups.stair = 1
local light, alpha, propa, soun = get_node_vars(recipeitem) local def = minetest.registered_nodes[recipeitem]
minetest.register_node(":stairs:slope_" .. subname, { minetest.register_node(":stairs:slope_" .. subname, {
description = description, description = description,
@ -458,11 +438,11 @@ function stairs.register_slope(
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
use_texture_alpha = alpha, use_texture_alpha = def.use_texture_alpha,
light_source = light, light_source = def.light_source,
sunlight_propagates = propa, sunlight_propagates = def.sunlight_propagates,
groups = new_groups, groups = new_groups,
sounds = snds or soun, sounds = snds or def.sounds,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -479,8 +459,9 @@ function stairs.register_slope(
}, },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return stair_place(itemstack, placer, pointed_thing,
"stairs:slope_" .. subname) return stair_place(
itemstack, placer, pointed_thing, "stairs:slope_" .. subname)
end end
}) })
@ -514,7 +495,7 @@ function stairs.register_slope_inner(
new_groups.stair = 1 new_groups.stair = 1
local light, alpha, propa, soun = get_node_vars(recipeitem) local def = minetest.registered_nodes[recipeitem]
minetest.register_node(":stairs:slope_inner_" .. subname, { minetest.register_node(":stairs:slope_inner_" .. subname, {
description = description, description = description,
@ -524,11 +505,11 @@ function stairs.register_slope_inner(
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
use_texture_alpha = alpha, use_texture_alpha = def.use_texture_alpha,
light_source = light, light_source = def.light_source,
sunlight_propagates = propa, sunlight_propagates = def.sunlight_propagates,
groups = new_groups, groups = new_groups,
sounds = snds or soun, sounds = snds or def.sounds,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -547,8 +528,9 @@ function stairs.register_slope_inner(
}, },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return stair_place(itemstack, placer, pointed_thing,
"stairs:slope_inner_" .. subname) return stair_place(
itemstack, placer, pointed_thing, "stairs:slope_inner_" .. subname)
end end
}) })
@ -582,7 +564,7 @@ function stairs.register_slope_outer(
new_groups.stair = 1 new_groups.stair = 1
local light, alpha, propa, soun = get_node_vars(recipeitem) local def = minetest.registered_nodes[recipeitem]
minetest.register_node(":stairs:slope_outer_" .. subname, { minetest.register_node(":stairs:slope_outer_" .. subname, {
description = description, description = description,
@ -592,11 +574,11 @@ function stairs.register_slope_outer(
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
use_texture_alpha = alpha, use_texture_alpha = def.use_texture_alpha,
light_source = light, light_source = def.light_source,
sunlight_propagates = propa, sunlight_propagates = def.sunlight_propagates,
groups = new_groups, groups = new_groups,
sounds = snds or soun, sounds = snds or def.sounds,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -613,8 +595,9 @@ function stairs.register_slope_outer(
}, },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return stair_place(itemstack, placer, pointed_thing,
"stairs:slope_outer_" .. subname) return stair_place(
itemstack, placer, pointed_thing, "stairs:slope_outer_" .. subname)
end end
}) })

View File

@ -314,6 +314,24 @@ stairs.register_slope(
stairs.glass stairs.glass
) )
stairs.register_slope_inner(
"glass",
"default:glass",
tmp,
{face_tex},
"Glass Inner Slope",
stairs.glass
)
stairs.register_slope_outer(
"glass",
"default:glass",
tmp,
{face_tex},
"Glass Outer Slope",
stairs.glass
)
-- Obsidian Glass (stairs registered seperately to use special texture) -- Obsidian Glass (stairs registered seperately to use special texture)
--stairs.register_all("obsidian_glass", "default:obsidian_glass", --stairs.register_all("obsidian_glass", "default:obsidian_glass",
@ -377,6 +395,24 @@ stairs.register_slope(
stairs.glass stairs.glass
) )
stairs.register_slope_inner(
"obsidian_glass",
"default:obsidian_glass",
tmp,
{face_tex},
"Obsidian Glass Inner Slope",
stairs.glass
)
stairs.register_slope_outer(
"obsidian_glass",
"default:obsidian_glass",
tmp,
{face_tex},
"Obsidian Glass Outer Slope",
stairs.glass
)
-- Brick, Snow and Ice -- Brick, Snow and Ice
stairs.register_all("brick", "default:brick", stairs.register_all("brick", "default:brick",