1-- stairs/init.lua
2
3-- Minetest 0.4 mod: stairs
4-- See README.txt for licensing and other information.
5
6
7-- Global namespace for functions
8
9stairs = {}
10
11-- Load support for MT game translation.
12local S = minetest.get_translator("stairs")
13-- Same as S, but will be ignored by translation file update scripts
14local T = S
15
16
17-- Register aliases for new pine node names
18
19minetest.register_alias("stairs:stair_pinewood", "stairs:stair_pine_wood")
20minetest.register_alias("stairs:slab_pinewood", "stairs:slab_pine_wood")
21
22
23-- Get setting for replace ABM
24
25local replace = minetest.settings:get_bool("enable_stairs_replace_abm")
26
27local function rotate_and_place(itemstack, placer, pointed_thing)
28	local p0 = pointed_thing.under
29	local p1 = pointed_thing.above
30	local param2 = 0
31
32	if placer then
33		local placer_pos = placer:get_pos()
34		if placer_pos then
35			param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos))
36		end
37
38		local finepos = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
39		local fpos = finepos.y % 1
40
41		if p0.y - 1 == p1.y or (fpos > 0 and fpos < 0.5)
42				or (fpos < -0.5 and fpos > -0.999999999) then
43			param2 = param2 + 20
44			if param2 == 21 then
45				param2 = 23
46			elseif param2 == 23 then
47				param2 = 21
48			end
49		end
50	end
51	return minetest.item_place(itemstack, placer, pointed_thing, param2)
52end
53
54local function warn_if_exists(nodename)
55	if minetest.registered_nodes[nodename] then
56		minetest.log("warning", "Overwriting stairs node: " .. nodename)
57	end
58end
59
60
61-- Register stair
62-- Node will be called stairs:stair_<subname>
63
64function stairs.register_stair(subname, recipeitem, groups, images, description,
65		sounds, worldaligntex)
66	local src_def = minetest.registered_nodes[recipeitem]
67
68	-- Set backface culling and world-aligned textures
69	local stair_images = {}
70	for i, image in ipairs(images) do
71		if type(image) == "string" then
72			stair_images[i] = {
73				name = image,
74				backface_culling = true,
75			}
76			if worldaligntex then
77				stair_images[i].align_style = "world"
78			end
79		else
80			stair_images[i] = table.copy(image)
81			if stair_images[i].backface_culling == nil then
82				stair_images[i].backface_culling = true
83			end
84			if worldaligntex and stair_images[i].align_style == nil then
85				stair_images[i].align_style = "world"
86			end
87		end
88	end
89	local new_groups = table.copy(groups)
90	new_groups.stair = 1
91	warn_if_exists("stairs:stair_" .. subname)
92	minetest.register_node(":stairs:stair_" .. subname, {
93		description = description,
94		drawtype = "nodebox",
95		tiles = stair_images,
96		use_texture_alpha = src_def and src_def.use_texture_alpha,
97		paramtype = "light",
98		paramtype2 = "facedir",
99		is_ground_content = false,
100		groups = new_groups,
101		sounds = sounds,
102		node_box = {
103			type = "fixed",
104			fixed = {
105				{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
106				{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
107			},
108		},
109		on_place = function(itemstack, placer, pointed_thing)
110			if pointed_thing.type ~= "node" then
111				return itemstack
112			end
113
114			return rotate_and_place(itemstack, placer, pointed_thing)
115		end,
116	})
117
118	-- for replace ABM
119	if replace then
120		minetest.register_node(":stairs:stair_" .. subname .. "upside_down", {
121			replace_name = "stairs:stair_" .. subname,
122			groups = {slabs_replace = 1},
123		})
124	end
125
126	if recipeitem then
127		-- Recipe matches appearence in inventory
128		minetest.register_craft({
129			output = "stairs:stair_" .. subname .. " 8",
130			recipe = {
131				{"", "", recipeitem},
132				{"", recipeitem, recipeitem},
133				{recipeitem, recipeitem, recipeitem},
134			},
135		})
136
137		-- Use stairs to craft full blocks again (1:1)
138		minetest.register_craft({
139			output = recipeitem .. " 3",
140			recipe = {
141				{"stairs:stair_" .. subname, "stairs:stair_" .. subname},
142				{"stairs:stair_" .. subname, "stairs:stair_" .. subname},
143			},
144		})
145
146		-- Fuel
147		local baseburntime = minetest.get_craft_result({
148			method = "fuel",
149			width = 1,
150			items = {recipeitem}
151		}).time
152		if baseburntime > 0 then
153			minetest.register_craft({
154				type = "fuel",
155				recipe = "stairs:stair_" .. subname,
156				burntime = math.floor(baseburntime * 0.75),
157			})
158		end
159	end
160end
161
162
163-- Register slab
164-- Node will be called stairs:slab_<subname>
165
166function stairs.register_slab(subname, recipeitem, groups, images, description,
167		sounds, worldaligntex)
168	local src_def = minetest.registered_nodes[recipeitem]
169
170	-- Set world-aligned textures
171	local slab_images = {}
172	for i, image in ipairs(images) do
173		if type(image) == "string" then
174			slab_images[i] = {
175				name = image,
176			}
177			if worldaligntex then
178				slab_images[i].align_style = "world"
179			end
180		else
181			slab_images[i] = table.copy(image)
182			if worldaligntex and image.align_style == nil then
183				slab_images[i].align_style = "world"
184			end
185		end
186	end
187	local new_groups = table.copy(groups)
188	new_groups.slab = 1
189	warn_if_exists("stairs:slab_" .. subname)
190	minetest.register_node(":stairs:slab_" .. subname, {
191		description = description,
192		drawtype = "nodebox",
193		tiles = slab_images,
194		use_texture_alpha = src_def and src_def.use_texture_alpha,
195		paramtype = "light",
196		paramtype2 = "facedir",
197		is_ground_content = false,
198		groups = new_groups,
199		sounds = sounds,
200		node_box = {
201			type = "fixed",
202			fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
203		},
204		on_place = function(itemstack, placer, pointed_thing)
205			local under = minetest.get_node(pointed_thing.under)
206			local wield_item = itemstack:get_name()
207			local player_name = placer and placer:get_player_name() or ""
208
209			if under and under.name:find("^stairs:slab_") then
210				-- place slab using under node orientation
211				local dir = minetest.dir_to_facedir(vector.subtract(
212					pointed_thing.above, pointed_thing.under), true)
213
214				local p2 = under.param2
215
216				-- Placing a slab on an upside down slab should make it right-side up.
217				if p2 >= 20 and dir == 8 then
218					p2 = p2 - 20
219				-- same for the opposite case: slab below normal slab
220				elseif p2 <= 3 and dir == 4 then
221					p2 = p2 + 20
222				end
223
224				-- else attempt to place node with proper param2
225				minetest.item_place_node(ItemStack(wield_item), placer, pointed_thing, p2)
226				if not minetest.is_creative_enabled(player_name) then
227					itemstack:take_item()
228				end
229				return itemstack
230			else
231				return rotate_and_place(itemstack, placer, pointed_thing)
232			end
233		end,
234	})
235
236	-- for replace ABM
237	if replace then
238		minetest.register_node(":stairs:slab_" .. subname .. "upside_down", {
239			replace_name = "stairs:slab_".. subname,
240			groups = {slabs_replace = 1},
241		})
242	end
243
244	if recipeitem then
245		minetest.register_craft({
246			output = "stairs:slab_" .. subname .. " 6",
247			recipe = {
248				{recipeitem, recipeitem, recipeitem},
249			},
250		})
251
252		-- Use 2 slabs to craft a full block again (1:1)
253		minetest.register_craft({
254			output = recipeitem,
255			recipe = {
256				{"stairs:slab_" .. subname},
257				{"stairs:slab_" .. subname},
258			},
259		})
260
261		-- Fuel
262		local baseburntime = minetest.get_craft_result({
263			method = "fuel",
264			width = 1,
265			items = {recipeitem}
266		}).time
267		if baseburntime > 0 then
268			minetest.register_craft({
269				type = "fuel",
270				recipe = "stairs:slab_" .. subname,
271				burntime = math.floor(baseburntime * 0.5),
272			})
273		end
274	end
275end
276
277
278-- Optionally replace old "upside_down" nodes with new param2 versions.
279-- Disabled by default.
280
281if replace then
282	minetest.register_abm({
283		label = "Slab replace",
284		nodenames = {"group:slabs_replace"},
285		interval = 16,
286		chance = 1,
287		action = function(pos, node)
288			node.name = minetest.registered_nodes[node.name].replace_name
289			node.param2 = node.param2 + 20
290			if node.param2 == 21 then
291				node.param2 = 23
292			elseif node.param2 == 23 then
293				node.param2 = 21
294			end
295			minetest.set_node(pos, node)
296		end,
297	})
298end
299
300
301-- Register inner stair
302-- Node will be called stairs:stair_inner_<subname>
303
304function stairs.register_stair_inner(subname, recipeitem, groups, images,
305		description, sounds, worldaligntex, full_description)
306	local src_def = minetest.registered_nodes[recipeitem]
307
308	-- Set backface culling and world-aligned textures
309	local stair_images = {}
310	for i, image in ipairs(images) do
311		if type(image) == "string" then
312			stair_images[i] = {
313				name = image,
314				backface_culling = true,
315			}
316			if worldaligntex then
317				stair_images[i].align_style = "world"
318			end
319		else
320			stair_images[i] = table.copy(image)
321			if stair_images[i].backface_culling == nil then
322				stair_images[i].backface_culling = true
323			end
324			if worldaligntex and stair_images[i].align_style == nil then
325				stair_images[i].align_style = "world"
326			end
327		end
328	end
329	local new_groups = table.copy(groups)
330	new_groups.stair = 1
331	if full_description then
332		description = full_description
333	else
334		description = "Inner " .. description
335	end
336	warn_if_exists("stairs:stair_inner_" .. subname)
337	minetest.register_node(":stairs:stair_inner_" .. subname, {
338		description = description,
339		drawtype = "nodebox",
340		tiles = stair_images,
341		use_texture_alpha = src_def and src_def.use_texture_alpha,
342		paramtype = "light",
343		paramtype2 = "facedir",
344		is_ground_content = false,
345		groups = new_groups,
346		sounds = sounds,
347		node_box = {
348			type = "fixed",
349			fixed = {
350				{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
351				{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
352				{-0.5, 0.0, -0.5, 0.0, 0.5, 0.0},
353			},
354		},
355		on_place = function(itemstack, placer, pointed_thing)
356			if pointed_thing.type ~= "node" then
357				return itemstack
358			end
359
360			return rotate_and_place(itemstack, placer, pointed_thing)
361		end,
362	})
363
364	if recipeitem then
365		minetest.register_craft({
366			output = "stairs:stair_inner_" .. subname .. " 7",
367			recipe = {
368				{"", recipeitem, ""},
369				{recipeitem, "", recipeitem},
370				{recipeitem, recipeitem, recipeitem},
371			},
372		})
373
374		-- Fuel
375		local baseburntime = minetest.get_craft_result({
376			method = "fuel",
377			width = 1,
378			items = {recipeitem}
379		}).time
380		if baseburntime > 0 then
381			minetest.register_craft({
382				type = "fuel",
383				recipe = "stairs:stair_inner_" .. subname,
384				burntime = math.floor(baseburntime * 0.875),
385			})
386		end
387	end
388end
389
390
391-- Register outer stair
392-- Node will be called stairs:stair_outer_<subname>
393
394function stairs.register_stair_outer(subname, recipeitem, groups, images,
395		description, sounds, worldaligntex, full_description)
396	local src_def = minetest.registered_nodes[recipeitem]
397
398	-- Set backface culling and world-aligned textures
399	local stair_images = {}
400	for i, image in ipairs(images) do
401		if type(image) == "string" then
402			stair_images[i] = {
403				name = image,
404				backface_culling = true,
405			}
406			if worldaligntex then
407				stair_images[i].align_style = "world"
408			end
409		else
410			stair_images[i] = table.copy(image)
411			if stair_images[i].backface_culling == nil then
412				stair_images[i].backface_culling = true
413			end
414			if worldaligntex and stair_images[i].align_style == nil then
415				stair_images[i].align_style = "world"
416			end
417		end
418	end
419	local new_groups = table.copy(groups)
420	new_groups.stair = 1
421	if full_description then
422		description = full_description
423	else
424		description = "Outer " .. description
425	end
426	warn_if_exists("stairs:stair_outer_" .. subname)
427	minetest.register_node(":stairs:stair_outer_" .. subname, {
428		description = description,
429		drawtype = "nodebox",
430		tiles = stair_images,
431		use_texture_alpha = src_def and src_def.use_texture_alpha,
432		paramtype = "light",
433		paramtype2 = "facedir",
434		is_ground_content = false,
435		groups = new_groups,
436		sounds = sounds,
437		node_box = {
438			type = "fixed",
439			fixed = {
440				{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
441				{-0.5, 0.0, 0.0, 0.0, 0.5, 0.5},
442			},
443		},
444		on_place = function(itemstack, placer, pointed_thing)
445			if pointed_thing.type ~= "node" then
446				return itemstack
447			end
448
449			return rotate_and_place(itemstack, placer, pointed_thing)
450		end,
451	})
452
453	if recipeitem then
454		minetest.register_craft({
455			output = "stairs:stair_outer_" .. subname .. " 6",
456			recipe = {
457				{"", recipeitem, ""},
458				{recipeitem, recipeitem, recipeitem},
459			},
460		})
461
462		-- Fuel
463		local baseburntime = minetest.get_craft_result({
464			method = "fuel",
465			width = 1,
466			items = {recipeitem}
467		}).time
468		if baseburntime > 0 then
469			minetest.register_craft({
470				type = "fuel",
471				recipe = "stairs:stair_outer_" .. subname,
472				burntime = math.floor(baseburntime * 0.625),
473			})
474		end
475	end
476end
477
478
479-- Stair/slab registration function.
480-- Nodes will be called stairs:{stair,slab}_<subname>
481
482function stairs.register_stair_and_slab(subname, recipeitem, groups, images,
483		desc_stair, desc_slab, sounds, worldaligntex,
484		desc_stair_inner, desc_stair_outer)
485	stairs.register_stair(subname, recipeitem, groups, images, desc_stair,
486		sounds, worldaligntex)
487	stairs.register_stair_inner(subname, recipeitem, groups, images,
488		desc_stair, sounds, worldaligntex, desc_stair_inner)
489	stairs.register_stair_outer(subname, recipeitem, groups, images,
490		desc_stair, sounds, worldaligntex, desc_stair_outer)
491	stairs.register_slab(subname, recipeitem, groups, images, desc_slab,
492		sounds, worldaligntex)
493end
494
495-- Local function so we can apply translations
496local function my_register_stair_and_slab(subname, recipeitem, groups, images,
497		desc_stair, desc_slab, sounds, worldaligntex)
498	stairs.register_stair(subname, recipeitem, groups, images, S(desc_stair),
499		sounds, worldaligntex)
500	stairs.register_stair_inner(subname, recipeitem, groups, images, "",
501		sounds, worldaligntex, T("Inner " .. desc_stair))
502	stairs.register_stair_outer(subname, recipeitem, groups, images, "",
503		sounds, worldaligntex, T("Outer " .. desc_stair))
504	stairs.register_slab(subname, recipeitem, groups, images, S(desc_slab),
505		sounds, worldaligntex)
506end
507
508
509-- Register default stairs and slabs
510
511my_register_stair_and_slab(
512	"wood",
513	"default:wood",
514	{choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
515	{"default_wood.png"},
516	"Wooden Stair",
517	"Wooden Slab",
518	default.node_sound_wood_defaults(),
519	false
520)
521
522my_register_stair_and_slab(
523	"junglewood",
524	"default:junglewood",
525	{choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
526	{"default_junglewood.png"},
527	"Jungle Wood Stair",
528	"Jungle Wood Slab",
529	default.node_sound_wood_defaults(),
530	false
531)
532
533my_register_stair_and_slab(
534	"pine_wood",
535	"default:pine_wood",
536	{choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
537	{"default_pine_wood.png"},
538	"Pine Wood Stair",
539	"Pine Wood Slab",
540	default.node_sound_wood_defaults(),
541	false
542)
543
544my_register_stair_and_slab(
545	"acacia_wood",
546	"default:acacia_wood",
547	{choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
548	{"default_acacia_wood.png"},
549	"Acacia Wood Stair",
550	"Acacia Wood Slab",
551	default.node_sound_wood_defaults(),
552	false
553)
554
555my_register_stair_and_slab(
556	"aspen_wood",
557	"default:aspen_wood",
558	{choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
559	{"default_aspen_wood.png"},
560	"Aspen Wood Stair",
561	"Aspen Wood Slab",
562	default.node_sound_wood_defaults(),
563	false
564)
565
566my_register_stair_and_slab(
567	"stone",
568	"default:stone",
569	{cracky = 3},
570	{"default_stone.png"},
571	"Stone Stair",
572	"Stone Slab",
573	default.node_sound_stone_defaults(),
574	true
575)
576
577my_register_stair_and_slab(
578	"cobble",
579	"default:cobble",
580	{cracky = 3},
581	{"default_cobble.png"},
582	"Cobblestone Stair",
583	"Cobblestone Slab",
584	default.node_sound_stone_defaults(),
585	true
586)
587
588my_register_stair_and_slab(
589	"mossycobble",
590	"default:mossycobble",
591	{cracky = 3},
592	{"default_mossycobble.png"},
593	"Mossy Cobblestone Stair",
594	"Mossy Cobblestone Slab",
595	default.node_sound_stone_defaults(),
596	true
597)
598
599my_register_stair_and_slab(
600	"stonebrick",
601	"default:stonebrick",
602	{cracky = 2},
603	{"default_stone_brick.png"},
604	"Stone Brick Stair",
605	"Stone Brick Slab",
606	default.node_sound_stone_defaults(),
607	false
608)
609
610my_register_stair_and_slab(
611	"stone_block",
612	"default:stone_block",
613	{cracky = 2},
614	{"default_stone_block.png"},
615	"Stone Block Stair",
616	"Stone Block Slab",
617	default.node_sound_stone_defaults(),
618	true
619)
620
621my_register_stair_and_slab(
622	"desert_stone",
623	"default:desert_stone",
624	{cracky = 3},
625	{"default_desert_stone.png"},
626	"Desert Stone Stair",
627	"Desert Stone Slab",
628	default.node_sound_stone_defaults(),
629	true
630)
631
632my_register_stair_and_slab(
633	"desert_cobble",
634	"default:desert_cobble",
635	{cracky = 3},
636	{"default_desert_cobble.png"},
637	"Desert Cobblestone Stair",
638	"Desert Cobblestone Slab",
639	default.node_sound_stone_defaults(),
640	true
641)
642
643my_register_stair_and_slab(
644	"desert_stonebrick",
645	"default:desert_stonebrick",
646	{cracky = 2},
647	{"default_desert_stone_brick.png"},
648	"Desert Stone Brick Stair",
649	"Desert Stone Brick Slab",
650	default.node_sound_stone_defaults(),
651	false
652)
653
654my_register_stair_and_slab(
655	"desert_stone_block",
656	"default:desert_stone_block",
657	{cracky = 2},
658	{"default_desert_stone_block.png"},
659	"Desert Stone Block Stair",
660	"Desert Stone Block Slab",
661	default.node_sound_stone_defaults(),
662	true
663)
664
665my_register_stair_and_slab(
666	"sandstone",
667	"default:sandstone",
668	{crumbly = 1, cracky = 3},
669	{"default_sandstone.png"},
670	"Sandstone Stair",
671	"Sandstone Slab",
672	default.node_sound_stone_defaults(),
673	true
674)
675
676my_register_stair_and_slab(
677	"sandstonebrick",
678	"default:sandstonebrick",
679	{cracky = 2},
680	{"default_sandstone_brick.png"},
681	"Sandstone Brick Stair",
682	"Sandstone Brick Slab",
683	default.node_sound_stone_defaults(),
684	false
685)
686
687my_register_stair_and_slab(
688	"sandstone_block",
689	"default:sandstone_block",
690	{cracky = 2},
691	{"default_sandstone_block.png"},
692	"Sandstone Block Stair",
693	"Sandstone Block Slab",
694	default.node_sound_stone_defaults(),
695	true
696)
697
698my_register_stair_and_slab(
699	"desert_sandstone",
700	"default:desert_sandstone",
701	{crumbly = 1, cracky = 3},
702	{"default_desert_sandstone.png"},
703	"Desert Sandstone Stair",
704	"Desert Sandstone Slab",
705	default.node_sound_stone_defaults(),
706	true
707)
708
709my_register_stair_and_slab(
710	"desert_sandstone_brick",
711	"default:desert_sandstone_brick",
712	{cracky = 2},
713	{"default_desert_sandstone_brick.png"},
714	"Desert Sandstone Brick Stair",
715	"Desert Sandstone Brick Slab",
716	default.node_sound_stone_defaults(),
717	false
718)
719
720my_register_stair_and_slab(
721	"desert_sandstone_block",
722	"default:desert_sandstone_block",
723	{cracky = 2},
724	{"default_desert_sandstone_block.png"},
725	"Desert Sandstone Block Stair",
726	"Desert Sandstone Block Slab",
727	default.node_sound_stone_defaults(),
728	true
729)
730
731my_register_stair_and_slab(
732	"silver_sandstone",
733	"default:silver_sandstone",
734	{crumbly = 1, cracky = 3},
735	{"default_silver_sandstone.png"},
736	"Silver Sandstone Stair",
737	"Silver Sandstone Slab",
738	default.node_sound_stone_defaults(),
739	true
740)
741
742my_register_stair_and_slab(
743	"silver_sandstone_brick",
744	"default:silver_sandstone_brick",
745	{cracky = 2},
746	{"default_silver_sandstone_brick.png"},
747	"Silver Sandstone Brick Stair",
748	"Silver Sandstone Brick Slab",
749	default.node_sound_stone_defaults(),
750	false
751)
752
753my_register_stair_and_slab(
754	"silver_sandstone_block",
755	"default:silver_sandstone_block",
756	{cracky = 2},
757	{"default_silver_sandstone_block.png"},
758	"Silver Sandstone Block Stair",
759	"Silver Sandstone Block Slab",
760	default.node_sound_stone_defaults(),
761	true
762)
763
764my_register_stair_and_slab(
765	"obsidian",
766	"default:obsidian",
767	{cracky = 1, level = 2},
768	{"default_obsidian.png"},
769	"Obsidian Stair",
770	"Obsidian Slab",
771	default.node_sound_stone_defaults(),
772	true
773)
774
775my_register_stair_and_slab(
776	"obsidianbrick",
777	"default:obsidianbrick",
778	{cracky = 1, level = 2},
779	{"default_obsidian_brick.png"},
780	"Obsidian Brick Stair",
781	"Obsidian Brick Slab",
782	default.node_sound_stone_defaults(),
783	false
784)
785
786my_register_stair_and_slab(
787	"obsidian_block",
788	"default:obsidian_block",
789	{cracky = 1, level = 2},
790	{"default_obsidian_block.png"},
791	"Obsidian Block Stair",
792	"Obsidian Block Slab",
793	default.node_sound_stone_defaults(),
794	true
795)
796
797my_register_stair_and_slab(
798	"brick",
799	"default:brick",
800	{cracky = 3},
801	{"default_brick.png"},
802	"Brick Stair",
803	"Brick Slab",
804	default.node_sound_stone_defaults(),
805	false
806)
807
808my_register_stair_and_slab(
809	"steelblock",
810	"default:steelblock",
811	{cracky = 1, level = 2},
812	{"default_steel_block.png"},
813	"Steel Block Stair",
814	"Steel Block Slab",
815	default.node_sound_metal_defaults(),
816	true
817)
818
819my_register_stair_and_slab(
820	"tinblock",
821	"default:tinblock",
822	{cracky = 1, level = 2},
823	{"default_tin_block.png"},
824	"Tin Block Stair",
825	"Tin Block Slab",
826	default.node_sound_metal_defaults(),
827	true
828)
829
830my_register_stair_and_slab(
831	"copperblock",
832	"default:copperblock",
833	{cracky = 1, level = 2},
834	{"default_copper_block.png"},
835	"Copper Block Stair",
836	"Copper Block Slab",
837	default.node_sound_metal_defaults(),
838	true
839)
840
841my_register_stair_and_slab(
842	"bronzeblock",
843	"default:bronzeblock",
844	{cracky = 1, level = 2},
845	{"default_bronze_block.png"},
846	"Bronze Block Stair",
847	"Bronze Block Slab",
848	default.node_sound_metal_defaults(),
849	true
850)
851
852my_register_stair_and_slab(
853	"goldblock",
854	"default:goldblock",
855	{cracky = 1},
856	{"default_gold_block.png"},
857	"Gold Block Stair",
858	"Gold Block Slab",
859	default.node_sound_metal_defaults(),
860	true
861)
862
863my_register_stair_and_slab(
864	"ice",
865	"default:ice",
866	{cracky = 3, cools_lava = 1, slippery = 3},
867	{"default_ice.png"},
868	"Ice Stair",
869	"Ice Slab",
870	default.node_sound_ice_defaults(),
871	true
872)
873
874my_register_stair_and_slab(
875	"snowblock",
876	"default:snowblock",
877	{crumbly = 3, cools_lava = 1, snowy = 1},
878	{"default_snow.png"},
879	"Snow Block Stair",
880	"Snow Block Slab",
881	default.node_sound_snow_defaults(),
882	true
883)
884
885-- Glass stair nodes need to be registered individually to utilize specialized textures.
886
887stairs.register_stair(
888	"glass",
889	"default:glass",
890	{cracky = 3, oddly_breakable_by_hand = 3},
891	{"stairs_glass_split.png", "default_glass.png",
892	"stairs_glass_stairside.png^[transformFX", "stairs_glass_stairside.png",
893	"default_glass.png", "stairs_glass_split.png"},
894	S("Glass Stair"),
895	default.node_sound_glass_defaults(),
896	false
897)
898
899stairs.register_slab(
900	"glass",
901	"default:glass",
902	{cracky = 3, oddly_breakable_by_hand = 3},
903	{"default_glass.png", "default_glass.png", "stairs_glass_split.png"},
904	S("Glass Slab"),
905	default.node_sound_glass_defaults(),
906	false
907)
908
909stairs.register_stair_inner(
910	"glass",
911	"default:glass",
912	{cracky = 3, oddly_breakable_by_hand = 3},
913	{"stairs_glass_stairside.png^[transformR270", "default_glass.png",
914	"stairs_glass_stairside.png^[transformFX", "default_glass.png",
915	"default_glass.png", "stairs_glass_stairside.png"},
916	"",
917	default.node_sound_glass_defaults(),
918	false,
919	S("Inner Glass Stair")
920)
921
922stairs.register_stair_outer(
923	"glass",
924	"default:glass",
925	{cracky = 3, oddly_breakable_by_hand = 3},
926	{"stairs_glass_stairside.png^[transformR90", "default_glass.png",
927	"stairs_glass_outer_stairside.png", "stairs_glass_stairside.png",
928	"stairs_glass_stairside.png^[transformR90","stairs_glass_outer_stairside.png"},
929	"",
930	default.node_sound_glass_defaults(),
931	false,
932	S("Outer Glass Stair")
933)
934
935stairs.register_stair(
936	"obsidian_glass",
937	"default:obsidian_glass",
938	{cracky = 3},
939	{"stairs_obsidian_glass_split.png", "default_obsidian_glass.png",
940	"stairs_obsidian_glass_stairside.png^[transformFX", "stairs_obsidian_glass_stairside.png",
941	"default_obsidian_glass.png", "stairs_obsidian_glass_split.png"},
942	S("Obsidian Glass Stair"),
943	default.node_sound_glass_defaults(),
944	false
945)
946
947stairs.register_slab(
948	"obsidian_glass",
949	"default:obsidian_glass",
950	{cracky = 3},
951	{"default_obsidian_glass.png", "default_obsidian_glass.png", "stairs_obsidian_glass_split.png"},
952	S("Obsidian Glass Slab"),
953	default.node_sound_glass_defaults(),
954	false
955)
956
957stairs.register_stair_inner(
958	"obsidian_glass",
959	"default:obsidian_glass",
960	{cracky = 3},
961	{"stairs_obsidian_glass_stairside.png^[transformR270", "default_obsidian_glass.png",
962	"stairs_obsidian_glass_stairside.png^[transformFX", "default_obsidian_glass.png",
963	"default_obsidian_glass.png", "stairs_obsidian_glass_stairside.png"},
964	"",
965	default.node_sound_glass_defaults(),
966	false,
967	S("Inner Obsidian Glass Stair")
968)
969
970stairs.register_stair_outer(
971	"obsidian_glass",
972	"default:obsidian_glass",
973	{cracky = 3},
974	{"stairs_obsidian_glass_stairside.png^[transformR90", "default_obsidian_glass.png",
975	"stairs_obsidian_glass_outer_stairside.png", "stairs_obsidian_glass_stairside.png",
976	"stairs_obsidian_glass_stairside.png^[transformR90","stairs_obsidian_glass_outer_stairside.png"},
977	"",
978	default.node_sound_glass_defaults(),
979	false,
980	S("Outer Obsidian Glass Stair")
981)
982
983-- Dummy calls to S() to allow translation scripts to detect the strings.
984-- To update this add this code to my_register_stair_and_slab:
985-- for _,x in ipairs({"","Inner ","Outer "}) do print(("S(%q)"):format(x..desc_stair)) end
986-- print(("S(%q)"):format(desc_slab))
987
988--[[
989S("Wooden Stair")
990S("Inner Wooden Stair")
991S("Outer Wooden Stair")
992S("Wooden Slab")
993S("Jungle Wood Stair")
994S("Inner Jungle Wood Stair")
995S("Outer Jungle Wood Stair")
996S("Jungle Wood Slab")
997S("Pine Wood Stair")
998S("Inner Pine Wood Stair")
999S("Outer Pine Wood Stair")
1000S("Pine Wood Slab")
1001S("Acacia Wood Stair")
1002S("Inner Acacia Wood Stair")
1003S("Outer Acacia Wood Stair")
1004S("Acacia Wood Slab")
1005S("Aspen Wood Stair")
1006S("Inner Aspen Wood Stair")
1007S("Outer Aspen Wood Stair")
1008S("Aspen Wood Slab")
1009S("Stone Stair")
1010S("Inner Stone Stair")
1011S("Outer Stone Stair")
1012S("Stone Slab")
1013S("Cobblestone Stair")
1014S("Inner Cobblestone Stair")
1015S("Outer Cobblestone Stair")
1016S("Cobblestone Slab")
1017S("Mossy Cobblestone Stair")
1018S("Inner Mossy Cobblestone Stair")
1019S("Outer Mossy Cobblestone Stair")
1020S("Mossy Cobblestone Slab")
1021S("Stone Brick Stair")
1022S("Inner Stone Brick Stair")
1023S("Outer Stone Brick Stair")
1024S("Stone Brick Slab")
1025S("Stone Block Stair")
1026S("Inner Stone Block Stair")
1027S("Outer Stone Block Stair")
1028S("Stone Block Slab")
1029S("Desert Stone Stair")
1030S("Inner Desert Stone Stair")
1031S("Outer Desert Stone Stair")
1032S("Desert Stone Slab")
1033S("Desert Cobblestone Stair")
1034S("Inner Desert Cobblestone Stair")
1035S("Outer Desert Cobblestone Stair")
1036S("Desert Cobblestone Slab")
1037S("Desert Stone Brick Stair")
1038S("Inner Desert Stone Brick Stair")
1039S("Outer Desert Stone Brick Stair")
1040S("Desert Stone Brick Slab")
1041S("Desert Stone Block Stair")
1042S("Inner Desert Stone Block Stair")
1043S("Outer Desert Stone Block Stair")
1044S("Desert Stone Block Slab")
1045S("Sandstone Stair")
1046S("Inner Sandstone Stair")
1047S("Outer Sandstone Stair")
1048S("Sandstone Slab")
1049S("Sandstone Brick Stair")
1050S("Inner Sandstone Brick Stair")
1051S("Outer Sandstone Brick Stair")
1052S("Sandstone Brick Slab")
1053S("Sandstone Block Stair")
1054S("Inner Sandstone Block Stair")
1055S("Outer Sandstone Block Stair")
1056S("Sandstone Block Slab")
1057S("Desert Sandstone Stair")
1058S("Inner Desert Sandstone Stair")
1059S("Outer Desert Sandstone Stair")
1060S("Desert Sandstone Slab")
1061S("Desert Sandstone Brick Stair")
1062S("Inner Desert Sandstone Brick Stair")
1063S("Outer Desert Sandstone Brick Stair")
1064S("Desert Sandstone Brick Slab")
1065S("Desert Sandstone Block Stair")
1066S("Inner Desert Sandstone Block Stair")
1067S("Outer Desert Sandstone Block Stair")
1068S("Desert Sandstone Block Slab")
1069S("Silver Sandstone Stair")
1070S("Inner Silver Sandstone Stair")
1071S("Outer Silver Sandstone Stair")
1072S("Silver Sandstone Slab")
1073S("Silver Sandstone Brick Stair")
1074S("Inner Silver Sandstone Brick Stair")
1075S("Outer Silver Sandstone Brick Stair")
1076S("Silver Sandstone Brick Slab")
1077S("Silver Sandstone Block Stair")
1078S("Inner Silver Sandstone Block Stair")
1079S("Outer Silver Sandstone Block Stair")
1080S("Silver Sandstone Block Slab")
1081S("Obsidian Stair")
1082S("Inner Obsidian Stair")
1083S("Outer Obsidian Stair")
1084S("Obsidian Slab")
1085S("Obsidian Brick Stair")
1086S("Inner Obsidian Brick Stair")
1087S("Outer Obsidian Brick Stair")
1088S("Obsidian Brick Slab")
1089S("Obsidian Block Stair")
1090S("Inner Obsidian Block Stair")
1091S("Outer Obsidian Block Stair")
1092S("Obsidian Block Slab")
1093S("Brick Stair")
1094S("Inner Brick Stair")
1095S("Outer Brick Stair")
1096S("Brick Slab")
1097S("Steel Block Stair")
1098S("Inner Steel Block Stair")
1099S("Outer Steel Block Stair")
1100S("Steel Block Slab")
1101S("Tin Block Stair")
1102S("Inner Tin Block Stair")
1103S("Outer Tin Block Stair")
1104S("Tin Block Slab")
1105S("Copper Block Stair")
1106S("Inner Copper Block Stair")
1107S("Outer Copper Block Stair")
1108S("Copper Block Slab")
1109S("Bronze Block Stair")
1110S("Inner Bronze Block Stair")
1111S("Outer Bronze Block Stair")
1112S("Bronze Block Slab")
1113S("Gold Block Stair")
1114S("Inner Gold Block Stair")
1115S("Outer Gold Block Stair")
1116S("Gold Block Slab")
1117S("Ice Stair")
1118S("Inner Ice Stair")
1119S("Outer Ice Stair")
1120S("Ice Slab")
1121S("Snow Block Stair")
1122S("Inner Snow Block Stair")
1123S("Outer Snow Block Stair")
1124S("Snow Block Slab")
1125--]]
1126