Merge mcstair into mcl_stairs
This commit is contained in:
parent
eb02e9f3e1
commit
cf8415f87a
15 changed files with 92 additions and 199 deletions
|
@ -15,3 +15,4 @@ Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (CC BY-SA 3.0):
|
|||
stairs_stair.obj
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ for m=1, #materials do
|
|||
minetest.register_alias("stairs:slab_"..mat, "mcl_stairs:slab_"..mat)
|
||||
minetest.register_alias("stairs:stair_"..mat, "mcl_stairs:stair_"..mat)
|
||||
|
||||
-- mcstair
|
||||
-- corner stairs
|
||||
minetest.register_alias("stairs:stair_"..mat.."_inner", "mcl_stairs:stair_"..mat.."_inner")
|
||||
minetest.register_alias("stairs:stair_"..mat.."_outer", "mcl_stairs:stair_"..mat.."_outer")
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
-- Core mcl_stairs API
|
||||
|
||||
-- Wrapper around mintest.pointed_thing_to_face_pos.
|
||||
local function get_fpos(placer, pointed_thing)
|
||||
local fpos
|
||||
|
@ -74,10 +76,10 @@ local function place_stair(itemstack, placer, pointed_thing)
|
|||
return minetest.item_place(itemstack, placer, pointed_thing, param2)
|
||||
end
|
||||
|
||||
-- Register mcl_stairs.
|
||||
-- Register stairs.
|
||||
-- Node will be called mcl_stairs:stair_<subname>
|
||||
|
||||
function mcl_stairs.register_stair(subname, recipeitem, groups, images, description, sounds, hardness)
|
||||
function mcl_stairs.register_stair(subname, recipeitem, groups, images, description, sounds, hardness, corner_texture_override)
|
||||
groups.stair = 1
|
||||
groups.building_block = 1
|
||||
|
||||
|
@ -151,6 +153,8 @@ function mcl_stairs.register_stair(subname, recipeitem, groups, images, descript
|
|||
},
|
||||
})
|
||||
end
|
||||
|
||||
mcl_stairs.cornerstair.add("mcl_stairs:stair_"..subname, corner_texture_override)
|
||||
end
|
||||
|
||||
|
||||
|
|
673
mods/ITEMS/mcl_stairs/cornerstair.lua
Normal file
673
mods/ITEMS/mcl_stairs/cornerstair.lua
Normal file
|
@ -0,0 +1,673 @@
|
|||
-- Corner stairs handling
|
||||
|
||||
-- This code originally copied from the [mcstair] mod and merged into this mod.
|
||||
-- This file is licensed under CC0.
|
||||
|
||||
mcl_stairs.cornerstair = {}
|
||||
|
||||
local get_stair_param = function(node)
|
||||
local stair = minetest.get_item_group(node.name, "stair")
|
||||
if stair == 1 then
|
||||
return node.param2
|
||||
elseif stair == 2 then
|
||||
if node.param2 < 12 then
|
||||
return node.param2 + 4
|
||||
else
|
||||
return node.param2 - 4
|
||||
end
|
||||
elseif stair == 3 then
|
||||
if node.param2 < 12 then
|
||||
return node.param2 + 8
|
||||
else
|
||||
return node.param2 - 8
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local get_stair_from_param = function(param, stairs)
|
||||
if param < 12 then
|
||||
if param < 4 then
|
||||
return {name = stairs[1], param2 = param}
|
||||
elseif param < 8 then
|
||||
return {name = stairs[2], param2 = param - 4}
|
||||
else
|
||||
return {name = stairs[3], param2 = param - 8}
|
||||
end
|
||||
else
|
||||
if param >= 20 then
|
||||
return {name = stairs[1], param2 = param}
|
||||
elseif param >= 16 then
|
||||
return {name = stairs[2], param2 = param + 4}
|
||||
else
|
||||
return {name = stairs[3], param2 = param + 8}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local stair_param_to_connect = function(param, ceiling)
|
||||
local out = {false, false, false, false, false, false, false, false}
|
||||
if not ceiling then
|
||||
if param == 0 then
|
||||
out[3] = true
|
||||
out[8] = true
|
||||
elseif param == 1 then
|
||||
out[2] = true
|
||||
out[5] = true
|
||||
elseif param == 2 then
|
||||
out[4] = true
|
||||
out[7] = true
|
||||
elseif param == 3 then
|
||||
out[1] = true
|
||||
out[6] = true
|
||||
elseif param == 4 then
|
||||
out[1] = true
|
||||
out[8] = true
|
||||
elseif param == 5 then
|
||||
out[2] = true
|
||||
out[3] = true
|
||||
elseif param == 6 then
|
||||
out[4] = true
|
||||
out[5] = true
|
||||
elseif param == 7 then
|
||||
out[6] = true
|
||||
out[7] = true
|
||||
elseif param == 8 then
|
||||
out[3] = true
|
||||
out[6] = true
|
||||
elseif param == 9 then
|
||||
out[5] = true
|
||||
out[8] = true
|
||||
elseif param == 10 then
|
||||
out[2] = true
|
||||
out[7] = true
|
||||
elseif param == 11 then
|
||||
out[1] = true
|
||||
out[4] = true
|
||||
end
|
||||
else
|
||||
if param == 12 then
|
||||
out[5] = true
|
||||
out[8] = true
|
||||
elseif param == 13 then
|
||||
out[3] = true
|
||||
out[6] = true
|
||||
elseif param == 14 then
|
||||
out[1] = true
|
||||
out[4] = true
|
||||
elseif param == 15 then
|
||||
out[2] = true
|
||||
out[7] = true
|
||||
elseif param == 16 then
|
||||
out[2] = true
|
||||
out[3] = true
|
||||
elseif param == 17 then
|
||||
out[1] = true
|
||||
out[8] = true
|
||||
elseif param == 18 then
|
||||
out[6] = true
|
||||
out[7] = true
|
||||
elseif param == 19 then
|
||||
out[4] = true
|
||||
out[5] = true
|
||||
elseif param == 20 then
|
||||
out[3] = true
|
||||
out[8] = true
|
||||
elseif param == 21 then
|
||||
out[1] = true
|
||||
out[6] = true
|
||||
elseif param == 22 then
|
||||
out[4] = true
|
||||
out[7] = true
|
||||
elseif param == 23 then
|
||||
out[2] = true
|
||||
out[5] = true
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local stair_connect_to_param = function(connect, ceiling)
|
||||
local param
|
||||
if not ceiling then
|
||||
if connect[3] and connect[8] then
|
||||
param = 0
|
||||
elseif connect[2] and connect[5] then
|
||||
param = 1
|
||||
elseif connect[4] and connect[7] then
|
||||
param = 2
|
||||
elseif connect[1] and connect[6] then
|
||||
param = 3
|
||||
elseif connect[1] and connect[8] then
|
||||
param = 4
|
||||
elseif connect[2] and connect[3] then
|
||||
param = 5
|
||||
elseif connect[4] and connect[5] then
|
||||
param = 6
|
||||
elseif connect[6] and connect[7] then
|
||||
param = 7
|
||||
elseif connect[3] and connect[6] then
|
||||
param = 8
|
||||
elseif connect[5] and connect[8] then
|
||||
param = 9
|
||||
elseif connect[2] and connect[7] then
|
||||
param = 10
|
||||
elseif connect[1] and connect[4] then
|
||||
param = 11
|
||||
end
|
||||
else
|
||||
if connect[5] and connect[8] then
|
||||
param = 12
|
||||
elseif connect[3] and connect[6] then
|
||||
param = 13
|
||||
elseif connect[1] and connect[4] then
|
||||
param = 14
|
||||
elseif connect[2] and connect[7] then
|
||||
param = 15
|
||||
elseif connect[2] and connect[3] then
|
||||
param = 16
|
||||
elseif connect[1] and connect[8] then
|
||||
param = 17
|
||||
elseif connect[6] and connect[7] then
|
||||
param = 18
|
||||
elseif connect[4] and connect[5] then
|
||||
param = 19
|
||||
elseif connect[3] and connect[8] then
|
||||
param = 20
|
||||
elseif connect[1] and connect[6] then
|
||||
param = 21
|
||||
elseif connect[4] and connect[7] then
|
||||
param = 22
|
||||
elseif connect[2] and connect[5] then
|
||||
param = 23
|
||||
end
|
||||
end
|
||||
return param
|
||||
end
|
||||
|
||||
--[[
|
||||
mcl_stairs.cornerstair.add(name, stairtiles)
|
||||
|
||||
* "name" is the name of the node to make corner stairs for.
|
||||
* "stairtiles" is an optional table of tiles to override textures for inner and outer stairs.
|
||||
* "stairtiles" format is:
|
||||
|
||||
{tiles_def_for_outer_stair, tiles_def_for_inner_stair}
|
||||
|
||||
Note: This function is called when you register a stair, no need to call it again!
|
||||
]]
|
||||
|
||||
function mcl_stairs.cornerstair.add(name, stairtiles)
|
||||
local node_def = minetest.registered_nodes[name]
|
||||
local outer_tiles
|
||||
local inner_tiles
|
||||
if stairtiles then
|
||||
outer_tiles = stairtiles[1]
|
||||
inner_tiles = stairtiles[2]
|
||||
else
|
||||
outer_tiles = node_def.tiles
|
||||
inner_tiles = node_def.tiles
|
||||
end
|
||||
local outer_groups = table.copy(node_def.groups)
|
||||
outer_groups.not_in_creative_inventory = 1
|
||||
local inner_groups = table.copy(outer_groups)
|
||||
outer_groups.stair = 2
|
||||
outer_groups.not_in_craft_guide = 1
|
||||
inner_groups.stair = 3
|
||||
inner_groups.not_in_craft_guide = 1
|
||||
local drop = node_def.drop or name
|
||||
local after_dig_node = function(pos, oldnode)
|
||||
local param = get_stair_param(oldnode)
|
||||
local ceiling
|
||||
if param < 12 then
|
||||
ceiling = false
|
||||
else
|
||||
ceiling = true
|
||||
end
|
||||
local connect = stair_param_to_connect(param, ceiling)
|
||||
local t = {
|
||||
{pos = {x = pos.x, y = pos.y, z = pos.z + 2}},
|
||||
{pos = {x = pos.x - 1, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z + 1}},
|
||||
{pos = {x = pos.x - 2, y = pos.y, z = pos.z}}, {pos = {x = pos.x - 1, y = pos.y, z = pos.z}},
|
||||
{pos = pos, connect = connect},
|
||||
{pos = {x = pos.x + 1, y = pos.y, z = pos.z}}, {pos = {x = pos.x + 2, y = pos.y, z = pos.z}},
|
||||
{pos = {x = pos.x - 1, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z - 1}},
|
||||
{pos = {x = pos.x, y = pos.y, z = pos.z - 2}}
|
||||
}
|
||||
for i,v in ipairs(t) do
|
||||
if not v.connect then
|
||||
local node = minetest.get_node(v.pos)
|
||||
local node_def = minetest.registered_nodes[node.name]
|
||||
if not node_def then
|
||||
return
|
||||
end
|
||||
if node_def.stairs then
|
||||
t[i].stairs = node_def.stairs
|
||||
t[i].connect = stair_param_to_connect(get_stair_param(node), ceiling)
|
||||
else
|
||||
t[i].connect = {false, false, false, false, false, false, false, false}
|
||||
end
|
||||
end
|
||||
end
|
||||
local swap_stair = function(index, n1, n2)
|
||||
local connect = {false, false, false, false, false, false, false, false}
|
||||
connect[n1] = true
|
||||
connect[n2] = true
|
||||
local node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[index].stairs)
|
||||
minetest.swap_node(t[index].pos, node)
|
||||
end
|
||||
if t[3].stairs then
|
||||
if t[7].connect[1] and t[3].connect[6] then
|
||||
if t[3].connect[1] and t[1].connect[6] then
|
||||
if t[2].connect[3] then
|
||||
swap_stair(3, 1, 8)
|
||||
elseif t[4].connect[7] then
|
||||
swap_stair(3, 1, 4)
|
||||
end
|
||||
elseif t[3].connect[7] then
|
||||
swap_stair(3, 4, 7)
|
||||
elseif t[3].connect[3] then
|
||||
swap_stair(3, 3, 8)
|
||||
end
|
||||
elseif t[7].connect[2] and t[3].connect[5] then
|
||||
if t[3].connect[2] and t[1].connect[5] then
|
||||
if t[4].connect[8] then
|
||||
swap_stair(3, 2, 3)
|
||||
elseif t[2].connect[4] then
|
||||
swap_stair(3, 2, 7)
|
||||
end
|
||||
elseif t[3].connect[4] then
|
||||
swap_stair(3, 4, 7)
|
||||
elseif t[3].connect[8] then
|
||||
swap_stair(3, 3, 8)
|
||||
end
|
||||
end
|
||||
end
|
||||
if t[8].stairs then
|
||||
if t[7].connect[3] and t[8].connect[8] then
|
||||
if t[8].connect[3] and t[9].connect[8] then
|
||||
if t[4].connect[5] then
|
||||
swap_stair(8, 2, 3)
|
||||
elseif t[12].connect[1] then
|
||||
swap_stair(8, 3, 6)
|
||||
end
|
||||
elseif t[8].connect[1] then
|
||||
swap_stair(8, 1, 6)
|
||||
elseif t[8].connect[5] then
|
||||
swap_stair(8, 2, 5)
|
||||
end
|
||||
elseif t[7].connect[4] and t[8].connect[7] then
|
||||
if t[8].connect[4] and t[9].connect[7] then
|
||||
if t[12].connect[2] then
|
||||
swap_stair(8, 4, 5)
|
||||
elseif t[4].connect[6] then
|
||||
swap_stair(8, 1, 4)
|
||||
end
|
||||
elseif t[8].connect[6] then
|
||||
swap_stair(8, 1, 6)
|
||||
elseif t[8].connect[2] then
|
||||
swap_stair(8, 2, 5)
|
||||
end
|
||||
end
|
||||
end
|
||||
if t[11].stairs then
|
||||
if t[7].connect[5] and t[11].connect[2] then
|
||||
if t[11].connect[5] and t[13].connect[2] then
|
||||
if t[12].connect[7] then
|
||||
swap_stair(11, 4, 5)
|
||||
elseif t[10].connect[3] then
|
||||
swap_stair(11, 5, 8)
|
||||
end
|
||||
elseif t[11].connect[3] then
|
||||
swap_stair(11, 3, 8)
|
||||
elseif t[11].connect[7] then
|
||||
swap_stair(11, 4, 7)
|
||||
end
|
||||
elseif t[7].connect[6] and t[11].connect[1] then
|
||||
if t[11].connect[6] and t[13].connect[1] then
|
||||
if t[10].connect[4] then
|
||||
swap_stair(11, 6, 7)
|
||||
elseif t[12].connect[8] then
|
||||
swap_stair(11, 3, 6)
|
||||
end
|
||||
elseif t[11].connect[8] then
|
||||
swap_stair(11, 3, 8)
|
||||
elseif t[11].connect[4] then
|
||||
swap_stair(11, 4, 7)
|
||||
end
|
||||
end
|
||||
end
|
||||
if t[6].stairs then
|
||||
if t[7].connect[7] and t[6].connect[4] then
|
||||
if t[6].connect[7] and t[5].connect[4] then
|
||||
if t[10].connect[1] then
|
||||
swap_stair(6, 6, 7)
|
||||
elseif t[2].connect[5] then
|
||||
swap_stair(6, 2, 7)
|
||||
end
|
||||
elseif t[6].connect[5] then
|
||||
swap_stair(6, 2, 5)
|
||||
elseif t[6].connect[1] then
|
||||
swap_stair(6, 1, 6)
|
||||
end
|
||||
elseif t[7].connect[8] and t[6].connect[3] then
|
||||
if t[6].connect[8] and t[5].connect[3] then
|
||||
if t[2].connect[6] then
|
||||
swap_stair(6, 1, 8)
|
||||
elseif t[10].connect[2] then
|
||||
swap_stair(6, 5, 8)
|
||||
end
|
||||
elseif t[6].connect[2] then
|
||||
swap_stair(6, 2, 5)
|
||||
elseif t[6].connect[6] then
|
||||
swap_stair(6, 1, 6)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.override_item(name, {
|
||||
stairs = {name, name.."_outer", name.."_inner"},
|
||||
after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end,
|
||||
on_place = nil,
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local node = minetest.get_node(pos)
|
||||
local ceiling = false
|
||||
if pointed_thing.under.y > pointed_thing.above.y then
|
||||
ceiling = true
|
||||
if node.param2 == 0 then node.param2 = 20
|
||||
elseif node.param2 == 1 then node.param2 = 23
|
||||
elseif node.param2 == 2 then node.param2 = 22
|
||||
elseif node.param2 == 3 then node.param2 = 21
|
||||
end
|
||||
end
|
||||
local connect = stair_param_to_connect(get_stair_param(node), ceiling)
|
||||
local t = {
|
||||
{pos = {x = pos.x - 1, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z + 1}},
|
||||
{pos = {x = pos.x - 1, y = pos.y, z = pos.z}}, {pos = pos, stairs = {name, name.."_outer", name.."_inner"}, connect = connect}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z}},
|
||||
{pos = {x = pos.x - 1, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z - 1}},
|
||||
}
|
||||
for i,v in ipairs(t) do
|
||||
if not v.connect then
|
||||
local node = minetest.get_node(v.pos)
|
||||
local node_def = minetest.registered_nodes[node.name]
|
||||
if not node_def then
|
||||
return
|
||||
end
|
||||
if node_def.stairs then
|
||||
t[i].stairs = node_def.stairs
|
||||
t[i].connect = stair_param_to_connect(get_stair_param(node), ceiling)
|
||||
else
|
||||
t[i].connect = {false, false, false, false, false, false, false, false}
|
||||
end
|
||||
end
|
||||
end
|
||||
local reset_node = function(n1, n2)
|
||||
local connect = {false, false, false, false, false, false, false, false}
|
||||
connect[n1] = true
|
||||
connect[n2] = true
|
||||
node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[5].stairs)
|
||||
end
|
||||
local swap_stair = function(index, n1, n2)
|
||||
local connect = {false, false, false, false, false, false, false, false}
|
||||
connect[n1] = true
|
||||
connect[n2] = true
|
||||
local node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[index].stairs)
|
||||
t[index].connect = connect
|
||||
minetest.swap_node(t[index].pos, node)
|
||||
end
|
||||
if connect[3] then
|
||||
if t[4].connect[2] and t[4].connect[5] and t[1].connect[5] and not t[7].connect[2] then
|
||||
swap_stair(4, 2, 3)
|
||||
elseif t[4].connect[1] and t[4].connect[6] and t[7].connect[1] and not t[1].connect[6] then
|
||||
swap_stair(4, 3, 6)
|
||||
end
|
||||
if t[6].connect[1] and t[6].connect[6] and t[3].connect[6] and not t[9].connect[1] then
|
||||
swap_stair(6, 1, 8)
|
||||
elseif t[6].connect[2] and t[6].connect[5] and t[9].connect[2] and not t[3].connect[5] then
|
||||
swap_stair(6, 5, 8)
|
||||
end
|
||||
if t[4].connect[3] ~= t[6].connect[8] then
|
||||
if t[4].connect[3] then
|
||||
if t[2].connect[6] then
|
||||
reset_node(1, 8)
|
||||
elseif t[8].connect[2] then
|
||||
reset_node(5, 8)
|
||||
elseif t[2].connect[4] and t[2].connect[7] and t[1].connect[4] and not t[3].connect[7] then
|
||||
swap_stair(2, 6, 7)
|
||||
reset_node(1, 8)
|
||||
elseif t[2].connect[3] and t[2].connect[8] and t[3].connect[8] and not t[1].connect[3] then
|
||||
swap_stair(2, 3, 6)
|
||||
reset_node(1, 8)
|
||||
elseif t[8].connect[3] and t[8].connect[8] and t[9].connect[8] and not t[7].connect[3] then
|
||||
swap_stair(8, 2, 3)
|
||||
reset_node(5, 8)
|
||||
elseif t[8].connect[4] and t[8].connect[7] and t[7].connect[4] and not t[9].connect[7] then
|
||||
swap_stair(8, 2, 7)
|
||||
reset_node(5, 8)
|
||||
end
|
||||
else
|
||||
if t[2].connect[5] then
|
||||
reset_node(2, 3)
|
||||
elseif t[8].connect[1] then
|
||||
reset_node(3, 6)
|
||||
elseif t[2].connect[4] and t[2].connect[7] and t[3].connect[7] and not t[1].connect[4] then
|
||||
swap_stair(2, 4, 5)
|
||||
reset_node(2, 3)
|
||||
elseif t[2].connect[3] and t[2].connect[8] and t[1].connect[3] and not t[3].connect[8] then
|
||||
swap_stair(2, 5, 8)
|
||||
reset_node(2, 3)
|
||||
elseif t[8].connect[3] and t[8].connect[8] and t[7].connect[3] and not t[9].connect[8] then
|
||||
swap_stair(8, 1, 8)
|
||||
reset_node(3, 6)
|
||||
elseif t[8].connect[4] and t[8].connect[7] and t[9].connect[7] and not t[7].connect[4] then
|
||||
swap_stair(8, 1, 4)
|
||||
reset_node(3, 6)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif connect[2] then
|
||||
if t[2].connect[4] and t[2].connect[7] and t[3].connect[7] and not t[1].connect[4] then
|
||||
swap_stair(2, 4, 5)
|
||||
elseif t[2].connect[3] and t[2].connect[8] and t[1].connect[3] and not t[3].connect[8] then
|
||||
swap_stair(2, 5, 8)
|
||||
end
|
||||
if t[8].connect[3] and t[8].connect[8] and t[9].connect[8] and not t[7].connect[3] then
|
||||
swap_stair(8, 2, 3)
|
||||
elseif t[8].connect[4] and t[8].connect[7] and t[7].connect[4] and not t[9].connect[7] then
|
||||
swap_stair(8, 2, 7)
|
||||
end
|
||||
if t[2].connect[5] ~= t[8].connect[2] then
|
||||
if t[2].connect[5] then
|
||||
if t[6].connect[8] then
|
||||
reset_node(2, 3)
|
||||
elseif t[4].connect[4] then
|
||||
reset_node(2, 7)
|
||||
elseif t[6].connect[1] and t[6].connect[6] and t[3].connect[6] and not t[9].connect[1] then
|
||||
swap_stair(6, 1, 8)
|
||||
reset_node(2, 3)
|
||||
elseif t[6].connect[2] and t[6].connect[5] and t[9].connect[2] and not t[3].connect[5] then
|
||||
swap_stair(6, 5, 8)
|
||||
reset_node(2, 3)
|
||||
elseif t[4].connect[2] and t[4].connect[5] and t[7].connect[2] and not t[1].connect[5] then
|
||||
swap_stair(4, 4, 5)
|
||||
reset_node(2, 7)
|
||||
elseif t[4].connect[1] and t[4].connect[6] and t[1].connect[6] and not t[7].connect[1] then
|
||||
swap_stair(4, 1, 4)
|
||||
reset_node(2, 7)
|
||||
end
|
||||
else
|
||||
if t[6].connect[7] then
|
||||
reset_node(4, 5)
|
||||
elseif t[4].connect[3] then
|
||||
reset_node(5, 8)
|
||||
elseif t[6].connect[1] and t[6].connect[6] and t[9].connect[1] and not t[3].connect[6] then
|
||||
swap_stair(6, 6, 7)
|
||||
reset_node(4, 5)
|
||||
elseif t[6].connect[2] and t[6].connect[5] and t[3].connect[5] and not t[9].connect[2] then
|
||||
swap_stair(6, 2, 7)
|
||||
reset_node(4, 5)
|
||||
elseif t[4].connect[2] and t[4].connect[5] and t[1].connect[5] and not t[7].connect[2] then
|
||||
swap_stair(4, 2, 3)
|
||||
reset_node(5, 8)
|
||||
elseif t[4].connect[1] and t[4].connect[6] and t[7].connect[1] and not t[1].connect[6] then
|
||||
swap_stair(4, 3, 6)
|
||||
reset_node(5, 8)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif connect[4] then
|
||||
if t[6].connect[1] and t[6].connect[6] and t[9].connect[1] and not t[3].connect[6] then
|
||||
swap_stair(6, 6, 7)
|
||||
elseif t[6].connect[2] and t[6].connect[5] and t[3].connect[5] and not t[9].connect[2] then
|
||||
swap_stair(6, 2, 7)
|
||||
end
|
||||
if t[4].connect[2] and t[4].connect[5] and t[7].connect[2] and not t[1].connect[5] then
|
||||
swap_stair(4, 4, 5)
|
||||
elseif t[4].connect[1] and t[4].connect[6] and t[1].connect[6] and not t[7].connect[1] then
|
||||
swap_stair(4, 1, 4)
|
||||
end
|
||||
if t[4].connect[4] ~= t[6].connect[7] then
|
||||
if t[4].connect[4] then
|
||||
if t[8].connect[1] then
|
||||
reset_node(6, 7)
|
||||
elseif t[2].connect[5] then
|
||||
reset_node(2, 7)
|
||||
elseif t[8].connect[3] and t[8].connect[8] and t[7].connect[3] and not t[9].connect[8] then
|
||||
swap_stair(8, 1, 8)
|
||||
reset_node(6, 7)
|
||||
elseif t[8].connect[4] and t[8].connect[7] and t[9].connect[7] and not t[7].connect[4] then
|
||||
swap_stair(8, 1, 4)
|
||||
reset_node(6, 7)
|
||||
elseif t[2].connect[4] and t[2].connect[7] and t[3].connect[7] and not t[1].connect[4] then
|
||||
swap_stair(2, 4, 5)
|
||||
reset_node(2, 7)
|
||||
elseif t[2].connect[3] and t[2].connect[8] and t[1].connect[3] and not t[3].connect[8] then
|
||||
swap_stair(2, 5, 8)
|
||||
reset_node(2, 7)
|
||||
end
|
||||
else
|
||||
if t[8].connect[2] then
|
||||
reset_node(4, 5)
|
||||
elseif t[2].connect[6] then
|
||||
reset_node(1, 4)
|
||||
elseif t[8].connect[3] and t[8].connect[8] and t[9].connect[8] and not t[7].connect[3] then
|
||||
swap_stair(8, 2, 3)
|
||||
reset_node(4, 5)
|
||||
elseif t[8].connect[4] and t[8].connect[7] and t[7].connect[4] and not t[9].connect[7] then
|
||||
swap_stair(8, 2, 7)
|
||||
reset_node(4, 5)
|
||||
elseif t[2].connect[4] and t[2].connect[7] and t[1].connect[4] and not t[3].connect[7] then
|
||||
swap_stair(2, 6, 7)
|
||||
reset_node(1, 4)
|
||||
elseif t[2].connect[3] and t[2].connect[8] and t[3].connect[8] and not t[1].connect[3] then
|
||||
swap_stair(2, 3, 6)
|
||||
reset_node(1, 4)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif connect[1] then
|
||||
if t[8].connect[3] and t[8].connect[8] and t[7].connect[3] and not t[9].connect[8] then
|
||||
swap_stair(8, 1, 8)
|
||||
elseif t[8].connect[4] and t[8].connect[7] and t[9].connect[7] and not t[7].connect[4] then
|
||||
swap_stair(8, 1, 4)
|
||||
end
|
||||
if t[2].connect[4] and t[2].connect[7] and t[1].connect[4] and not t[3].connect[7] then
|
||||
swap_stair(2, 6, 7)
|
||||
elseif t[2].connect[3] and t[2].connect[8] and t[3].connect[8] and not t[1].connect[3] then
|
||||
swap_stair(2, 3, 6)
|
||||
end
|
||||
if t[2].connect[6] ~= t[8].connect[1] then
|
||||
if t[2].connect[6] then
|
||||
if t[4].connect[3] then
|
||||
reset_node(1, 8)
|
||||
elseif t[6].connect[7] then
|
||||
reset_node(1, 4)
|
||||
elseif t[4].connect[2] and t[4].connect[5] and t[1].connect[5] and not t[7].connect[2] then
|
||||
swap_stair(4, 2, 3)
|
||||
reset_node(1, 8)
|
||||
elseif t[4].connect[1] and t[4].connect[6] and t[7].connect[1] and not t[1].connect[6] then
|
||||
swap_stair(4, 3, 6)
|
||||
reset_node(1, 8)
|
||||
elseif t[6].connect[1] and t[6].connect[6] and t[9].connect[1] and not t[3].connect[6] then
|
||||
swap_stair(6, 6, 7)
|
||||
reset_node(1, 4)
|
||||
elseif t[6].connect[2] and t[6].connect[5] and t[3].connect[5] and not t[9].connect[2] then
|
||||
swap_stair(6, 2, 7)
|
||||
reset_node(1, 4)
|
||||
end
|
||||
else
|
||||
if t[4].connect[4] then
|
||||
reset_node(6, 7)
|
||||
elseif t[6].connect[8] then
|
||||
reset_node(3, 6)
|
||||
elseif t[4].connect[2] and t[4].connect[5] and t[7].connect[2] and not t[1].connect[5] then
|
||||
swap_stair(4, 4, 5)
|
||||
reset_node(6, 7)
|
||||
elseif t[4].connect[1] and t[4].connect[6] and t[1].connect[6] and not t[7].connect[1] then
|
||||
swap_stair(4, 1, 4)
|
||||
reset_node(6, 7)
|
||||
elseif t[6].connect[1] and t[6].connect[6] and t[3].connect[6] and not t[9].connect[1] then
|
||||
swap_stair(6, 1, 8)
|
||||
reset_node(3, 6)
|
||||
elseif t[6].connect[2] and t[6].connect[5] and t[9].connect[2] and not t[3].connect[5] then
|
||||
swap_stair(6, 5, 8)
|
||||
reset_node(3, 6)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
})
|
||||
minetest.register_node(":"..name.."_outer", {
|
||||
description = node_def.description,
|
||||
_doc_items_create_entry = false,
|
||||
drawtype = "nodebox",
|
||||
tiles = outer_tiles,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = outer_groups,
|
||||
sounds = node_def.sounds,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
{-0.5, 0, 0, 0, 0.5, 0.5}
|
||||
}
|
||||
},
|
||||
drop = drop,
|
||||
stairs = {name, name.."_outer", name.."_inner"},
|
||||
after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end,
|
||||
_mcl_hardness = node_def._mcl_hardness,
|
||||
})
|
||||
minetest.register_node(":"..name.."_inner", {
|
||||
description = node_def.description,
|
||||
_doc_items_create_entry = false,
|
||||
drawtype = "nodebox",
|
||||
tiles = inner_tiles,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = inner_groups,
|
||||
sounds = node_def.sounds,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
{-0.5, 0, 0, 0.5, 0.5, 0.5},
|
||||
{-0.5, 0, -0.5, 0, 0.5, 0}
|
||||
}
|
||||
},
|
||||
drop = drop,
|
||||
stairs = {name, name.."_outer", name.."_inner"},
|
||||
after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end,
|
||||
_mcl_hardness = node_def._mcl_hardness,
|
||||
})
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry_alias("nodes", name, "nodes", name.."_inner")
|
||||
doc.add_entry_alias("nodes", name, "nodes", name.."_outer")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -8,6 +8,7 @@ mcl_stairs = {}
|
|||
-- Load other files
|
||||
|
||||
dofile(minetest.get_modpath("mcl_stairs").."/api.lua")
|
||||
dofile(minetest.get_modpath("mcl_stairs").."/cornerstair.lua")
|
||||
dofile(minetest.get_modpath("mcl_stairs").."/register.lua")
|
||||
dofile(minetest.get_modpath("mcl_stairs").."/crafting.lua")
|
||||
dofile(minetest.get_modpath("mcl_stairs").."/alias.lua")
|
||||
|
|
|
@ -3,90 +3,47 @@
|
|||
-- slabs actually take slightly longer to be dug than their stair counterparts.
|
||||
-- Note sure if it is a good idea to preserve this oddity.
|
||||
|
||||
mcl_stairs.register_stair("wood", "mcl_core:wood",
|
||||
{handy=1,axey=1, flammable=3,wood_stairs=1, material_wood=1},
|
||||
{"default_wood.png"},
|
||||
"Oak Wood Stairs",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2)
|
||||
mcl_stairs.register_slab("wood", "mcl_core:wood",
|
||||
{handy=1,axey=1, flammable=3,wood_slab=1, material_wood=1},
|
||||
{"default_wood.png"},
|
||||
"Oak Wood Slab",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2,
|
||||
"Double Oak Wood Slab")
|
||||
local function make_wood_corner_texture(subname)
|
||||
local t = minetest.registered_nodes["mcl_core:"..subname].tiles[1]
|
||||
return {
|
||||
{
|
||||
t.."^("..t.."^[transformR90^mcl_stairs_turntexture.png^[makealpha:255,0,255)",
|
||||
t.."^("..t.."^mcl_stairs_turntexture.png^[transformR270^[makealpha:255,0,255)",
|
||||
t
|
||||
},
|
||||
{
|
||||
t.."^("..t.."^[transformR90^(mcl_stairs_turntexture.png^[transformR180)^[makealpha:255,0,255)",
|
||||
t.."^("..t.."^[transformR270^(mcl_stairs_turntexture.png^[transformR90)^[makealpha:255,0,255)",
|
||||
t
|
||||
}
|
||||
}
|
||||
end
|
||||
local woods = {
|
||||
{ "wood", "default_wood.png", "Oak Wood Stairs", "Oak Wood Slab", "Double Oak Wood Slab" },
|
||||
{ "junglewood", "default_junglewood.png", "Jungle Wood Stairs", "Jungle Wood Slab", "Double Jungle Wood Slab" },
|
||||
{ "acaciawood", "default_acacia_wood.png", "Acacia Wood Stairs", "Acacia Wood Slab", "Double Acacia Wood Slab" },
|
||||
{ "sprucewood", "mcl_core_planks_spruce.png", "Spruce Wood Stairs", "Spruce Wood Slab", "Double Spruce Wood Slab" },
|
||||
{ "birchwood", "mcl_core_planks_birch.png", "Birch Wood Stairs", "Birch Wood Slab", "Double Birch Wood Slab" },
|
||||
{ "darkwood", "mcl_core_planks_big_oak.png", "Dark Oak Wood Stairs", "Dark Oak Wood Slab", "Double Dark Oak Wood Slab" },
|
||||
}
|
||||
|
||||
mcl_stairs.register_stair("junglewood", "mcl_core:junglewood",
|
||||
{handy=1,axey=1, flammable=3,wood_stairs=1, material_wood=1},
|
||||
{"default_junglewood.png"},
|
||||
"Jungle Wood Stairs",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2)
|
||||
mcl_stairs.register_slab("junglewood", "mcl_core:junglewood",
|
||||
{handy=1,axey=1, flammable=3,wood_slab=1, material_wood=1},
|
||||
{"default_junglewood.png"},
|
||||
"Jungle Wood Slab",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2,
|
||||
"Double Jungle Wood Slab")
|
||||
|
||||
mcl_stairs.register_stair("acaciawood", "mcl_core:acaciawood",
|
||||
{handy=1,axey=1, flammable=3,wood_stairs=1, material_wood=1},
|
||||
{"default_acacia_wood.png"},
|
||||
"Acacia Wood Stairs",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2)
|
||||
|
||||
mcl_stairs.register_slab("acaciawood", "mcl_core:acaciawood",
|
||||
{handy=1,axey=1, flammable=3,wood_slab=1, material_wood=1},
|
||||
{"default_acacia_wood.png"},
|
||||
"Acacia Wood Slab",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2,
|
||||
"Double Acacia Wood Slab")
|
||||
|
||||
mcl_stairs.register_stair("sprucewood", "mcl_core:sprucewood",
|
||||
{handy=1,axey=1, flammable=3,wood_stairs=1, material_wood=1},
|
||||
{"mcl_core_planks_spruce.png"},
|
||||
"Spruce Wood Stairs",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2)
|
||||
mcl_stairs.register_slab("sprucewood", "mcl_core:sprucewood",
|
||||
{handy=1,axey=1, flammable=3,wood_slab=1, material_wood=1},
|
||||
{"mcl_core_planks_spruce.png"},
|
||||
"Spruce Wood Slab",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2,
|
||||
"Double Spruce Wood Slab")
|
||||
|
||||
mcl_stairs.register_stair("birchwood", "mcl_core:birchwood",
|
||||
{handy=1,axey=1, flammable=3,wood_stairs=1, material_wood=1},
|
||||
{"mcl_core_planks_birch.png"},
|
||||
"Birch Wood Stairs",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2)
|
||||
mcl_stairs.register_slab("birchwood", "mcl_core:birchwood",
|
||||
{handy=1,axey=1, flammable=3,wood_slab=1, material_wood=1},
|
||||
{"mcl_core_planks_birch.png"},
|
||||
"Birch Wood Slab",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2,
|
||||
"Double Birch Wood Slab")
|
||||
|
||||
mcl_stairs.register_stair("darkwood", "mcl_core:darkwood",
|
||||
{handy=1,axey=1, flammable=3,wood_stairs=1, material_wood=1},
|
||||
{"mcl_core_planks_big_oak.png"},
|
||||
"Dark Oak Wood Stairs",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2)
|
||||
mcl_stairs.register_slab("darkwood", "mcl_core:darkwood",
|
||||
{handy=1,axey=1, flammable=3,wood_slab=1, material_wood=1},
|
||||
{"mcl_core_planks_big_oak.png"},
|
||||
"Dark Oak Wood Slab",
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2,
|
||||
"Double Dark Oak Wood Slab")
|
||||
for w=1, #woods do
|
||||
local wood = woods[w]
|
||||
mcl_stairs.register_stair(wood[1], "mcl_core:"..wood[1],
|
||||
{handy=1,axey=1, flammable=3,wood_stairs=1, material_wood=1},
|
||||
{wood[2]},
|
||||
wood[3],
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2,
|
||||
make_wood_corner_texture(wood[1]))
|
||||
mcl_stairs.register_slab(wood[1], "mcl_core:"..wood[1],
|
||||
{handy=1,axey=1, flammable=3,wood_slab=1, material_wood=1},
|
||||
{wood[2]},
|
||||
wood[4],
|
||||
mcl_sounds.node_sound_wood_defaults(),
|
||||
2,
|
||||
wood[5])
|
||||
end
|
||||
|
||||
mcl_stairs.register_slab("stone", "mcl_core:stone",
|
||||
{pickaxey=1, material_stone=1},
|
||||
|
@ -171,3 +128,26 @@ mcl_stairs.register_stair_and_slab_simple("prismarine", "mcl_ocean:prismarine",
|
|||
|
||||
mcl_stairs.register_stair_and_slab_simple("prismarine_brick", "mcl_ocean:prismarine_brick", "Prismarine Brick Stairs", "Prismarine Brick Slab", "Double Prismarine Brick Slab")
|
||||
mcl_stairs.register_stair_and_slab_simple("prismarine_dark", "mcl_ocean:prismarine_dark", "Dark Prismarine Stairs", "Dark Prismarine Slab", "Double Dark Prismarine Slab")
|
||||
|
||||
for _,v in ipairs({
|
||||
"wood",
|
||||
"junglewood",
|
||||
"sprucewood",
|
||||
"acaciawood",
|
||||
"birchwood",
|
||||
"darkwood"
|
||||
}) do
|
||||
local t = minetest.registered_nodes["mcl_core:"..v].tiles[1]
|
||||
mcl_stairs.cornerstair.add("mcl_stairs:stair_"..v, {
|
||||
{
|
||||
t.."^("..t.."^[transformR90^mcl_stairs_turntexture.png^[makealpha:255,0,255)",
|
||||
t.."^("..t.."^mcl_stairs_turntexture.png^[transformR270^[makealpha:255,0,255)",
|
||||
t
|
||||
},
|
||||
{
|
||||
t.."^("..t.."^[transformR90^(mcl_stairs_turntexture.png^[transformR180)^[makealpha:255,0,255)",
|
||||
t.."^("..t.."^[transformR270^(mcl_stairs_turntexture.png^[transformR90)^[makealpha:255,0,255)",
|
||||
t
|
||||
}
|
||||
})
|
||||
end
|
||||
|
|
BIN
mods/ITEMS/mcl_stairs/textures/mcl_stairs_turntexture.png
Normal file
BIN
mods/ITEMS/mcl_stairs/textures/mcl_stairs_turntexture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 126 B |
Loading…
Add table
Add a link
Reference in a new issue