Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pull some parent node vars for stairs and slabs (#2911)
Fixes the sunlight propagation of glass stairs and slabs.

Co-authored-by: tenplus1 <tenplus1@users.noreply.github.com>
  • Loading branch information
yamanq and tenplus1 committed Dec 12, 2021
1 parent 60389a1 commit d775a9b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
6 changes: 6 additions & 0 deletions game_api.txt
Expand Up @@ -723,6 +723,12 @@ Stairs API
The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
delivered with Minetest Game, to keep them compatible with other mods.

The following node attributes are sourced from the recipeitem:
* use_texture_alpha
* sunlight_propagates
* light_source
* If the recipeitem is a fuel, the stair/slab is also registered as a fuel of proportionate burntime.

`stairs.register_stair(subname, recipeitem, groups, images, description, sounds, worldaligntex)`

* Registers a stair
Expand Down
35 changes: 27 additions & 8 deletions mods/stairs/init.lua
Expand Up @@ -57,13 +57,24 @@ local function warn_if_exists(nodename)
end
end

-- get node settings to use for stairs
local function get_node_vars(nodename)

local def = minetest.registered_nodes[nodename]

if def then
return def.light_source, def.use_texture_alpha, def.sunlight_propagates
end

return nil, nil, nil
end

-- Register stair
-- Node will be called stairs:stair_<subname>

function stairs.register_stair(subname, recipeitem, groups, images, description,
sounds, worldaligntex)
local src_def = minetest.registered_nodes[recipeitem]
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)

-- Set backface culling and world-aligned textures
local stair_images = {}
Expand Down Expand Up @@ -93,7 +104,9 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
description = description,
drawtype = "nodebox",
tiles = stair_images,
use_texture_alpha = src_def and src_def.use_texture_alpha,
use_texture_alpha = texture_alpha,
sunlight_propagates = sunlight,
light_source = light_source,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
Expand Down Expand Up @@ -165,7 +178,7 @@ end

function stairs.register_slab(subname, recipeitem, groups, images, description,
sounds, worldaligntex)
local src_def = minetest.registered_nodes[recipeitem]
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)

-- Set world-aligned textures
local slab_images = {}
Expand All @@ -191,7 +204,9 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
description = description,
drawtype = "nodebox",
tiles = slab_images,
use_texture_alpha = src_def and src_def.use_texture_alpha,
use_texture_alpha = texture_alpha,
sunlight_propagates = sunlight,
light_source = light_source,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
Expand Down Expand Up @@ -303,7 +318,7 @@ end

function stairs.register_stair_inner(subname, recipeitem, groups, images,
description, sounds, worldaligntex, full_description)
local src_def = minetest.registered_nodes[recipeitem]
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)

-- Set backface culling and world-aligned textures
local stair_images = {}
Expand Down Expand Up @@ -338,7 +353,9 @@ function stairs.register_stair_inner(subname, recipeitem, groups, images,
description = description,
drawtype = "nodebox",
tiles = stair_images,
use_texture_alpha = src_def and src_def.use_texture_alpha,
use_texture_alpha = texture_alpha,
sunlight_propagates = sunlight,
light_source = light_source,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
Expand Down Expand Up @@ -393,7 +410,7 @@ end

function stairs.register_stair_outer(subname, recipeitem, groups, images,
description, sounds, worldaligntex, full_description)
local src_def = minetest.registered_nodes[recipeitem]
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)

-- Set backface culling and world-aligned textures
local stair_images = {}
Expand Down Expand Up @@ -428,7 +445,9 @@ function stairs.register_stair_outer(subname, recipeitem, groups, images,
description = description,
drawtype = "nodebox",
tiles = stair_images,
use_texture_alpha = src_def and src_def.use_texture_alpha,
use_texture_alpha = texture_alpha,
sunlight_propagates = sunlight,
light_source = light_source,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
Expand Down

0 comments on commit d775a9b

Please sign in to comment.