fix some bugs, starting to track down all the compatability issues

This commit is contained in:
flux
2022-06-16 16:32:55 -07:00
parent 03b189e927
commit acc6e2ebea
12 changed files with 121 additions and 85 deletions

View File

@ -1,4 +1,12 @@
stairsplus.compat = {}
stairsplus.compat = {
is_legacy_drawtype = function(node)
local def = minetest.registered_nodes[node]
return (
def.drawtype == "mesh" or
def.drawtype == "plantlike"
)
end
}
stairsplus.dofile("compat", "stairs")
stairsplus.dofile("compat", "legacy")

View File

@ -3,13 +3,19 @@
-- existing servers
local api = stairsplus.api
local is_legacy_drawtype = stairsplus.compat.is_legacy_drawtype
local legacy_mode = stairsplus.settings.legacy_mode
function stairsplus:register_all(modname, subname, recipeitem, fields)
local meta = {}
if is_legacy_drawtype(recipeitem) then
meta.ignore_drawtype = true
end
if legacy_mode then
api.register_group(recipeitem, "legacy", fields)
api.register_group(recipeitem, "legacy", fields, meta)
else
api.register_group(recipeitem, "common", fields)
api.register_group(recipeitem, "common", fields, meta)
end
local old_name = ("%s:%s"):format(modname, subname)

View File

@ -7,57 +7,78 @@ local api = stairsplus.api
local S = stairsplus.S
local default_align_style = stairsplus.settings.default_align_style
local is_legacy_drawtype = stairsplus.compat.is_legacy_drawtype
-- stairs compat: override what stairs does, and "fix" any stairs which were already registered...
function stairs.register_stair(subname, node, groups, tiles, description, sounds, worldaligntex)
local meta = {
align_style = worldaligntex and "world" or default_align_style
}
if is_legacy_drawtype(node) then
meta.ignore_drawtype = true
end
api.register_single(node, "stair", {
groups = groups,
tiles = tiles,
description = description,
sounds = sounds,
}, {
align_style = worldaligntex and "world" or default_align_style
})
}, meta)
minetest.register_alias(("stairs:stair_%s"):format(subname), api.format_name(node, "stair"))
end
function stairs.register_slab(subname, node, groups, images, description, sounds, worldaligntex)
local meta = {
align_style = worldaligntex and "world" or default_align_style
}
if is_legacy_drawtype(node) then
meta.ignore_drawtype = true
end
api.register_single(node, "slab_8", {
groups = groups,
tiles = images,
description = description,
sounds = sounds,
}, {
align_style = worldaligntex and "world" or default_align_style
})
}, meta)
minetest.register_alias(("stairs:slab_%s"):format(subname), api.format_name(node, "slab_8"))
end
function stairs.register_stair_inner(subname, node, groups, tiles, description, sounds, worldaligntex, full_description)
local meta = {
align_style = worldaligntex and "world" or default_align_style
}
if is_legacy_drawtype(node) then
meta.ignore_drawtype = true
end
api.register_single(node, "stair_inner", {
groups = groups,
tiles = tiles,
description = full_description or S("Inner @1", description),
sounds = sounds,
}, {
align_style = worldaligntex and "world" or default_align_style
})
}, meta)
minetest.register_alias(("stairs:stair_inner_%s"):format(subname), api.format_name(node, "stair_inner"))
end
function stairs.register_stair_outer(subname, node, groups, tiles, description, sounds, worldaligntex, full_description)
local meta = {
align_style = worldaligntex and "world" or default_align_style
}
if is_legacy_drawtype(node) then
meta.ignore_drawtype = true
end
api.register_single(node, "stair_outer", {
groups = groups,
tiles = tiles,
description = full_description or S("Inner @1", description),
sounds = sounds,
}, {
align_style = worldaligntex and "world" or default_align_style
})
}, meta)
minetest.register_alias(("stairs:stair_outer_%s"):format(subname), api.format_name(node, "stair_outer"))
end