mirror of
https://github.com/mt-mods/xcompat.git
synced 2025-11-09 20:35:22 +01:00
add stairs api (#56)
This commit is contained in:
8
src/stairs.lua
Normal file
8
src/stairs.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
local filename = xcompat.gameid
|
||||
|
||||
--if we dont have a stairs file for the game, use xcompat_agnostic
|
||||
if not xcompat.utilities.file_exists(xcompat.modpath .. "/src/stairs/" .. filename .. ".lua") then
|
||||
filename = "xcompat_agnostic"
|
||||
end
|
||||
|
||||
return dofile(xcompat.modpath .. "/src/stairs/" .. filename .. ".lua")
|
||||
25
src/stairs/farlands_reloaded.lua
Normal file
25
src/stairs/farlands_reloaded.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
local function register(name, _)
|
||||
local splitName = name:split(":")
|
||||
local sName = splitName[2]
|
||||
|
||||
local groups = core.registered_nodes[name].groups
|
||||
groups.stairable = 1
|
||||
|
||||
core.override_item(name, {groups = groups})
|
||||
|
||||
local flStairNameOverrides = {
|
||||
["stair_inner"] = "inner_stair",
|
||||
["stair_outer"] = "outer_stair"
|
||||
}
|
||||
|
||||
for _, type in pairs({"slab", "stair", "stair_inner", "stair_outer"}) do
|
||||
|
||||
|
||||
minetest.register_alias(
|
||||
splitName[1] .. ":" .. type .. "_" .. sName,
|
||||
splitName[1] .. ":" .. sName .. "_" .. (flStairNameOverrides[type] or type)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
return {register = register}
|
||||
19
src/stairs/minetest.lua
Normal file
19
src/stairs/minetest.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
local function register(name, def)
|
||||
local splitName = name:split(":")
|
||||
local sName = splitName[2]
|
||||
|
||||
stairs.register_stair_and_slab(
|
||||
sName,
|
||||
nil,
|
||||
def.groups,
|
||||
def.tiles,
|
||||
def.description,
|
||||
def.sounds
|
||||
)
|
||||
|
||||
for _, type in pairs({"slab", "stair", "stair_inner", "stair_outer"}) do
|
||||
minetest.register_alias(splitName[1] .. ":" .. type .. "_" .. sName, "stairs:" .. type .. "_" .. sName)
|
||||
end
|
||||
end
|
||||
|
||||
return {register = register}
|
||||
48
src/stairs/xcompat_agnostic.lua
Normal file
48
src/stairs/xcompat_agnostic.lua
Normal file
@@ -0,0 +1,48 @@
|
||||
local stairtable = {
|
||||
{
|
||||
"slab",
|
||||
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
},
|
||||
{
|
||||
"stair",
|
||||
{
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
|
||||
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
|
||||
},
|
||||
},
|
||||
{
|
||||
"stair_inner",
|
||||
{
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
|
||||
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
|
||||
{-0.5, 0.0, -0.5, 0.0, 0.5, 0.0},
|
||||
},
|
||||
},
|
||||
{
|
||||
"stair_outer",
|
||||
{
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
|
||||
{-0.5, 0.0, 0.0, 0.0, 0.5, 0.5},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local function register(name, def)
|
||||
for _, sdef in pairs(stairtable) do
|
||||
local split = name:split(":")
|
||||
local ndef = table.copy(def)
|
||||
local item_name = ":" .. sdef[1] .. "_" .. split[2]
|
||||
|
||||
ndef.description = def.description .. " " .. string.gsub(sdef[1], "_", " ")
|
||||
ndef.paramtype, ndef.paramtype2 = "light", "facedir"
|
||||
ndef.drawtype = "nodebox"
|
||||
ndef.node_box = {
|
||||
type = "fixed",
|
||||
fixed = sdef[2],
|
||||
}
|
||||
|
||||
minetest.register_node(":" .. split[1] .. item_name, ndef)
|
||||
end
|
||||
end
|
||||
|
||||
return {register = register}
|
||||
Reference in New Issue
Block a user