From d5edcb2a1033e5e03d9a1c7650456445ade8db4c Mon Sep 17 00:00:00 2001 From: Thomas--S Date: Sun, 4 Mar 2018 11:16:43 +0100 Subject: [PATCH] Add a register_custom_subset function --- stairsplus/custom.lua | 98 +++++++++++++++++++++++++++++++++++++++++++ stairsplus/defs.lua | 2 +- stairsplus/init.lua | 1 + 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 stairsplus/custom.lua diff --git a/stairsplus/custom.lua b/stairsplus/custom.lua new file mode 100644 index 0000000..e456f7c --- /dev/null +++ b/stairsplus/custom.lua @@ -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 diff --git a/stairsplus/defs.lua b/stairsplus/defs.lua index a7b7bca..560b1f2 100644 --- a/stairsplus/defs.lua +++ b/stairsplus/defs.lua @@ -335,7 +335,7 @@ stairsplus.defs = { }, }, }, - ["_right_half" ]= { + ["_right_half"] = { node_box = { type = "fixed", fixed = { diff --git a/stairsplus/init.lua b/stairsplus/init.lua index c9ca438..bb1ed2b 100644 --- a/stairsplus/init.lua +++ b/stairsplus/init.lua @@ -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")