Switched to using definition table, added hades support, updated stairsplus, improved world align

This commit is contained in:
Kazooo100
2024-08-09 18:27:43 -04:00
parent 4d5c1e3eab
commit 4e6cf3c7e4
3 changed files with 110 additions and 40 deletions

View File

@ -16,60 +16,108 @@ function functions.can_interact_with_node(player, pos)
return false
end
function functions.register_stairs_slabs(Name, BaseItem, Tiles, DigGroups, Sounds, StairName, SlabName)
--skip if farlands as farlands reloaded uses diggroups to make stairs/slabs
--if minetest.get_modpath("fl_core") then return end
function functions.register_stairs_slabs(def)
local LName = string.lower(Name)
local BaseItem = def.baseitem or {}
local nodedef = minetest.registered_nodes[def.baseitem]
local Groups = def.groups or nodedef.groups
local Tiles = def.tiles or nodedef.tiles
local Sounds = def.sounds or nodedef.sounds or {}
local RecipeItem = def.recipeitem or def.baseitem
local Name = def.name
local LName = def.lname or string.lower(Name):gsub("_", "")
local SlabName = def.slabname or def.name
local StairName = def.stairname or def.name
--extra names for hades
local OuterStairName = def.stair_name_out or def.stair_name or def.name
local InnerStairName = def.stair_name_in or def.stair_name or def.name
local StepName = def.step_name or def.name
local OuterStepName = def.step_name_out or def.step_name or def.name
local InnerStepName = def.step_name_in or def.step_name or def.name
local DoubleSlabName = def.slab_name_double or def.slab_name or def.name
if minetest.global_exists("stairs") then
if stairs.mod and stairs.mod == "redo" then
stairs.register_all(
LName,
BaseItem,
DigGroups,
Tiles,
Name,
Sounds,
--true/false world align texture
true
)
else
stairs.register_stair_and_slab(
LName,
BaseItem,
DigGroups,
Tiles,
StairName,
SlabName,
Sounds
)
if minetest.global_exists("stairsplus") then
if WorldAlign == true then
WorldAlign = "world"
elseif WorldAlign == false then
WorldAlign = "node"
elseif WorldAlign ~= "world" and WorldAlign ~= "node" then
WorldAlign = "user"
end
elseif minetest.global_exists("stairsplus") then
stairsplus:register_all(
--[[stairsplus:register_all(
Name,
Name,
BaseItem,
{
description = Name,
tiles = Tiles,
groups = Groups,
sounds = Sounds
}
)]]
stairsplus.api.register_all(BaseItem,
{
tiles = Tiles,
groups = DigGroups,
sounds = Sounds
}
)
},
{
align_style = WorldAlign,
allow_override_groups = true
})
elseif minetest.global_exists("stairs") then
if stairs.mod and stairs.mod == "redo" then
if WorldAlign ~= true and WorldAlign ~= false and WorldAlign ~= "" then
WorldAlign = ""
end
stairs.register_all(
LName,
RecipeItem,
Groups,
Tiles,
Name,
Sounds,
WorldAlign
)
else
stairs.register_stair_and_slab(
LName,
RecipeItem,
Groups,
Tiles,
StairName,
SlabName,
Sounds
)
end
elseif minetest.global_exists("mcl_stairs") then
--mcl_stairs.register_stair_and_slab(LName
mcl_stairs.register_stair_and_slab(LName, {
baseitem = BaseItem,
--base_description = Name,
recipeitem = RecipeItem,
description_stair = StairName,
description_slab = SlabName,
tiles = Tiles,
})
elseif minetest.global_exists("hades_stairs") then
hades_stairs.register_stair_and_slab_and_step(LName, BaseItem,
Groups,
Tiles,
Stairname,
OuterStairName,
InnerStairName,
SlabName,
StepName,
OuterStepName,
InnerStepName,
Sounds,
DoubleSlabName
)
elseif minetest.global_exists("fl_stairs") then
Groups.stairable = 1
minetest.override_item(BaseItem, {
groups = {stairtable=1,},
groups = Groups,
})
end
end