Add a register_custom_subset function

This commit is contained in:
Thomas--S 2018-03-04 11:16:43 +01:00 committed by Hugo Locurcio
parent c711946453
commit d5edcb2a10
3 changed files with 100 additions and 1 deletions

98
stairsplus/custom.lua Normal file
View File

@ -0,0 +1,98 @@
--[[
More Blocks: microblock definitions
Copyright (c) 2011-2018 Hugo Locurcio and contributors.
Licensed under the zlib license. See LICENSE.md for more information.
--]]
local S = moreblocks.intllib
--[[
Subset table should have the following format: (You can remove entries as needed.)
local subset = {
{ "micro", "" },
{ "micro", "_1" },
{ "micro", "_2" },
{ "micro", "_4" },
{ "micro", "_12" },
{ "micro", "_14" },
{ "micro", "_15" },
{ "panel", "" },
{ "panel", "_1" },
{ "panel", "_2" },
{ "panel", "_4" },
{ "panel", "_12" },
{ "panel", "_14" },
{ "panel", "_15" },
{ "slab", "" },
{ "slab", "_quarter" },
{ "slab", "_three_quarter" },
{ "slab", "_1" },
{ "slab", "_2" },
{ "slab", "_14" },
{ "slab", "_15" },
{ "slab", "_two_sides" },
{ "slab", "_three_sides" },
{ "slab", "_three_sides_u" },
{ "slope", "" },
{ "slope", "_half" },
{ "slope", "_half_raised" },
{ "slope", "_inner" },
{ "slope", "_inner_half" },
{ "slope", "_inner_half_raised" },
{ "slope", "_inner_cut" },
{ "slope", "_inner_cut_half" },
{ "slope", "_inner_cut_half_raised" },
{ "slope", "_outer" },
{ "slope", "_outer_half" },
{ "slope", "_outer_half_raised" },
{ "slope", "_outer_cut" },
{ "slope", "_outer_cut_half" },
{ "slope", "_outer_cut_half_raised" },
{ "slope", "_cut" },
{ "stair", "" },
{ "stair", "_half" },
{ "stair", "_right_half" },
{ "stair", "_inner" },
{ "stair", "_outer" },
{ "stair", "_alt" },
{ "stair", "_alt_1" },
{ "stair", "_alt_2" },
{ "stair", "_alt_4" },
}
--]]
function register_custom_subset(subset, modname, subname, recipeitem, groups, images, description, drop, light)
stairsplus:register_custom_subset(subset, modname, subname, recipeitem, {
groups = groups,
tiles = images,
description = description,
drop = drop,
light_source = light,
sounds = default.node_sound_stone_defaults(),
})
end
function stairsplus:register_custom_subset_alias(subset, modname_old, subname_old, modname_new, subname_new)
local subset = table.copy(subset)
for k, v in pairs(subset) do
minetest.register_alias(modname_old .. ":" .. v[1] .. "_" .. subname_old .. v[2], modname_new .. ":" .. v[1] .. "_" .. subname_new .. v[2])
end
end
function stairsplus:register_custom_subset_alias_force(subset, modname_old, subname_old, modname_new, subname_new)
local subset = table.copy(subset)
for k, v in pairs(subset) do
minetest.register_alias_force(modname_old .. ":" .. v[1] .. "_" .. subname_old .. v[2], modname_new .. ":" .. v[1] .. "_" .. subname_new .. v[2])
end
end
function stairsplus:register_custom_subset(subset, modname, subname, recipeitem, fields)
local subset = table.copy(subset)
for k, v in pairs(subset) do
stairsplus.register_single(v[1], v[2], stairsplus.defs[v[1]][v[2]], modname, subname, recipeitem, fields)
end
circular_saw.known_nodes[recipeitem] = {modname, subname}
end

View File

@ -335,7 +335,7 @@ stairsplus.defs = {
},
},
},
["_right_half" ]= {
["_right_half"] = {
node_box = {
type = "fixed",
fixed = {

View File

@ -77,4 +77,5 @@ dofile(modpath .. "/slabs.lua")
dofile(modpath .. "/slopes.lua")
dofile(modpath .. "/panels.lua")
dofile(modpath .. "/microblocks.lua")
dofile(modpath .. "/custom.lua")
dofile(modpath .. "/registrations.lua")