mirror of
https://github.com/minetest-mods/moreblocks.git
synced 2025-02-21 12:30:24 +01:00
bugfixes for legacy stairsplus support
This commit is contained in:
parent
21a374b8dd
commit
2163a39844
@ -2,6 +2,8 @@
|
||||
|
||||
local api = stairsplus.api
|
||||
|
||||
local resolve_aliases = stairsplus.util.resolve_aliases
|
||||
|
||||
local default_stack_max = tonumber(minetest.settings:get("default_stack_max")) or 99
|
||||
|
||||
local station = {}
|
||||
@ -59,10 +61,36 @@ function station.on_receive_fields(meta, inv, formname, fields, sender, build_fo
|
||||
return not not fields.max_offered
|
||||
end
|
||||
|
||||
function station.update_inventory(meta, inv, taken_stack)
|
||||
local node = station.get_current_node(inv)
|
||||
local function fix_aliases(inv)
|
||||
local input = inv:get_stack("stairsplus:input", 1)
|
||||
input:set_name(resolve_aliases(input:get_name()))
|
||||
inv:set_stack("stairsplus:input", 1, input)
|
||||
|
||||
if not node then
|
||||
local micro = inv:get_stack("stairsplus:micro", 1)
|
||||
micro:set_name(resolve_aliases(micro:get_name()))
|
||||
inv:set_stack("stairsplus:micro", 1, micro)
|
||||
|
||||
local recycle = inv:get_stack("stairsplus:recycle", 1)
|
||||
recycle:set_name(resolve_aliases(recycle:get_name()))
|
||||
inv:set_stack("stairsplus:recycle", 1, recycle)
|
||||
|
||||
for i = 1, inv:get_size("stairsplus:output") do
|
||||
local output = inv:get_stack("stairsplus:output", i)
|
||||
output:set_name(resolve_aliases(output:get_name()))
|
||||
inv:set_stack("stairsplus:output", i, output)
|
||||
end
|
||||
end
|
||||
|
||||
function station.update_inventory(meta, inv, taken_stack)
|
||||
fix_aliases(inv)
|
||||
|
||||
local node = station.get_current_node(inv)
|
||||
local valid_shapes = api.shapes_by_node[node]
|
||||
|
||||
if not (node and valid_shapes) then
|
||||
inv:set_stack("stairsplus:input", 1, ItemStack())
|
||||
inv:set_stack("stairsplus:micro", 1, ItemStack())
|
||||
inv:set_stack("stairsplus:recycle", 1, ItemStack())
|
||||
for i = 1, inv:get_size("stairsplus:output") do
|
||||
inv:set_stack("stairsplus:output", i, ItemStack())
|
||||
end
|
||||
@ -92,7 +120,6 @@ function station.update_inventory(meta, inv, taken_stack)
|
||||
return
|
||||
end
|
||||
|
||||
local valid_shapes = api.shapes_by_node[node]
|
||||
local max_offered = meta:get_int("stairsplus:max_offered")
|
||||
local shape_groups = minetest.parse_json(meta:get_string("stairsplus:shape_groups"))
|
||||
|
||||
@ -152,7 +179,7 @@ function station.allow_inventory_put(meta, inv, listname, index, stack, player)
|
||||
return 0
|
||||
end
|
||||
|
||||
local shaped_node = stack:get_name()
|
||||
local shaped_node = resolve_aliases(stack:get_name())
|
||||
local node = api.get_node_of_shaped_node(shaped_node)
|
||||
local shape = api.get_shape_of_shaped_node(shaped_node)
|
||||
|
||||
|
@ -72,7 +72,8 @@ stairsplus.api.register_shape("micro_14", {
|
||||
})
|
||||
|
||||
stairsplus.api.register_shape("micro_15", {
|
||||
name_format = "micro_%s_5",
|
||||
name_format = "micro_%s_15",
|
||||
aliases = {"micro_%s_5"},
|
||||
description = "@1 15/16 Microblock",
|
||||
shape_groups = {micro = 1, legacy = 1},
|
||||
eighths = 2,
|
||||
|
@ -81,4 +81,17 @@ stairsplus.util = {
|
||||
error(("unexpected location? %s"):format(dump(location)))
|
||||
end
|
||||
end,
|
||||
|
||||
resolve_aliases = function(node, seen)
|
||||
seen = seen or {}
|
||||
if seen[node] then
|
||||
error(("alias loop on %s"):format(node))
|
||||
end
|
||||
local aliased_to = minetest.registered_aliases[node]
|
||||
if aliased_to then
|
||||
seen[node] = true
|
||||
return stairsplus.util.resolve_aliases(aliased_to, seen)
|
||||
end
|
||||
return node
|
||||
end,
|
||||
}
|
||||
|
@ -1,12 +1,19 @@
|
||||
-- not every fork of basic_materials has all the nodes
|
||||
if minetest.registered_nodes["basic_materials:concrete_block"] then
|
||||
local materials = stairsplus_legacy.materials
|
||||
|
||||
if materials.concrete_block and materials.concrete_block ~= "basic_materials:concrete_block" then
|
||||
stairsplus.api.register_alias_all("basic_materials:concrete_block", materials.concrete_block)
|
||||
elseif minetest.registered_nodes["basic_materials:concrete_block"] then
|
||||
stairsplus_legacy.register_legacy("basic_materials:concrete_block")
|
||||
end
|
||||
|
||||
if minetest.registered_nodes["basic_materials:cement_block"] then
|
||||
if materials.cement_block and materials.cement_block ~= "basic_materials:cement_block" then
|
||||
stairsplus.api.register_alias_all("basic_materials:cement_block", materials.cement_block)
|
||||
elseif minetest.registered_nodes["basic_materials:cement_block"] then
|
||||
stairsplus_legacy.register_legacy("basic_materials:cement_block")
|
||||
end
|
||||
|
||||
if minetest.registered_nodes["basic_materials:brass_block"] then
|
||||
if materials.brass_block and materials.brass_block ~= "basic_materials:brass_block" then
|
||||
stairsplus.api.register_alias_all("basic_materials:brass_block", materials.brass_block)
|
||||
elseif minetest.registered_nodes["basic_materials:brass_block"] then
|
||||
stairsplus_legacy.register_legacy("basic_materials:brass_block")
|
||||
end
|
||||
|
@ -1,6 +1,8 @@
|
||||
if stairsplus_legacy.has.basic_materials and stairsplus_legacy.settings.basic_materials then
|
||||
stairsplus.api.register_alias_force_all("gloopblocks:cement", "basic_materials:cement_block")
|
||||
local materials = stairsplus_legacy.materials
|
||||
|
||||
else
|
||||
if materials.cement_block and materials.cement_block ~= "gloopblocks:cement" then
|
||||
stairsplus.api.register_alias_all("gloopblocks:cement", materials.cement_block)
|
||||
elseif minetest.registered_nodes["gloopblocks:cement"] then
|
||||
stairsplus_legacy.register_legacy("gloopblocks:cement")
|
||||
end
|
||||
|
||||
|
@ -32,6 +32,7 @@ stairsplus_legacy = {
|
||||
}
|
||||
|
||||
stairsplus_legacy.dofile("settings")
|
||||
stairsplus_legacy.dofile("resources")
|
||||
|
||||
function stairsplus_legacy.register_legacy(node, overrides, meta)
|
||||
if stairsplus.settings.legacy_mode then
|
||||
@ -41,30 +42,8 @@ function stairsplus_legacy.register_legacy(node, overrides, meta)
|
||||
end
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.basic_materials and stairsplus_legacy.settings.basic_materials then
|
||||
stairsplus_legacy.dofile("basic_materials")
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.default and stairsplus_legacy.settings.default then
|
||||
stairsplus_legacy.dofile("default")
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.farming and stairsplus_legacy.settings.farming then
|
||||
stairsplus_legacy.dofile("farming")
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.gloopblocks and stairsplus_legacy.settings.gloopblocks then
|
||||
stairsplus_legacy.dofile("gloopblocks")
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.technic and stairsplus_legacy.settings.technic then
|
||||
stairsplus_legacy.dofile("technic")
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.prefab and stairsplus_legacy.settings.prefab then
|
||||
stairsplus_legacy.dofile("prefab")
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.wool and stairsplus_legacy.settings.wool then
|
||||
stairsplus_legacy.dofile("wool")
|
||||
for mod, enabled in pairs(stairsplus_legacy.settings) do
|
||||
if enabled then
|
||||
stairsplus_legacy.dofile(mod)
|
||||
end
|
||||
end
|
||||
|
@ -1,9 +1,9 @@
|
||||
if stairsplus_legacy.has.basic_materials and stairsplus_legacy.settings.basic_materials then
|
||||
stairsplus.api.register_alias_force_all("prefab:concrete", "basic_materials:concrete_block")
|
||||
local materials = stairsplus_legacy.materials
|
||||
|
||||
elseif stairsplus_legacy.has.technic and stairsplus_legacy.settings.technic then
|
||||
stairsplus.api.register_alias_force_all("prefab:concrete", "technic:concrete")
|
||||
if materials.concrete_block and materials.concrete_block ~= "prefab:concrete" then
|
||||
local slab_name = stairsplus.api.format_name(materials.concrete_block, "slab_8")
|
||||
local stair_name = stairsplus.api.format_name(materials.concrete_block, "stair")
|
||||
|
||||
else
|
||||
stairsplus_legacy.register_legacy("prefab:concrete")
|
||||
minetest.register_alias_force("prefab:concrete_slab", slab_name)
|
||||
minetest.register_alias_force("prefab:concrete_stair", stair_name)
|
||||
end
|
||||
|
34
stairsplus_legacy/resources.lua
Normal file
34
stairsplus_legacy/resources.lua
Normal file
@ -0,0 +1,34 @@
|
||||
stairsplus_legacy.materials = {}
|
||||
|
||||
if stairsplus_legacy.has.prefab then
|
||||
if minetest.registered_nodes["prefab:concrete"] then
|
||||
stairsplus_legacy.materials.concrete_block = "prefab:concrete"
|
||||
end
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.gloopblocks then
|
||||
if minetest.registered_nodes["gloopblocks:cement"] then
|
||||
stairsplus_legacy.materials.cement_block = "gloopblocks:cement"
|
||||
end
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.technic then
|
||||
if minetest.registered_nodes["technic:brass_block"] then
|
||||
stairsplus_legacy.materials.brass_block = "technic:brass_block"
|
||||
end
|
||||
if minetest.registered_nodes["technic:concrete"] then
|
||||
stairsplus_legacy.materials.concrete_block = "technic:concrete"
|
||||
end
|
||||
end
|
||||
|
||||
if stairsplus_legacy.has.basic_materials then
|
||||
if minetest.registered_nodes["basic_materials:brass_block"] then
|
||||
stairsplus_legacy.materials.brass_block = "basic_materials:brass_block"
|
||||
end
|
||||
if minetest.registered_nodes["basic_materials:cement_block"] then
|
||||
stairsplus_legacy.materials.cement_block = "basic_materials:cement_block"
|
||||
end
|
||||
if minetest.registered_nodes["basic_materials:concrete_block"] then
|
||||
stairsplus_legacy.materials.concrete_block = "basic_materials:concrete_block"
|
||||
end
|
||||
end
|
@ -1,9 +1,13 @@
|
||||
if stairsplus_legacy.has.basic_materials and stairsplus_legacy.settings.basic_materials then
|
||||
stairsplus.api.register_alias_force_all("technic:brass_block", "basic_materials:concrete_block")
|
||||
stairsplus.api.register_alias_force_all("technic:brass_block", "basic_materials:brass_block")
|
||||
local materials = stairsplus_legacy.materials
|
||||
|
||||
else
|
||||
stairsplus_legacy.register_legacy("technic:brass_block")
|
||||
if materials.concrete_block and materials.concrete_block ~= "technic:concrete" then
|
||||
stairsplus.api.register_alias_all("technic:concrete", materials.concrete_block)
|
||||
elseif minetest.registered_nodes["technic:concrete"] then
|
||||
stairsplus_legacy.register_legacy("technic:concrete")
|
||||
end
|
||||
|
||||
if materials.brass_block and materials.brass_block ~= "technic:brass_block" then
|
||||
stairsplus.api.register_alias_all("technic:brass_block", materials.brass_block)
|
||||
elseif minetest.registered_nodes["technic:brass_block"] then
|
||||
stairsplus_legacy.register_legacy("technic:brass_block")
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user