functional, except saw, legacy, other compatability

This commit is contained in:
flux 2022-06-14 11:17:06 -07:00
parent 687de31632
commit b9eed16713
22 changed files with 374 additions and 238 deletions

View File

@ -11,18 +11,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- turned into a modpack (separate out stairsplus properly
- refactored and rewrote a ton of stuff.)
- a lot of cleanup.
- got rid of some dead code ("ownership").
- more API for creating node variants
- allow registering new variants w/ this mod
- parameterized resources (sounds, textures, craft materials) to make it easier to integrate w/ other games
- actually implemented proper luachecking
- fixed some unreported bugs (e.g. dependencies which weren't declared)
- turned into a modpack (i.e. properly separated moreblocks and stairsplus)
- refactored and rewrote a ton of stuff
- got rid of some dead code (e.g. "ownership.lua")
- more API for creating node variants, e.g. trap nodes, all_faces, shapes
- parameterized resources (sounds, textures, craft materials) to make it easier to integrate w/ other minetest "games"
- actually implement luachecking - stop ignoring problems
- fix some unreported bugs (e.g. dependencies which weren't declared, unused code)
- i'm rewriting large parts of the mod and creating a sane API, i'm bumping the version
- create a default-on "legacy" mode to allow new servers to not commit to creating so many useless shapes by default
### Fixed
- [stairsplus:register_custom_subset computes the wrong "cost" for elements](https://github.com/minetest-mods/moreblocks/issues/190)
- \* [Material disappears from Recycle output slot](https://github.com/minetest-mods/moreblocks/issues/189)
- \* [Would it be possible to port to mineclone?](https://github.com/minetest-mods/moreblocks/issues/188) - no plan to
actually make moreblocks mineclone-aware, but will lay the groundwork to make this very easy.
- [Minor issue causing warnings in MT 5.5.0 with texture alpha clipping](https://github.com/minetest-mods/moreblocks/issues/187)
- maybe: [world aligned textures](https://github.com/minetest-mods/moreblocks/issues/179)
- maybe: [Make microblocks work for nodes with layered textures](Make microblocks work for nodes with layered textures)
- \* [Make variants of nodes that can burn also burnable](https://github.com/minetest-mods/moreblocks/issues/177)
- [Add screenshot in README.md #151](https://github.com/minetest-mods/moreblocks/issues/151)
- maybe some of the other bugs/PRS, but they mostly either seem to be fixed or unfixable
\* not yet fixed, but planned
## [2.2.0] - 2021-06-28

View File

@ -72,6 +72,10 @@ minetest.register_alias("moreblocks:allfacestree", "moreblocks:all_faces_tree")
minetest.register_alias("moreblocks:empty_bookshelf", "moreblocks:empty_shelf")
minetest.register_alias("moreblocks:split_stone_tile_alt", "moreblocks:checker_stone_tile")
if moreblocks.has.stairsplus and cm.jungle_wood then
stairsplus.api.register_alias_all("moreblocks:jungle_wood", cm.jungle_wood)
end
minetest.register_lbm({
name = "moreblocks:reduce_wood_tile_redundancy",
nodenames = {

View File

@ -354,7 +354,6 @@ if cm.glass then
})
end
minetest.register_craft({
output = "moreblocks:trap_clean_glass",
type = "shapeless",

View File

@ -22,7 +22,7 @@ local sound_metal = moreblocks.resources.sounds.metal
local function is_glasslike(def)
return #def.tiles > 1 and (
def.drawtype == "glasslike_framed" or
def.drawtype == "glasslike_framed_optional"
def.drawtype == "glasslike_framed_optional"
)
end
@ -37,14 +37,8 @@ local function register_stairs(name, def)
end
if moreblocks.has.stairsplus then
stairsplus:register_all(modname, name, itemstring, {
description = def.description,
groups = def.groups,
tiles = def.tiles,
sunlight_propagates = def.sunlight_propagates,
light_source = def.light_source,
sounds = def.sounds,
})
stairsplus.api.register_group(itemstring, "common")
elseif moreblocks.has.stairs then
stairs.register_stair_and_slab(
("%s_%s"):format(modname, name),
@ -59,7 +53,6 @@ local function register_stairs(name, def)
end
end
local function tile_tiles(tex)
return {tex, tex, tex, tex, tex .. "^[transformR90", tex .. "^[transformR90"}
end
@ -87,7 +80,6 @@ local function register_all_faces(name, base)
minetest.register_alias(name, itemstring)
end
local function register_trap(name, base)
name = "trap_" .. name
local itemstring = ("%s:%s"):format(modname, name)

View File

@ -1,4 +1,3 @@
minetest.register_alias("circular_saw", "stairsplus:circular_saw")
minetest.register_alias("moreblocks:circular_saw", "stairsplus:circular_saw")

View File

@ -1,24 +1,50 @@
local api = stairsplus.api
local table_is_empty = stairsplus.util.table_is_empty
function api.register_alias_single(old_node, new_node, shape)
local old_shaped_node = api.format_name(shape, old_node)
local new_shaped_node = api.format_name(shape, new_node)
minetest.register_alias(old_shaped_node, new_shaped_node)
end
function api.register_alias_all(old_node, new_node)
local old_mod, old_name = old_node:match("^([^:]+:(.*)$")
local new_mod, new_name = new_node:match("^([^:]+:(.*)$")
for _, shape_def in pairs(stairsplus.api.registered_shapes) do
minetest.register_alias(
("%s:%s"):format(old_mod, shape_def.name_format:format(old_name)),
("%s:%s"):format(new_mod, shape_def.name_format:format(new_name))
)
for shape in pairs(api.registered_shapes) do
api.register_alias_single(old_node, new_node, shape)
end
end
function api.register_alias_force_single(old_node, new_node, shape)
local old_shaped_node = api.format_name(shape, old_node)
local new_shaped_node = api.format_name(shape, new_node)
minetest.register_alias_force(old_shaped_node, new_shaped_node)
local nodes = api.nodes_by_shape[shape] or {}
if nodes[old_node] then
nodes[old_node] = nil
nodes[new_node] = true
api.nodes_by_shape[shape] = nodes
end
local old_shapes = api.shapes_by_node[old_node] or {}
if old_shapes[shape] then
old_shapes[shape] = nil
if table_is_empty(old_shapes) then
api.shapes_by_node[old_node] = nil
else
api.shapes_by_node[old_node] = old_shapes
end
local new_shapes = api.shapes_by_node[new_node] or {}
new_shapes[new_node] = true
api.shapes_by_node[new_node] = new_shapes
end
end
function api.register_alias_force_all(old_node, new_node)
local old_mod, old_name = old_node:match("^([^:]+:(.*)$")
local new_mod, new_name = new_node:match("^([^:]+:(.*)$")
for _, shape_def in pairs(stairsplus.api.registered_shapes) do
minetest.register_alias_force(
("%s:%s"):format(old_mod, shape_def.name_format:format(old_name)),
("%s:%s"):format(new_mod, shape_def.name_format:format(new_name))
)
for shape in pairs(api.registered_shapes) do
api.register_alias_force_single(old_node, new_node, shape)
end
end

View File

@ -3,4 +3,5 @@ stairsplus.api = {}
stairsplus.dofile("api", "shape")
stairsplus.dofile("api", "node")
stairsplus.dofile("api", "station")
stairsplus.dofile("api", "alias")
stairsplus.dofile("api", "recipe")

View File

@ -4,10 +4,16 @@
]]
local api = stairsplus.api
local table_set_all = stairsplus.util.table_set_all
local table_sort_keys = stairsplus.util.table_sort_keys
local S = stairsplus.S
local legacy_mode = stairsplus.settings.legacy_mode
local in_creative_inventory = stairsplus.settings.in_creative_inventory
local S = stairsplus.S
api.nodes_by_shape = {}
api.shapes_by_node = {}
local function scale_light(light_source, shape_def)
if not light_source or light_source == 0 then
@ -19,14 +25,19 @@ local function scale_light(light_source, shape_def)
return math.max(1, math.min(math.round(light_source * shape_def.eighths / 4), light_source))
end
function api.register_single(node, shape, overrides)
function api.format_name(shape, node)
local mod, name = node:match("^([^:]+):(.*)$")
local shape_def = api.registered_shapes[shape]
return ("%s:%s"):format(mod, shape_def.name_format:format(name))
end
function api.register_single(node, shape, overrides)
local node_def = table.copy(minetest.registered_nodes[node])
local shape_def = api.registered_shapes[shape]
local groups = {
[shape] = 1,
not_in_creative_inventory = in_creative_inventory,
not_in_creative_inventory = in_creative_inventory and 1 or 0,
}
for group, value in pairs(node_def.groups) do
@ -47,6 +58,13 @@ function api.register_single(node, shape, overrides)
light_source = scale_light(node_def.light_source, shape_def),
}
local tiles = node_def.tiles
if #tiles > 1 and (node_def.drawtype or ""):match("glass") then
def.tiles = {tiles[1]}
else
def.tiles = tiles
end
if node_def.short_description then
def.short_description = S(shape_def.description, node_def.short_description)
end
@ -62,39 +80,72 @@ function api.register_single(node, shape, overrides)
end
end
for k, v in pairs(overrides or {}) do
def[k] = v
end
table_set_all(def, overrides or {})
minetest.register_node((":%s:%s"):format(mod, shape_def.name_format:format(name)), def)
local shaped_name = api.format_name(shape, node)
minetest.register_node(":" .. shaped_name, def)
if shape_def.aliases then
local mod, name = node:match("^([^:]+):(.*)$")
for _, alias in ipairs(shape_def.aliases) do
minetest.register_alias(
("%s:%s"):format(mod, alias:format(name)),
("%s:%s"):format(mod, shape_def.name_format:format(name))
shaped_name
)
end
end
local nodes = api.nodes_by_shape[shape] or {}
nodes[node] = true
api.nodes_by_shape[shape] = nodes
local shapes = api.shapes_by_node[node] or {}
shapes[shape] = true
api.shapes_by_node[node] = shapes
end
function api.register_all(node, overrides)
for shape in pairs(api.registered_shapes) do
api.register_single(node, shape, overrides)
end
api.register_schema_crafts_for_node(node)
end
function api.register_custom(node, list, overrides)
for _, shape in ipairs(list) do
api.register_single(node, shape, overrides)
end
api.register_schema_crafts_for_node(node)
end
function api.register_group(node, group, overrides)
for _, shape in ipairs(api.shapes_by_group[group] or {}) do
api.register_single(node, shape, overrides)
end
api.register_schema_crafts_for_node(node)
end
function api.get_shapes(node)
return table_sort_keys(api.shapes_by_node[node])
end
function api.get_shapes_hash(node)
return api.shapes_by_node[node]
end
function api.get_shaped_name(node, shape_or_item)
local t = ItemStack(shape_or_item):to_table()
if api.registered_shapes[t.name] then
t.name = api.format_name(t.name, node)
elseif t.name == "node" then
t.name = node
end
return ItemStack(t):to_string()
end
minetest.register_on_mods_loaded(function()
stairsplus.log("info", "registering schema crafts")
for node in pairs(api.shapes_by_node) do
api.register_schema_crafts_for_node(node)
end
end)

View File

@ -5,13 +5,13 @@
api.register_craft_schema({
output = "panel_8 6",
input = {{"node", "node", "node"}},
recipe = {{"node", "node", "node"}},
})
api.register_craft_schema({
type = "shapeless",
output = "micro_8 7",
input = {"stair_inner"},
recipe = {"stair_inner"},
})
api.register_schema_crafts_for_node("default:coalblock")
@ -31,18 +31,11 @@ api.register_crafts_for_shapes({
]]
local api = stairsplus.api
error("TODO: ugh, forgot to handle when output has > 1 item")
local function is_valid_shape(item)
return api.registered_shapes[item]
end
local function is_valid_item(item, shapes)
local item_name = ItemStack(item):get_name()
local function is_normal_item(item)
return item == "" or item:match(":")
end
local function is_valid_item(item)
return is_valid_shape(item) or is_normal_item(item)
return shapes[item_name] or item_name == "" or item_name:match(":")
end
local function verify_schema(schema)
@ -52,14 +45,14 @@ local function verify_schema(schema)
table.insert(problems, ("unimplemented schema type %q"):format(schema.type))
end
if not is_valid_item(schema.output) then
if not is_valid_item(schema.output, api.registered_shapes) then
table.insert(problems, ("don't know how to handle output %q"):format(schema.output))
end
if schema.replacements then
for _, replacement in ipairs(schema.replacements) do
for _, item in ipairs(replacement) do
if not is_valid_item(schema.output) then
if not is_valid_item(schema.output, api.registered_shapes) then
table.insert(problems, ("don't know how to handle replacement item %q"):format(item))
end
end
@ -67,16 +60,16 @@ local function verify_schema(schema)
end
if schema.type == "shapeless" then
for _, item in ipairs(schema.input) do
if not is_valid_item(schema.output) then
for _, item in ipairs(schema.recipe) do
if not is_valid_item(schema.output, api.registered_shapes) then
table.insert(problems, ("don't know how to handle craft item %q"):format(item))
end
end
else
for _, row in ipairs(schema.input) do
for _, row in ipairs(schema.recipe) do
for _, item in ipairs(row) do
if not is_valid_item(schema.output) then
if not is_valid_item(schema.output, api.registered_shapes) then
table.insert(problems, ("don't know how to handle craft item %q"):format(item))
end
end
@ -91,6 +84,7 @@ end
api.registered_recipe_schemas = {}
function api.register_craft_schema(schema)
local problems = verify_schema(schema)
if problems then
error(problems)
end
@ -98,19 +92,15 @@ function api.register_craft_schema(schema)
table.insert(api.registered_recipe_schemas, schema)
end
local function has_the_right_shape(item, shapes)
return shapes[item] or item == "" or item:match(":")
end
local function has_the_right_shapes(schema, shapes)
if not has_the_right_shape(schema.output, shapes) then
if not is_valid_item(schema.output, shapes) then
return false
end
if schema.replacements then
for _, replacement in ipairs(schema.replacements) do
for _, item in ipairs(replacement) do
if not has_the_right_shape(item, shapes) then
if not is_valid_item(item, shapes) then
return false
end
end
@ -118,16 +108,16 @@ local function has_the_right_shapes(schema, shapes)
end
if schema.type == "shapeless" then
for _, item in ipairs(schema.input) do
if not has_the_right_shape(item, shapes) then
for _, item in ipairs(schema.recipe) do
if not is_valid_item(item, shapes) then
return false
end
end
elseif schema.type == "shaped" or schema.type == nil then
for _, row in ipairs(schema.input) do
for _, row in ipairs(schema.recipe) do
for _, item in ipairs(row) do
if not has_the_right_shape(item, shapes) then
if not is_valid_item(item, shapes) then
return false
end
end
@ -155,14 +145,14 @@ local function register_for_schema(node, shapes, schema)
end
if recipe.type == "shapeless" then
for i, item in ipairs(recipe.input) do
for i, item in ipairs(recipe.recipe) do
if shapes[item] then
recipe.input[i] = api.get_shaped_name(node, item)
recipe.recipe[i] = api.get_shaped_name(node, item)
end
end
elseif recipe.type == "shaped" or recipe.type == nil then
for _, row in ipairs(schema.input) do
for _, row in ipairs(schema.recipe) do
for i, item in ipairs(row) do
if shapes[item] then
row[i] = api.get_shaped_name(node, item)

View File

@ -1,14 +1,28 @@
-- register shapes (e.g. 1/16 slab, 1/8 slab, 1/4 slab, etc)
--[[
stairsplus.api.register_shape("micro_1", {
name_format = "micro_%s_1",
description = "@1 1/16 Microblock",
shape_groups = {micro = 1},
eighths = 1,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5},
},
})
]]
local api = stairsplus.api
stairsplus.api.registered_shapes = {}
stairsplus.api.shapes_by_group = {}
api.registered_shapes = {}
api.shapes_by_group = {}
function stairsplus.api.register_shape(name , def)
stairsplus.api.registered_shapes[name] = def
function api.register_shape(name, def)
api.registered_shapes[name] = def
for group in pairs(def.shape_groups or {}) do
local shapes = stairsplus.api.shapes_by_group[group] or {}
local shapes = api.shapes_by_group[group] or {}
table.insert(shapes, name)
stairsplus.api.shapes_by_group[group] = shapes
api.shapes_by_group[group] = shapes
end
end

View File

@ -2,12 +2,12 @@
local api = stairsplus.api
local S = stairsplus.S
function api.register_station(name, shape_groups, def)
minetest.register_node(name, def)
end
local F = minetest.formspec_escape
local circular_saw = {}
@ -171,7 +171,7 @@ end
function circular_saw.on_construct(pos)
local meta = minetest.get_meta(pos)
local fancy_inv = ""
if has_default_mod then
if stairsplus.has.default then
-- prepend background and slot styles from default if available
fancy_inv = default.gui_bg .. default.gui_bg_img .. default.gui_slots
end

View File

@ -9,12 +9,12 @@ local S = stairsplus.S
local cm = stairsplus.resources.craft_materials
api.register_station("stairsplus:circular_saw", {
micros = 1,
panels = 1,
slabs = 1,
slopes = 1,
stairs = 1,
}, {
micros = 1,
panels = 1,
slabs = 1,
slopes = 1,
stairs = 1,
}, {
description = S("Circular Saw"),
drawtype = "nodebox",
node_box = {
@ -31,19 +31,19 @@ api.register_station("stairsplus:circular_saw", {
},
},
tiles = {
"moreblocks_circular_saw_top.png",
"moreblocks_circular_saw_bottom.png",
"moreblocks_circular_saw_side.png"
"stairsplus_circular_saw_top.png",
"stairsplus_circular_saw_bottom.png",
"stairsplus_circular_saw_side.png"
},
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
groups = {choppy = 2, oddly_breakable_by_hand = 2},
sounds = moreblocks.resources.sounds.wood,
sounds = stairsplus.resources.sounds.wood,
})
if cm.steel_ingot then
if moreblocks.settings.circular_saw_crafting then
if stairsplus.settings.circular_saw_crafting then
minetest.register_craft({
output = "stairsplus:circular_saw",
recipe = {

View File

@ -1,4 +1,3 @@
stairsplus.dofile("compat", "stairs")
stairsplus.dofile("compat", "legacy")

View File

@ -6,7 +6,7 @@ local api = stairsplus.api
function stairsplus:register_all(modname, subname, recipeitem, fields)
api.register_all(recipeitem, fields)
local old_name = ("%s:%s"):format(modname, subname)
local old_name = ("%s:%s"):format(modname, subname)
if old_name ~= recipeitem then
api.register_alias_all(old_name, recipeitem)
end

View File

@ -4,7 +4,7 @@ More Blocks: registrations
Copyright © 2011-2020 Hugo Locurcio and contributors.
Licensed under the zlib license. See LICENSE.md for more information.
--]]
local S = moreblocks.S
local S = stairsplus.S
-- default registrations
if minetest.get_modpath("default") then
local default_nodes = { -- Default stairs/slabs/panels/microblocks:
@ -120,7 +120,7 @@ if minetest.get_modpath("basic_materials") then
description = S("Concrete"),
tiles = {"basic_materials_concrete_block.png", },
groups = {cracky = 1, level = 2, concrete = 1},
sounds = moreblocks.node_sound_stone_defaults(),
sounds = stairsplus.node_sound_stone_defaults(),
})
minetest.register_alias("prefab:concrete_stair", "technic:stair_concrete")
@ -130,7 +130,7 @@ if minetest.get_modpath("basic_materials") then
description = S("Cement"),
tiles = {"basic_materials_cement_block.png"},
groups = {cracky = 2, not_in_creative_inventory = 1},
sounds = moreblocks.node_sound_stone_defaults(),
sounds = stairsplus.node_sound_stone_defaults(),
sunlight_propagates = true,
})

View File

@ -1,5 +1,9 @@
local register_craft_schema = stairsplus.api.register_craft_schema
-- micros
---- micro_8
register_craft_schema({
type = "shapeless",
output = "micro_8 7",
@ -42,11 +46,9 @@ register_craft_schema({
recipe = {"panel_8"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8"},
})
-- panels
---- panel_8
register_craft_schema({
output = "panel_8 12",
@ -70,11 +72,7 @@ register_craft_schema({
recipe = {"micro_8", "micro_8"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"panel_8", "panel_8", "panel_8", "panel_8"},
})
-- slabs
register_craft_schema({
output = "slab_8 6",
@ -99,13 +97,6 @@ register_craft_schema({
{"panel_8"},
},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_8", "slab_8"},
})
register_craft_schema({
type = "shapeless",
output = "slab_8 3",
@ -148,18 +139,6 @@ register_craft_schema({
recipe = {"slope_outer_cut_half", "slope_inner_cut_half"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_4", "slab_4", "slab_4", "slab_4"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_12", "slab_4"},
})
register_craft_schema({
type = "shapeless",
output = "slab_4",
@ -190,18 +169,6 @@ register_craft_schema({
recipe = {"slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_14", "slab_2"},
})
register_craft_schema({
type = "shapeless",
output = "slab_2 2",
@ -220,63 +187,14 @@ register_craft_schema({
recipe = {"slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_15", "slab_1"},
})
register_craft_schema({
type = "shapeless",
output = "slab_15",
recipe = {"slab_14", "slab_1"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope", "slope"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_half", "slope_half_raised"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_half", "slope_half", "slope_half", "slope_half"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer", "slope_inner"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer_half", "slope_inner_half_raised"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer_half_raised", "slope_inner_half"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer_cut", "slope_inner_cut"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer_cut_half", "slope_inner_cut_half_raised"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_cut", "slope_cut"},
})
-- slopes
register_craft_schema({
type = "shapeless",
output = "slope_half_raised",
@ -288,21 +206,27 @@ register_craft_schema({
output = "slope_half_raised",
recipe = {"slab_8", "slope_half"},
})
register_craft_schema({
type = "shapeless",
output = "slope_inner_half_raised",
recipe = {"slab_8", "slope_inner_half"},
})
register_craft_schema({
type = "shapeless",
output = "slope_outer_half_raised",
recipe = {"slab_8", "slope_outer_half"},
})
register_craft_schema({
type = "shapeless",
output = "slope_inner_cut_half_raised",
recipe = {"slab_8", "slope_inner_cut_half"},
})
-- stairs
register_craft_schema({
output = "stair 8",
recipe = {
@ -344,11 +268,13 @@ register_craft_schema({
output = "stair",
recipe = {"panel_8", "panel_8", "panel_8"},
})
register_craft_schema({
type = "shapeless",
output = "stair_inner",
recipe = {"micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8"},
})
register_craft_schema({
type = "shapeless",
output = "stair_outer",
@ -360,6 +286,7 @@ register_craft_schema({
output = "stair_outer",
recipe = {"micro_8", "micro_8", "micro_8", "micro_8", "micro_8"},
})
register_craft_schema({
type = "shapeless",
output = "stair_half",
@ -371,11 +298,13 @@ register_craft_schema({
output = "stair_half",
recipe = {"panel_8", "micro_8"},
})
register_craft_schema({
type = "shapeless",
output = "stair_right_half",
recipe = {"stair_half"},
})
register_craft_schema({ -- See mirrored variation of the recipe below.
output = "stair_alt_8",
recipe = {
@ -391,3 +320,106 @@ register_craft_schema({ -- Mirrored variation of the recipe above.
{"panel_8", ""},
},
})
-- node
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"panel_8", "panel_8", "panel_8", "panel_8"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_8", "slab_8"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_4", "slab_4", "slab_4", "slab_4"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_12", "slab_4"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_14", "slab_2"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slab_15", "slab_1"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope", "slope"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_half", "slope_half_raised"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_half", "slope_half", "slope_half", "slope_half"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer", "slope_inner"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer_half", "slope_inner_half_raised"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer_half_raised", "slope_inner_half"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer_cut", "slope_inner_cut"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_outer_cut_half", "slope_inner_cut_half_raised"},
})
register_craft_schema({
type = "shapeless",
output = "node",
recipe = {"slope_cut", "slope_cut"},
})

View File

@ -1,9 +1,13 @@
local s = minetest.settings
stairsplus.settings = {
in_creative_inventory = minetest.settings:get_bool("stairsplus.in_creative_inventory", false),
circular_saw_crafting = minetest.settings:get_bool("stairsplus.circular_saw_crafting", true),
expect_infinite_stacks = minetest.settings:get_bool("stairsplus.expect_infinite_stacks",
minetest.settings:get_bool("creative_mode", false)
in_creative_inventory = s:get_bool("stairsplus.in_creative_inventory",
s:get_bool("stairsplus_in_creative_inventory", false) -- turn to false because we will do nicer things
),
circular_saw_crafting = s:get_bool("stairsplus.circular_saw_crafting", true),
ex_nihilo = s:get_bool("stairsplus.ex_nihilo",
s:get_bool("creative_mode", false)
),
legacy_mode = minetest.settings:get_bool("stairsplus.legacy_mode", true),
legacy_mode = s:get_bool("stairsplus.legacy_mode", true),
}

View File

@ -1,4 +1,3 @@
stairsplus.api.register_shape("micro_1", {
name_format = "micro_%s_1",
description = "@1 1/16 Microblock",
@ -38,7 +37,7 @@ stairsplus.api.register_shape("micro_4", {
stairsplus.api.register_shape("micro_8", {
name_format = "micro_%s_8",
aliases = {"micro_%s", "micro_%s_bottom"},
description = "@1 Microblock", -- leave out the 1/2 to not confuse people too much...
description = "@1 Microblock", -- leave out the 1/2 to not confuse people too much...
shape_groups = {micro = 1, obligatory = 1, common = 1},
eighths = 1,
drawtype = "nodebox",

View File

@ -1,4 +1,3 @@
stairsplus.api.register_shape("panel_1", {
name_format = "panel_%s_1",
description = "@1 1/16 Panel",

View File

@ -1,4 +1,3 @@
stairsplus.api.register_shape("slab_1", {
name_format = "slab_%s_1",
description = "@1 1/16 Slab",

View File

@ -1,4 +1,3 @@
local box_slope = {
type = "fixed",
fixed = {
@ -12,10 +11,10 @@ local box_slope = {
stairsplus.api.register_shape("slope", {
name_format = "slope_%s",
description = "@1 Slope",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 4,
drawtype = "mesh",
mesh = "moreblocks_slope.obj",
mesh = "stairsplus_slope.obj",
collision_box = box_slope,
selection_box = box_slope,
})
@ -33,10 +32,10 @@ local box_slope_half = {
stairsplus.api.register_shape("slope_half", {
name_format = "slope_%s_half",
description = "@1 1/2 Slope",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 2,
drawtype = "mesh",
mesh = "moreblocks_slope_half.obj",
mesh = "stairsplus_slope_half.obj",
collision_box = box_slope_half,
selection_box = box_slope_half,
})
@ -54,10 +53,10 @@ local box_slope_half_raised = {
stairsplus.api.register_shape("slope_half_raised", {
name_format = "slope_%s_half_raised",
description = "@1 1/2 Slope Raised",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 6,
drawtype = "mesh",
mesh = "moreblocks_slope_half_raised.obj",
mesh = "stairsplus_slope_half_raised.obj",
collision_box = box_slope_half_raised,
selection_box = box_slope_half_raised,
})
@ -78,10 +77,10 @@ local box_slope_inner = {
stairsplus.api.register_shape("slope_inner", {
name_format = "slope_%s_inner",
description = "@1 Slope Inner",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 6,
drawtype = "mesh",
mesh = "moreblocks_slope_inner.obj",
mesh = "stairsplus_slope_inner.obj",
collision_box = box_slope_inner,
selection_box = box_slope_inner,
})
@ -89,10 +88,10 @@ stairsplus.api.register_shape("slope_inner", {
stairsplus.api.register_shape("slope_inner_cut", {
name_format = "slope_%s_inner_cut",
description = "@1 Slope Inner Cut",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 6,
drawtype = "mesh",
mesh = "moreblocks_slope_inner_cut.obj",
mesh = "stairsplus_slope_inner_cut.obj",
collision_box = box_slope_inner,
selection_box = box_slope_inner,
})
@ -113,10 +112,10 @@ local box_slope_inner_half = {
stairsplus.api.register_shape("slope_inner_half", {
name_format = "slope_%s_inner_half",
description = "@1 Slope Inner Half",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 3,
drawtype = "mesh",
mesh = "moreblocks_slope_inner_half.obj",
mesh = "stairsplus_slope_inner_half.obj",
collision_box = box_slope_inner_half,
selection_box = box_slope_inner_half,
})
@ -124,10 +123,10 @@ stairsplus.api.register_shape("slope_inner_half", {
stairsplus.api.register_shape("slope_inner_cut_half", {
name_format = "slope_%s_inner_cut_half",
description = "@1 Slope Inner Cut Half",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 4,
drawtype = "mesh",
mesh = "moreblocks_slope_inner_cut_half.obj",
mesh = "stairsplus_slope_inner_cut_half.obj",
collision_box = box_slope_inner_half,
selection_box = box_slope_inner_half,
})
@ -148,10 +147,10 @@ local box_slope_inner_half_raised = {
stairsplus.api.register_shape("slope_inner_half_raised", {
name_format = "slope_%s_inner_half_raised",
description = "@1 Slope Inner Half Raised",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 6,
drawtype = "mesh",
mesh = "moreblocks_slope_inner_half_raised.obj",
mesh = "stairsplus_slope_inner_half_raised.obj",
collision_box = box_slope_inner_half_raised,
selection_box = box_slope_inner_half_raised,
})
@ -159,10 +158,10 @@ stairsplus.api.register_shape("slope_inner_half_raised", {
stairsplus.api.register_shape("slope_inner_cut_half_raised", {
name_format = "slope_%s_inner_cut_half_raised",
description = "@1 Slope Inner Cut Half Raised",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 7,
drawtype = "mesh",
mesh = "moreblocks_slope_inner_cut_half_raised.obj",
mesh = "stairsplus_slope_inner_cut_half_raised.obj",
collision_box = box_slope_inner_half_raised,
selection_box = box_slope_inner_half_raised,
})
@ -182,10 +181,10 @@ local box_slope_outer = {
stairsplus.api.register_shape("slope_outer", {
name_format = "slope_%s_outer",
description = "@1 Slope Outer",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 3,
drawtype = "mesh",
mesh = "moreblocks_slope_outer.obj",
mesh = "stairsplus_slope_outer.obj",
collision_box = box_slope_outer,
selection_box = box_slope_outer,
})
@ -193,10 +192,10 @@ stairsplus.api.register_shape("slope_outer", {
stairsplus.api.register_shape("slope_outer_cut", {
name_format = "slope_%s_outer_cut",
description = "@1 Slope Outer Cut",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 2,
drawtype = "mesh",
mesh = "moreblocks_slope_outer_cut.obj",
mesh = "stairsplus_slope_outer_cut.obj",
collision_box = box_slope_outer,
selection_box = box_slope_outer,
})
@ -204,10 +203,10 @@ stairsplus.api.register_shape("slope_outer_cut", {
stairsplus.api.register_shape("slope_cut", {
name_format = "slope_%s_cut",
description = "@1 Slope Cut",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 4,
drawtype = "mesh",
mesh = "moreblocks_slope_cut.obj",
mesh = "stairsplus_slope_cut.obj",
collision_box = box_slope_outer,
selection_box = box_slope_outer,
})
@ -225,10 +224,10 @@ local box_slope_outer_half = {
stairsplus.api.register_shape("slope_outer_half", {
name_format = "slope_%s_outer_half",
description = "@1 Slope Outer Half",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 2,
drawtype = "mesh",
mesh = "moreblocks_slope_outer_half.obj",
mesh = "stairsplus_slope_outer_half.obj",
collision_box = box_slope_outer_half,
selection_box = box_slope_outer_half,
})
@ -236,10 +235,10 @@ stairsplus.api.register_shape("slope_outer_half", {
stairsplus.api.register_shape("slope_outer_cut_half", {
name_format = "slope_%s_outer_cut_half",
description = "@1 Slope Outer Cut Half",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 1,
drawtype = "mesh",
mesh = "moreblocks_slope_outer_cut_half.obj",
mesh = "stairsplus_slope_outer_cut_half.obj",
collision_box = box_slope_outer_half,
selection_box = box_slope_outer_half,
})
@ -257,10 +256,10 @@ local box_slope_outer_half_raised = {
stairsplus.api.register_shape("slope_outer_half_raised", {
name_format = "slope_%s_outer_half_raised",
description = "@1 Slope Outer Half Raised",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 6,
drawtype = "mesh",
mesh = "moreblocks_slope_outer_half_raised.obj",
mesh = "stairsplus_slope_outer_half_raised.obj",
collision_box = box_slope_outer_half_raised,
selection_box = box_slope_outer_half_raised,
})
@ -268,10 +267,10 @@ stairsplus.api.register_shape("slope_outer_half_raised", {
stairsplus.api.register_shape("slope_outer_cut_half_raised", {
name_format = "slope_%s_outer_cut_half_raised",
description = "@1 Slope Outer Cut Half Raised",
shape_groups = {slope = 1},
shape_groups = {slope = 1, common = 1},
eighths = 3,
drawtype = "mesh",
mesh = "moreblocks_slope_outer_cut_half_raised.obj",
mesh = "stairsplus_slope_outer_cut_half_raised.obj",
collision_box = box_slope_outer_half_raised,
selection_box = box_slope_outer_half_raised,
})

View File

@ -4,5 +4,22 @@ stairsplus.util = {
t[key] = value
end
return t
end,
table_is_empty = function(t)
return not next(t)
end,
table_sort_keys = function(t, sort_function)
local sorted = {}
for key in pairs(t) do
table.insert(sorted, key)
end
if sort_function then
table.sort(sorted, sort_function)
else
table.sort(sorted)
end
return sorted
end
}