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

@ -14,12 +14,34 @@ supports
* else polyfill
## `register_stairs_slabs(Name, BaseItem, Tiles, DigGroups, Sounds, StairName, SlabName)`
## `register_stairs_slabs({def})`
Creates stairs, slabs and sometimes more.
Use with:
xcompat.functions.register_stairs_slabs({
baseitem = "", --the item the nodes are based on
recipeitem = "", --the item the nodes are crafted with, will use baseitem if unset
name = "Willow",
slab_name = "", --slab name, if nil will use name
slab_name_double = "", --double slab name, if nil will use slab name, if nil will use name
stair_name = "", --stair name, if nil will use name
stair_name_out = "", --outer stair name, if nil will use stair name, if nil will use name
stair_name_in = "", --outer stair name, if nil will use stair name, if nil will use name
step_name = "", --step name, if nil will use name
step_name_out = "", --outer step name, if nil will use step name, if nil will use name
step_name_in = "", --outer step name, if nil will use step name, if nil will use name
tiles = {"willow_planks.png"}, --the tiles the nodes will use, if nil will use baseitem's tiles
groups = {}, --the groups the nodes will use, if nil will use baseitem's groups
sounds = sounds, --the sounds the nodes will use, if nil will use baseitem's sounds, if baseitem has no sounds will base sounds off of baseitems groups, if nil will be silent
worldalign = true/false, --if textures should be world aligned
})
Supports:
* mineclonXX
* farlands redo
* any game with stairs
* MineclonXX
* Farlands Redo
* Hades
* any game with "stairs"
* any game with stairs redo
* any game with stairs plus

View File

@ -1,3 +1,3 @@
name = xcompat
description = Provides cross compatibility between mods and games for sounds and crafting materials.
optional_depends = default, fl_stone, fl_trees, mcl_sounds, hades_sounds, ks_sounds, nodes_nature, fl_topsoil, fl_trees, mcl_core, farming, x_farming, sounds, stairs, stairsplus, mcl_stairs, fl_stairs
optional_depends = default, fl_stone, fl_trees, mcl_sounds, hades_sounds, ks_sounds, nodes_nature, fl_topsoil, fl_trees, mcl_core, farming, x_farming, sounds, stairs, stairsplus, mcl_stairs, fl_stairs, hades_stairs

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
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
)
--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("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