forked from mtcontrib/darkage
Simplyfied stairs registrations
This commit is contained in:
parent
730f23f88f
commit
dc02970d08
@ -1,3 +1,4 @@
|
|||||||
default
|
default
|
||||||
farming
|
farming
|
||||||
moreblocks?
|
moreblocks?
|
||||||
|
stairs?
|
||||||
|
9
init.lua
9
init.lua
@ -1,5 +1,7 @@
|
|||||||
minetest.log("action"," ---- Dark Age Version 1.3 is Loading! ---- ")
|
minetest.log("action"," ---- Dark Age Version 1.3 is Loading! ---- ")
|
||||||
|
|
||||||
|
darkage = {}; -- Create darkage namespace
|
||||||
|
|
||||||
local MODPATH = minetest.get_modpath("darkage")
|
local MODPATH = minetest.get_modpath("darkage")
|
||||||
|
|
||||||
dofile(MODPATH.."/nodes.lua")
|
dofile(MODPATH.."/nodes.lua")
|
||||||
@ -9,11 +11,8 @@ dofile(MODPATH.."/furniture.lua")
|
|||||||
dofile(MODPATH.."/aliases.lua")
|
dofile(MODPATH.."/aliases.lua")
|
||||||
dofile(MODPATH.."/walls.lua")
|
dofile(MODPATH.."/walls.lua")
|
||||||
|
|
||||||
if minetest.get_modpath("moreblocks") then
|
dofile(MODPATH.."/stairs_functions.lua")
|
||||||
dofile(MODPATH.."/stairsplus.lua")--only if moreblocks installed
|
dofile(MODPATH.."/stairs.lua")
|
||||||
else
|
|
||||||
dofile(MODPATH.."/stairs.lua")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
---------------
|
---------------
|
||||||
|
176
stairs.lua
176
stairs.lua
@ -1,155 +1,25 @@
|
|||||||
darkage = {}
|
|
||||||
|
|
||||||
function darkage.register_stairs(modname, item, groups, images, description)
|
-- Registration of Stairs (Alphabetical order)
|
||||||
local recipeitem = modname..":"..item
|
darkage.register_stairs("darkage:basalt")
|
||||||
local itemname = modname..":stair_"..item
|
darkage.register_stairs("darkage:basalt_cobble")
|
||||||
minetest.register_node(itemname, {
|
darkage.register_stairs("darkage:gneiss")
|
||||||
description = description.." stair",
|
darkage.register_stairs("darkage:gneiss_cobble")
|
||||||
drawtype = "nodebox",
|
darkage.register_stairs("darkage:marble")
|
||||||
tiles = images,
|
darkage.register_stairs("darkage:marble_tile")
|
||||||
paramtype = "light",
|
darkage.register_stairs("darkage:old_tuff_bricks")
|
||||||
paramtype2 = "facedir",
|
darkage.register_stairs("darkage:ors")
|
||||||
is_ground_content = true,
|
darkage.register_stairs("darkage:ors_cobble")
|
||||||
groups = groups,
|
darkage.register_stairs("darkage:rhyolitic_tuff")
|
||||||
node_box = {
|
darkage.register_stairs("darkage:rhyolitic_tuff_bricks")
|
||||||
type = "fixed",
|
darkage.register_stairs("darkage:schist")
|
||||||
fixed = {
|
darkage.register_stairs("darkage:serpentine")
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
darkage.register_stairs("darkage:shale")
|
||||||
{-0.5, 0, 0, 0.5, 0.5, 0.5},
|
darkage.register_stairs("darkage:slate")
|
||||||
},
|
darkage.register_stairs("darkage:slate_cobble")
|
||||||
},
|
darkage.register_stairs("darkage:slate_tile")
|
||||||
})
|
darkage.register_stairs("darkage:stone_brick")
|
||||||
|
darkage.register_stairs("darkage:straw_bale")
|
||||||
|
darkage.register_stairs("darkage:tuff")
|
||||||
|
darkage.register_stairs("darkage:tuff_bricks")
|
||||||
|
darkage.register_stairs("farming:straw")
|
||||||
|
|
||||||
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"
|
|
||||||
)
|
|
39
stairs_functions.lua
Normal file
39
stairs_functions.lua
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
|
||||||
|
if minetest.get_modpath("moreblocks") then
|
||||||
|
function darkage.register_stairs(nodeName)
|
||||||
|
local ndef = assert(minetest.registered_nodes[nodeName], "Error: "..nodeName.." is not registered")
|
||||||
|
|
||||||
|
local mod = "darkage"
|
||||||
|
local node = nodeName:split(":")[2]
|
||||||
|
|
||||||
|
stairsplus:register_all(mod, node, nodeName, ndef)
|
||||||
|
end
|
||||||
|
elseif minetest.get_modpath("stairs") then
|
||||||
|
function darkage.register_stairs(nodeName)
|
||||||
|
local ndef = assert(minetest.registered_nodes[nodeName], "Error: "..nodeName.." is not registered")
|
||||||
|
|
||||||
|
local node = nodeName:split(":")[2]
|
||||||
|
|
||||||
|
-- The stairs api does not allow to use the darkage modname, so we have to call the nodes stairs:stair_darkage_
|
||||||
|
-- and creating an alias
|
||||||
|
local subname = "darkage_".. node;
|
||||||
|
stairs.register_stair_and_slab(subname, nodeName,
|
||||||
|
ndef.groups, ndef.tiles,
|
||||||
|
ndef.description.." Stair", ndef.description.." Slab",
|
||||||
|
ndef.sounds)
|
||||||
|
|
||||||
|
--stairs.register_stair_and_slab(subname, recipeitem,
|
||||||
|
-- groups, images,
|
||||||
|
-- desc_stair, desc_slab, sounds)
|
||||||
|
minetest.register_alias("darkage:stair_"..node, "stairs:stair_darkage_"..node)
|
||||||
|
minetest.register_alias("darkage:slab_"..node, "stairs:slab_darkage_"..node)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- No compatible stairs mod found.
|
||||||
|
minetest.log("error", "[darkage] Darkage requires at least moreblocks or stairs to be installed. Its not possible to register stairs.")
|
||||||
|
function darkage.register_stairs(nodeName)
|
||||||
|
minetest.log("warning", "could not create stair of type "..nodeName .." because no compatible stairs mod is installed.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
-- Function to register stairs out of base-material
|
|
||||||
local function create_stair(nodeName)
|
|
||||||
local ndef = assert(minetest.registered_nodes[nodeName], "Error: "..nodeName.." is not registered")
|
|
||||||
|
|
||||||
local mod = nodeName:split(":")[1]
|
|
||||||
local node = nodeName:split(":")[2]
|
|
||||||
|
|
||||||
stairsplus:register_all(mod, node, nodeName, ndef)
|
|
||||||
end
|
|
||||||
|
|
||||||
create_stair("darkage:slate_cobble")
|
|
||||||
create_stair("darkage:slate")
|
|
||||||
create_stair("darkage:slate_tile")
|
|
||||||
create_stair("darkage:marble")
|
|
||||||
create_stair("darkage:stone_brick")
|
|
||||||
create_stair("darkage:serpentine")
|
|
||||||
create_stair("darkage:schist")
|
|
||||||
create_stair("darkage:gneiss")
|
|
||||||
create_stair("darkage:gneiss_cobble")
|
|
||||||
create_stair("darkage:basalt")
|
|
||||||
create_stair("darkage:basalt_cobble")
|
|
||||||
create_stair("darkage:shale")
|
|
||||||
create_stair("darkage:ors")
|
|
||||||
create_stair("darkage:ors_cobble")
|
|
||||||
create_stair("darkage:tuff_bricks")
|
|
||||||
create_stair("darkage:old_tuff_bricks")
|
|
||||||
create_stair("darkage:rhyolitic_tuff_bricks")
|
|
||||||
create_stair("darkage:tuff")
|
|
||||||
create_stair("darkage:rhyolitic_tuff")
|
|
||||||
|
|
||||||
|
|
||||||
-- Straw
|
|
||||||
-- Keep this until farming:straw gets registered in moreblocks. Register alias then.
|
|
||||||
stairsplus:register_all("darkage", "straw", "farming:straw", {
|
|
||||||
description = "Straw",
|
|
||||||
tiles = {"farming_straw.png"},
|
|
||||||
groups = {snappy=3, flammable=2},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Straw Bale
|
|
||||||
-- Is it used? Maybe remove in future.
|
|
||||||
stairsplus:register_all("darkage", "straw_bale", "darkage:straw_bale", {
|
|
||||||
description = "Straw Bale",
|
|
||||||
tiles = {"darkage_straw_bale.png"},
|
|
||||||
groups = {snappy=2, flammable=2},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
Loading…
Reference in New Issue
Block a user