mirror of
https://github.com/minetest/minetest_game.git
synced 2025-07-04 15:40:23 +02:00
Stairs: Add helper function for textures
Use function to tidy stair textures
This commit is contained in:
@ -63,7 +63,7 @@ local function warn_if_exists(nodename)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get node settings to use for stairs
|
-- Get node settings to use for stairs
|
||||||
local function get_node_vars(nodename)
|
local function get_node_vars(nodename)
|
||||||
|
|
||||||
local def = minetest.registered_nodes[nodename]
|
local def = minetest.registered_nodes[nodename]
|
||||||
@ -75,21 +75,12 @@ local function get_node_vars(nodename)
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register stair
|
-- Set backface culling and world-aligned textures
|
||||||
-- Node will be called stairs:stair_<subname>
|
local function set_textures(images, worldaligntex)
|
||||||
|
|
||||||
function stairs.register_stair(subname, recipeitem, groups, images, description,
|
|
||||||
sounds, worldaligntex)
|
|
||||||
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
|
|
||||||
|
|
||||||
-- Set backface culling and world-aligned textures
|
|
||||||
local stair_images = {}
|
local stair_images = {}
|
||||||
for i, image in ipairs(images) do
|
for i, image in ipairs(images) do
|
||||||
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"
|
||||||
end
|
end
|
||||||
@ -103,6 +94,16 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return stair_images
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Register stair
|
||||||
|
-- Node will be called stairs:stair_<subname>
|
||||||
|
|
||||||
|
function stairs.register_stair(subname, recipeitem, groups, images, description,
|
||||||
|
sounds, worldaligntex)
|
||||||
|
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
|
||||||
|
local stair_images = set_textures(images, worldaligntex)
|
||||||
local new_groups = table.copy(groups)
|
local new_groups = table.copy(groups)
|
||||||
new_groups.stair = 1
|
new_groups.stair = 1
|
||||||
warn_if_exists("stairs:stair_" .. subname)
|
warn_if_exists("stairs:stair_" .. subname)
|
||||||
@ -185,24 +186,7 @@ end
|
|||||||
function stairs.register_slab(subname, recipeitem, groups, images, description,
|
function stairs.register_slab(subname, recipeitem, groups, images, description,
|
||||||
sounds, worldaligntex)
|
sounds, worldaligntex)
|
||||||
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
|
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
|
||||||
|
local slab_images = set_textures(images, worldaligntex)
|
||||||
-- Set world-aligned textures
|
|
||||||
local slab_images = {}
|
|
||||||
for i, image in ipairs(images) do
|
|
||||||
if type(image) == "string" then
|
|
||||||
slab_images[i] = {
|
|
||||||
name = image,
|
|
||||||
}
|
|
||||||
if worldaligntex then
|
|
||||||
slab_images[i].align_style = "world"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
slab_images[i] = table.copy(image)
|
|
||||||
if worldaligntex and image.align_style == nil then
|
|
||||||
slab_images[i].align_style = "world"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local new_groups = table.copy(groups)
|
local new_groups = table.copy(groups)
|
||||||
new_groups.slab = 1
|
new_groups.slab = 1
|
||||||
warn_if_exists("stairs:slab_" .. subname)
|
warn_if_exists("stairs:slab_" .. subname)
|
||||||
@ -325,28 +309,7 @@ end
|
|||||||
function stairs.register_stair_inner(subname, recipeitem, groups, images,
|
function stairs.register_stair_inner(subname, recipeitem, groups, images,
|
||||||
description, sounds, worldaligntex, full_description)
|
description, sounds, worldaligntex, full_description)
|
||||||
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
|
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
|
||||||
|
local stair_images = set_textures(images, worldaligntex)
|
||||||
-- Set backface culling and world-aligned textures
|
|
||||||
local stair_images = {}
|
|
||||||
for i, image in ipairs(images) do
|
|
||||||
if type(image) == "string" then
|
|
||||||
stair_images[i] = {
|
|
||||||
name = image,
|
|
||||||
backface_culling = true,
|
|
||||||
}
|
|
||||||
if worldaligntex then
|
|
||||||
stair_images[i].align_style = "world"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
stair_images[i] = table.copy(image)
|
|
||||||
if stair_images[i].backface_culling == nil then
|
|
||||||
stair_images[i].backface_culling = true
|
|
||||||
end
|
|
||||||
if worldaligntex and stair_images[i].align_style == nil then
|
|
||||||
stair_images[i].align_style = "world"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local new_groups = table.copy(groups)
|
local new_groups = table.copy(groups)
|
||||||
new_groups.stair = 1
|
new_groups.stair = 1
|
||||||
if full_description then
|
if full_description then
|
||||||
@ -417,28 +380,7 @@ end
|
|||||||
function stairs.register_stair_outer(subname, recipeitem, groups, images,
|
function stairs.register_stair_outer(subname, recipeitem, groups, images,
|
||||||
description, sounds, worldaligntex, full_description)
|
description, sounds, worldaligntex, full_description)
|
||||||
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
|
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
|
||||||
|
local stair_images = set_textures(images, worldaligntex)
|
||||||
-- Set backface culling and world-aligned textures
|
|
||||||
local stair_images = {}
|
|
||||||
for i, image in ipairs(images) do
|
|
||||||
if type(image) == "string" then
|
|
||||||
stair_images[i] = {
|
|
||||||
name = image,
|
|
||||||
backface_culling = true,
|
|
||||||
}
|
|
||||||
if worldaligntex then
|
|
||||||
stair_images[i].align_style = "world"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
stair_images[i] = table.copy(image)
|
|
||||||
if stair_images[i].backface_culling == nil then
|
|
||||||
stair_images[i].backface_culling = true
|
|
||||||
end
|
|
||||||
if worldaligntex and stair_images[i].align_style == nil then
|
|
||||||
stair_images[i].align_style = "world"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local new_groups = table.copy(groups)
|
local new_groups = table.copy(groups)
|
||||||
new_groups.stair = 1
|
new_groups.stair = 1
|
||||||
if full_description then
|
if full_description then
|
||||||
|
Reference in New Issue
Block a user