1
0
mirror of https://github.com/adrido/darkage.git synced 2024-11-10 20:30:31 +01:00
darkage/stairs.lua
adrido 3a8bdb7e7f updated to version 1.2
applied most changes by CraigyDavi
updated to new stairsplus aka moreblocks api
added serpentine stairs
2014-09-04 12:37:40 +02:00

155 lines
3.5 KiB
Lua

darkage = {}
function darkage.register_stairs(modname, item, groups, images, description)
local recipeitem = modname..":"..item
local itemname = modname..":stair_"..item
minetest.register_node(itemname, {
description = description.." stair",
drawtype = "nodebox",
tiles = images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
groups = groups,
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
})
minetest.register_craft({
output = itemname .. ' 4',
recipe = {
{recipeitem, "", ""},
{recipeitem, recipeitem, ""},
{recipeitem, recipeitem, recipeitem},
},
})
-- Flipped recipe for the silly minecrafters
minetest.register_craft({
output = itemname .. ' 4',
recipe = {
{"", "", recipeitem},
{"", recipeitem, recipeitem},
{recipeitem, recipeitem, recipeitem},
},
})
itemname=modname..":slab_" .. item
minetest.register_node(itemname, {
description = description.." slab",
drawtype = "nodebox",
tiles = images,
paramtype = "light",
is_ground_content = true,
groups = groups,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
-- If it's being placed on an another similar one, replace it with
-- a full block
local slabpos = nil
local slabnode = nil
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local n0 = minetest.env:get_node(p0)
local n1 = minetest.env:get_node(p1)
if n0.name == itemname then
slabpos = p0
slabnode = n0
elseif n1.name == itemname then
slabpos = p1
slabnode = n1
end
if slabpos then
-- Remove the slab at slabpos
minetest.env:remove_node(slabpos)
-- Make a fake stack of a single item and try to place it
local fakestack = ItemStack(recipeitem)
pointed_thing.above = slabpos
fakestack = minetest.item_place(fakestack, placer, pointed_thing)
-- If the item was taken from the fake stack, decrement original
if not fakestack or fakestack:is_empty() then
itemstack:take_item(1)
-- Else put old node back
else
minetest.env:set_node(slabpos, slabnode)
end
return itemstack
end
-- Otherwise place regularly
return minetest.item_place(itemstack, placer, pointed_thing)
end,
})
minetest.register_craft({
output = itemname .. ' 3',
recipe = {
{recipeitem, recipeitem, recipeitem},
},
})
end
darkage.register_stairs("darkage","basalt_cobble",
{cracky=3},
{"darkage_basalt_cobble.png"},
"Basalt Cobble"
)
darkage.register_stairs("darkage","slate_tile",
{cracky=3},
{"darkage_slate_tile.png"},
"Slate Tile"
)
darkage.register_stairs("darkage","straw",
{snappy=3, flammable=2},
{"darkage_straw.png"},
"Straw"
)
darkage.register_stairs("darkage","stone_brick",
{cracky=3},
{"darkage_stone_brick.png"},
"Stone Brick"
)
darkage.register_stairs("darkage","marble",
{cracky=3},
{"darkage_marble.png"},
"Marble"
)
darkage.register_stairs("darkage","marble_tile",
{cracky=3},
{"darkage_marble_tile.png"},
"Marble Tile"
)
darkage.register_stairs("darkage","ors_cobble",
{cracky=3},
{"darkage_ors_cobble.png"},
"Old Red Sandstone"
)
darkage.register_stairs("darkage","serpentine",
{cracky=3},
{"darkage_serpentine.png"},
"Serpentine"
)