1 -- Minetest 0.4 mod: stairs
2 -- See README.txt for licensing and other information.
6 -- Node will be called stairs:stair_<subname>
7 function stairs.register_stair(subname, recipeitem, groups, images, description)
8 minetest.register_node("stairs:stair_" .. subname, {
9 description = description,
13 paramtype2 = "facedir",
14 is_ground_content = true,
19 {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
20 {-0.5, 0, 0, 0.5, 0.5, 0.5},
25 minetest.register_craft({
26 output = 'stairs:stair_' .. subname .. ' 4',
29 {recipeitem, recipeitem, ""},
30 {recipeitem, recipeitem, recipeitem},
34 -- Flipped recipe for the silly minecrafters
35 minetest.register_craft({
36 output = 'stairs:stair_' .. subname .. ' 4',
39 {"", recipeitem, recipeitem},
40 {recipeitem, recipeitem, recipeitem},
45 -- Node will be called stairs:slab_<subname>
46 function stairs.register_slab(subname, recipeitem, groups, images, description)
47 minetest.register_node("stairs:slab_" .. subname, {
48 description = description,
52 is_ground_content = true,
56 fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
60 fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
62 on_place = function(itemstack, placer, pointed_thing)
63 if pointed_thing.type ~= "node" then
67 -- If it's being placed on an another similar one, replace it with
71 local p0 = pointed_thing.under
72 local p1 = pointed_thing.above
73 local n0 = minetest.env:get_node(p0)
74 if n0.name == "stairs:slab_" .. subname and
80 -- Remove the slab at slabpos
81 minetest.env:remove_node(slabpos)
82 -- Make a fake stack of a single item and try to place it
83 local fakestack = ItemStack(recipeitem)
84 pointed_thing.above = slabpos
85 fakestack = minetest.item_place(fakestack, placer, pointed_thing)
86 -- If the item was taken from the fake stack, decrement original
87 if not fakestack or fakestack:is_empty() then
88 itemstack:take_item(1)
89 -- Else put old node back
91 minetest.env:set_node(slabpos, slabnode)
96 -- Otherwise place regularly
97 return minetest.item_place(itemstack, placer, pointed_thing)
101 minetest.register_craft({
102 output = 'stairs:slab_' .. subname .. ' 3',
104 {recipeitem, recipeitem, recipeitem},
109 -- Nodes will be called stairs:{stair,slab}_<subname>
110 function stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab)
111 stairs.register_stair(subname, recipeitem, groups, images, desc_stair)
112 stairs.register_slab(subname, recipeitem, groups, images, desc_slab)
115 stairs.register_stair_and_slab("wood", "default:wood",
116 {snappy=2,choppy=2,oddly_breakable_by_hand=2},
117 {"default_wood.png"},
121 stairs.register_stair_and_slab("stone", "default:stone",
123 {"default_stone.png"},
127 stairs.register_stair_and_slab("cobble", "default:cobble",
129 {"default_cobble.png"},
133 stairs.register_stair_and_slab("brick", "default:brick",
135 {"default_brick.png"},
139 stairs.register_stair_and_slab("sandstone", "default:sandstone",
140 {crumbly=2,cracky=2},
141 {"default_sandstone.png"},