Skip to content

Commit d775a9b

Browse files
yamanqtenplus1
andauthoredDec 12, 2021
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>
1 parent 60389a1 commit d775a9b

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed
 

Diff for: ‎game_api.txt

+6
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,12 @@ Stairs API
723723
The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
724724
delivered with Minetest Game, to keep them compatible with other mods.
725725

726+
The following node attributes are sourced from the recipeitem:
727+
* use_texture_alpha
728+
* sunlight_propagates
729+
* light_source
730+
* If the recipeitem is a fuel, the stair/slab is also registered as a fuel of proportionate burntime.
731+
726732
`stairs.register_stair(subname, recipeitem, groups, images, description, sounds, worldaligntex)`
727733

728734
* Registers a stair

Diff for: ‎mods/stairs/init.lua

+27-8
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,24 @@ local function warn_if_exists(nodename)
5757
end
5858
end
5959

60+
-- get node settings to use for stairs
61+
local function get_node_vars(nodename)
62+
63+
local def = minetest.registered_nodes[nodename]
64+
65+
if def then
66+
return def.light_source, def.use_texture_alpha, def.sunlight_propagates
67+
end
68+
69+
return nil, nil, nil
70+
end
6071

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

6475
function stairs.register_stair(subname, recipeitem, groups, images, description,
6576
sounds, worldaligntex)
66-
local src_def = minetest.registered_nodes[recipeitem]
77+
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
6778

6879
-- Set backface culling and world-aligned textures
6980
local stair_images = {}
@@ -93,7 +104,9 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
93104
description = description,
94105
drawtype = "nodebox",
95106
tiles = stair_images,
96-
use_texture_alpha = src_def and src_def.use_texture_alpha,
107+
use_texture_alpha = texture_alpha,
108+
sunlight_propagates = sunlight,
109+
light_source = light_source,
97110
paramtype = "light",
98111
paramtype2 = "facedir",
99112
is_ground_content = false,
@@ -165,7 +178,7 @@ end
165178

166179
function stairs.register_slab(subname, recipeitem, groups, images, description,
167180
sounds, worldaligntex)
168-
local src_def = minetest.registered_nodes[recipeitem]
181+
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
169182

170183
-- Set world-aligned textures
171184
local slab_images = {}
@@ -191,7 +204,9 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
191204
description = description,
192205
drawtype = "nodebox",
193206
tiles = slab_images,
194-
use_texture_alpha = src_def and src_def.use_texture_alpha,
207+
use_texture_alpha = texture_alpha,
208+
sunlight_propagates = sunlight,
209+
light_source = light_source,
195210
paramtype = "light",
196211
paramtype2 = "facedir",
197212
is_ground_content = false,
@@ -303,7 +318,7 @@ end
303318

304319
function stairs.register_stair_inner(subname, recipeitem, groups, images,
305320
description, sounds, worldaligntex, full_description)
306-
local src_def = minetest.registered_nodes[recipeitem]
321+
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
307322

308323
-- Set backface culling and world-aligned textures
309324
local stair_images = {}
@@ -338,7 +353,9 @@ function stairs.register_stair_inner(subname, recipeitem, groups, images,
338353
description = description,
339354
drawtype = "nodebox",
340355
tiles = stair_images,
341-
use_texture_alpha = src_def and src_def.use_texture_alpha,
356+
use_texture_alpha = texture_alpha,
357+
sunlight_propagates = sunlight,
358+
light_source = light_source,
342359
paramtype = "light",
343360
paramtype2 = "facedir",
344361
is_ground_content = false,
@@ -393,7 +410,7 @@ end
393410

394411
function stairs.register_stair_outer(subname, recipeitem, groups, images,
395412
description, sounds, worldaligntex, full_description)
396-
local src_def = minetest.registered_nodes[recipeitem]
413+
local light_source, texture_alpha, sunlight = get_node_vars(recipeitem)
397414

398415
-- Set backface culling and world-aligned textures
399416
local stair_images = {}
@@ -428,7 +445,9 @@ function stairs.register_stair_outer(subname, recipeitem, groups, images,
428445
description = description,
429446
drawtype = "nodebox",
430447
tiles = stair_images,
431-
use_texture_alpha = src_def and src_def.use_texture_alpha,
448+
use_texture_alpha = texture_alpha,
449+
sunlight_propagates = sunlight,
450+
light_source = light_source,
432451
paramtype = "light",
433452
paramtype2 = "facedir",
434453
is_ground_content = false,

0 commit comments

Comments
 (0)
Please sign in to comment.