2018-03-03 20:15:09 +01:00
|
|
|
--[[
|
|
|
|
More Blocks: registrations
|
|
|
|
|
2020-01-01 04:09:24 +01:00
|
|
|
Copyright © 2011-2020 Hugo Locurcio and contributors.
|
2018-03-03 20:15:09 +01:00
|
|
|
Licensed under the zlib license. See LICENSE.md for more information.
|
|
|
|
--]]
|
|
|
|
|
2019-03-03 20:02:40 +01:00
|
|
|
local S = moreblocks.S
|
2018-03-03 20:15:09 +01:00
|
|
|
|
2018-07-13 23:02:01 +02:00
|
|
|
local descriptions = {
|
|
|
|
["micro"] = S("%s Microblock"),
|
|
|
|
["slab"] = S("%s Slab"),
|
|
|
|
["slope"] = S("%s Slope"),
|
|
|
|
["panel"] = S("%s Panel"),
|
|
|
|
["stair"] = S("%s Stairs"),
|
|
|
|
}
|
2018-03-03 20:15:09 +01:00
|
|
|
|
|
|
|
stairsplus.register_single = function(category, alternate, info, modname, subname, recipeitem, fields)
|
2020-08-16 10:14:18 +02:00
|
|
|
local src_def = minetest.registered_nodes[recipeitem] or {}
|
2018-07-13 23:02:01 +02:00
|
|
|
local desc_base = descriptions[category]:format(fields.description)
|
2018-03-03 20:15:09 +01:00
|
|
|
local def = {}
|
2018-07-13 23:02:01 +02:00
|
|
|
|
2018-03-03 20:15:09 +01:00
|
|
|
if category ~= "slab" then
|
|
|
|
def = table.copy(info)
|
|
|
|
end
|
|
|
|
|
2018-07-13 23:02:01 +02:00
|
|
|
-- copy fields to def
|
2018-03-03 20:15:09 +01:00
|
|
|
for k, v in pairs(fields) do
|
|
|
|
def[k] = v
|
|
|
|
end
|
2018-07-13 23:02:01 +02:00
|
|
|
|
2018-03-03 20:15:09 +01:00
|
|
|
def.drawtype = "nodebox"
|
|
|
|
def.paramtype = "light"
|
|
|
|
def.paramtype2 = def.paramtype2 or "facedir"
|
2020-08-16 10:14:18 +02:00
|
|
|
if def.use_texture_alpha == nil then
|
|
|
|
def.use_texture_alpha = src_def.use_texture_alpha
|
|
|
|
end
|
2019-02-25 10:47:51 +01:00
|
|
|
|
|
|
|
-- This makes node rotation work on placement
|
|
|
|
def.place_param2 = nil
|
|
|
|
|
2019-05-08 20:00:15 +02:00
|
|
|
-- Darken light sources slightly to make up for their smaller visual size
|
|
|
|
def.light_source = math.max(0, (def.light_source or 0) - 1)
|
|
|
|
|
2018-03-03 20:15:09 +01:00
|
|
|
def.on_place = minetest.rotate_node
|
2018-07-13 23:02:01 +02:00
|
|
|
def.groups = stairsplus:prepare_groups(fields.groups)
|
|
|
|
|
|
|
|
if category == "slab" then
|
2018-03-03 20:15:09 +01:00
|
|
|
if type(info) ~= "table" then
|
|
|
|
def.node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, (info/16)-0.5, 0.5},
|
|
|
|
}
|
|
|
|
def.description = ("%s (%d/16)"):format(desc_base, info)
|
|
|
|
else
|
|
|
|
def.node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = info,
|
|
|
|
}
|
|
|
|
def.description = desc_base .. alternate:gsub("_", " "):gsub("(%a)(%S*)", function(a, b) return a:upper() .. b end)
|
|
|
|
end
|
2018-07-13 23:02:01 +02:00
|
|
|
else
|
|
|
|
def.description = desc_base
|
|
|
|
if category == "slope" then
|
|
|
|
def.drawtype = "mesh"
|
|
|
|
elseif category == "stair" and alternate == "" then
|
|
|
|
def.groups.stair = 1
|
|
|
|
end
|
2018-03-03 20:15:09 +01:00
|
|
|
end
|
2018-07-13 23:02:01 +02:00
|
|
|
|
2018-03-03 20:15:09 +01:00
|
|
|
if fields.drop and not (type(fields.drop) == "table") then
|
|
|
|
def.drop = modname.. ":" .. category .. "_" .. fields.drop .. alternate
|
|
|
|
end
|
2018-07-13 23:02:01 +02:00
|
|
|
|
2018-03-03 20:15:09 +01:00
|
|
|
minetest.register_node(":" ..modname.. ":" .. category .. "_" .. subname .. alternate, def)
|
2018-03-04 12:16:45 +01:00
|
|
|
stairsplus.register_recipes(category, alternate, modname, subname, recipeitem)
|
2019-02-21 23:10:58 +01:00
|
|
|
end
|