Move definitions to a separate file

Make definitions table global
Replace stairsplus.copytable() function with table.copy()
This commit is contained in:
Thomas--S 2018-03-03 16:42:46 +01:00
parent 832b8f8817
commit ce27b43625
7 changed files with 425 additions and 448 deletions

409
stairsplus/defs.lua Normal file
View File

@ -0,0 +1,409 @@
--[[
More Blocks: registrations
Copyright (c) 2011-2018 Hugo Locurcio and contributors.
Licensed under the zlib license. See LICENSE.md for more information.
--]]
local box_slope = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
{-0.5, -0.25, -0.25, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.25, 0.5},
{-0.5, 0.25, 0.25, 0.5, 0.5, 0.5}
}
}
local box_slope_half = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, -0.25, 0.5, -0.25, 0.5},
{-0.5, -0.25, 0, 0.5, -0.125, 0.5},
{-0.5, -0.125, 0.25, 0.5, 0, 0.5},
}
}
local box_slope_half_raised = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.125, 0.5},
{-0.5, 0.125, -0.25, 0.5, 0.25, 0.5},
{-0.5, 0.25, 0, 0.5, 0.375, 0.5},
{-0.5, 0.375, 0.25, 0.5, 0.5, 0.5},
}
}
--==============================================================
local box_slope_inner = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
{-0.5, -0.5, -0.25, 0.5, 0, 0.5},
{-0.5, -0.5, -0.5, 0.25, 0, 0.5},
{-0.5, 0, -0.5, 0, 0.25, 0.5},
{-0.5, 0, 0, 0.5, 0.25, 0.5},
{-0.5, 0.25, 0.25, 0.5, 0.5, 0.5},
{-0.5, 0.25, -0.5, -0.25, 0.5, 0.5},
}
}
local box_slope_inner_half = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, -0.25, 0.5, -0.25, 0.5},
{-0.5, -0.375, -0.5, 0.25, -0.25, 0.5},
{-0.5, -0.25, -0.5, 0, -0.125, 0.5},
{-0.5, -0.25, 0, 0.5, -0.125, 0.5},
{-0.5, -0.125, 0.25, 0.5, 0, 0.5},
{-0.5, -0.125, -0.5, -0.25, 0, 0.5},
}
}
local box_slope_inner_half_raised = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.125, 0.5},
{-0.5, 0.125, -0.25, 0.5, 0.25, 0.5},
{-0.5, 0.125, -0.5, 0.25, 0.25, 0.5},
{-0.5, 0.25, -0.5, 0, 0.375, 0.5},
{-0.5, 0.25, 0, 0.5, 0.375, 0.5},
{-0.5, 0.375, 0.25, 0.5, 0.5, 0.5},
{-0.5, 0.375, -0.5, -0.25, 0.5, 0.5},
}
}
--==============================================================
local box_slope_outer = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
{-0.5, -0.25, -0.25, 0.25, 0, 0.5},
{-0.5, 0, 0, 0, 0.25, 0.5},
{-0.5, 0.25, 0.25, -0.25, 0.5, 0.5}
}
}
local box_slope_outer_half = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, -0.25, 0.25, -0.25, 0.5},
{-0.5, -0.25, 0, 0, -0.125, 0.5},
{-0.5, -0.125, 0.25, -0.25, 0, 0.5}
}
}
local box_slope_outer_half_raised = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.125, 0.5},
{-0.5, 0.125, -0.25, 0.25, 0.25, 0.5},
{-0.5, 0.25, 0, 0, 0.375, 0.5},
{-0.5, 0.375, 0.25, -0.25, 0.5, 0.5}
}
}
stairsplus.defs = {
["micro"] = {
[""] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0, 0.5},
},
},
["_1"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5},
},
},
["_2"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.375, 0.5},
},
},
["_4"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.25, 0.5},
},
},
["_12"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5},
},
},
["_14"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.375, 0.5},
},
},
["_15"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.4375, 0.5},
},
}
},
["panel"] = {
[""] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0, 0.5},
},
},
["_1"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5},
},
},
["_2"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, -0.375, 0.5},
},
},
["_4"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, -0.25, 0.5},
},
},
["_12"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5},
},
},
["_14"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.375, 0.5},
},
},
["_15"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.4375, 0.5},
},
}
},
["slab"] = {
[""] = 8,
["_quarter"] = 4,
["_three_quarter"] = 12,
["_1"] = 1,
["_2"] = 2,
["_14"] = 14,
["_15"] = 15,
["_two_sides"] = {
{ -0.5, -0.5, -0.5, 0.5, -7/16, 7/16 },
{ -0.5, -0.5, 7/16, 0.5, 0.5, 0.5 }
},
["_three_sides"] = {
{ -7/16, -0.5, -0.5, 0.5, -7/16, 7/16 },
{ -7/16, -0.5, 7/16, 0.5, 0.5, 0.5 },
{ -0.5, -0.5, -0.5, -7/16, 0.5, 0.5 }
},
["_three_sides_u"] = {
{ -0.5, -0.5, -0.5, 0.5, 0.5, -7/16 },
{ -0.5, -0.5, -7/16, 0.5, -7/16, 7/16 },
{ -0.5, -0.5, 7/16, 0.5, 0.5, 0.5 }
}
},
["slope"] = {
[""] = {
mesh = "moreblocks_slope.obj",
collision_box = box_slope,
selection_box = box_slope,
},
["_half"] = {
mesh = "moreblocks_slope_half.obj",
collision_box = box_slope_half,
selection_box = box_slope_half,
},
["_half_raised"] = {
mesh = "moreblocks_slope_half_raised.obj",
collision_box = box_slope_half_raised,
selection_box = box_slope_half_raised,
},
--==============================================================
["_inner"] = {
mesh = "moreblocks_slope_inner.obj",
collision_box = box_slope_inner,
selection_box = box_slope_inner,
},
["_inner_half"] = {
mesh = "moreblocks_slope_inner_half.obj",
collision_box = box_slope_inner_half,
selection_box = box_slope_inner_half,
},
["_inner_half_raised"] = {
mesh = "moreblocks_slope_inner_half_raised.obj",
collision_box = box_slope_inner_half_raised,
selection_box = box_slope_inner_half_raised,
},
--==============================================================
["_inner_cut"] = {
mesh = "moreblocks_slope_inner_cut.obj",
collision_box = box_slope_inner,
selection_box = box_slope_inner,
},
["_inner_cut_half"] = {
mesh = "moreblocks_slope_inner_cut_half.obj",
collision_box = box_slope_inner_half,
selection_box = box_slope_inner_half,
},
["_inner_cut_half_raised"] = {
mesh = "moreblocks_slope_inner_cut_half_raised.obj",
collision_box = box_slope_inner_half_raised,
selection_box = box_slope_inner_half_raised,
},
--==============================================================
["_outer"] = {
mesh = "moreblocks_slope_outer.obj",
collision_box = box_slope_outer,
selection_box = box_slope_outer,
},
["_outer_half"] = {
mesh = "moreblocks_slope_outer_half.obj",
collision_box = box_slope_outer_half,
selection_box = box_slope_outer_half,
},
["_outer_half_raised"] = {
mesh = "moreblocks_slope_outer_half_raised.obj",
collision_box = box_slope_outer_half_raised,
selection_box = box_slope_outer_half_raised,
},
--==============================================================
["_outer_cut"] = {
mesh = "moreblocks_slope_outer_cut.obj",
collision_box = box_slope_outer,
selection_box = box_slope_outer,
},
["_outer_cut_half"] = {
mesh = "moreblocks_slope_outer_cut_half.obj",
collision_box = box_slope_outer_half,
selection_box = box_slope_outer_half,
},
["_outer_cut_half_raised"] = {
mesh = "moreblocks_slope_outer_cut_half_raised.obj",
collision_box = box_slope_outer_half_raised,
selection_box = box_slope_outer_half_raised,
},
["_cut"] = {
mesh = "moreblocks_slope_cut.obj",
collision_box = box_slope_outer,
selection_box = box_slope_outer,
},
},
["stair"] = {
[""] = {
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},
},
},
},
["_half"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0, 0, 0.5},
{-0.5, 0, 0, 0, 0.5, 0.5},
},
},
},
["_right_half" ]= {
node_box = {
type = "fixed",
fixed = {
{0, -0.5, -0.5, 0.5, 0, 0.5},
{0, 0, 0, 0.5, 0.5, 0.5},
},
},
},
["_inner"] = {
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},
},
},
},
["_outer"] = {
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},
},
},
},
["_alt"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
},
["_alt_1"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.0625, -0.5, 0.5, 0, 0},
{-0.5, 0.4375, 0, 0.5, 0.5, 0.5},
},
},
},
["_alt_2"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.125, -0.5, 0.5, 0, 0},
{-0.5, 0.375, 0, 0.5, 0.5, 0.5},
},
},
},
["_alt_4"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.25, -0.5, 0.5, 0, 0},
{-0.5, 0.25, 0, 0.5, 0.5, 0.5},
},
},
},
},
}
for type,a in pairs(stairsplus.defs) do
for name,b in pairs(stairsplus.defs[type]) do
table.insert(stairsplus.shapes_list, { type .. "_", name })
end
end

View File

@ -19,21 +19,6 @@ and minetest.settings:get_bool("creative_mode") then
stairsplus.expect_infinite_stacks = true stairsplus.expect_infinite_stacks = true
end end
function stairsplus.copytable(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[stairsplus.copytable(orig_key)] = stairsplus.copytable(orig_value)
end
setmetatable(copy, stairsplus.copytable(getmetatable(orig)))
else
copy = orig
end
return copy
end
function stairsplus:prepare_groups(groups) function stairsplus:prepare_groups(groups)
local result = {} local result = {}
if groups then if groups then
@ -85,6 +70,7 @@ end
-- dofile(modpath.. "/aliases.lua") -- Not needed as of Q2 2013, uncomment to fix old maps. -- dofile(modpath.. "/aliases.lua") -- Not needed as of Q2 2013, uncomment to fix old maps.
-- dofile(modpath.. "/conversion.lua") -- Not needed as of Q2 2013, uncomment to fix old maps. -- dofile(modpath.. "/conversion.lua") -- Not needed as of Q2 2013, uncomment to fix old maps.
dofile(modpath .. "/defs.lua")
dofile(modpath .. "/stairs.lua") dofile(modpath .. "/stairs.lua")
dofile(modpath .. "/slabs.lua") dofile(modpath .. "/slabs.lua")
dofile(modpath .. "/slopes.lua") dofile(modpath .. "/slopes.lua")

View File

@ -20,71 +20,22 @@ function register_micro(modname, subname, recipeitem, groups, images, descriptio
}) })
end end
local microblocks_defs = {
[""] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0, 0.5},
},
},
["_1"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5},
},
},
["_2"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.375, 0.5},
},
},
["_4"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.25, 0.5},
},
},
["_12"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5},
},
},
["_14"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.375, 0.5},
},
},
["_15"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.4375, 0.5},
},
}
}
for k,v in pairs(microblocks_defs) do
table.insert(stairsplus.shapes_list, { "micro_", k })
end
function stairsplus:register_micro_alias(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_micro_alias(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(microblocks_defs) local defs = table.copy(stairsplus.defs["micro"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias(modname_old .. ":micro_" .. subname_old .. alternate, modname_new .. ":micro_" .. subname_new .. alternate) minetest.register_alias(modname_old .. ":micro_" .. subname_old .. alternate, modname_new .. ":micro_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_micro_alias_force(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_micro_alias_force(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(microblocks_defs) local defs = table.copy(stairsplus.defs["micro"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias_force(modname_old .. ":micro_" .. subname_old .. alternate, modname_new .. ":micro_" .. subname_new .. alternate) minetest.register_alias_force(modname_old .. ":micro_" .. subname_old .. alternate, modname_new .. ":micro_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_micro(modname, subname, recipeitem, fields) function stairsplus:register_micro(modname, subname, recipeitem, fields)
local defs = stairsplus.copytable(microblocks_defs) local defs = table.copy(stairsplus.defs["micro"])
local desc = S("%s Microblock"):format(fields.description) local desc = S("%s Microblock"):format(fields.description)
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
for k, v in pairs(fields) do for k, v in pairs(fields) do

View File

@ -20,71 +20,22 @@ function register_panel(modname, subname, recipeitem, groups, images, descriptio
}) })
end end
local panels_defs = {
[""] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0, 0.5},
},
},
["_1"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5},
},
},
["_2"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, -0.375, 0.5},
},
},
["_4"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, -0.25, 0.5},
},
},
["_12"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5},
},
},
["_14"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.375, 0.5},
},
},
["_15"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.4375, 0.5},
},
}
}
for k,v in pairs(panels_defs) do
table.insert(stairsplus.shapes_list, { "panel_", k })
end
function stairsplus:register_panel_alias(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_panel_alias(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(panels_defs) local defs = table.copy(stairsplus.defs["panel"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias(modname_old .. ":panel_" .. subname_old .. alternate, modname_new .. ":panel_" .. subname_new .. alternate) minetest.register_alias(modname_old .. ":panel_" .. subname_old .. alternate, modname_new .. ":panel_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_panel_alias_force(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_panel_alias_force(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(panels_defs) local defs = table.copy(stairsplus.defs["panel"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias_force(modname_old .. ":panel_" .. subname_old .. alternate, modname_new .. ":panel_" .. subname_new .. alternate) minetest.register_alias_force(modname_old .. ":panel_" .. subname_old .. alternate, modname_new .. ":panel_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_panel(modname, subname, recipeitem, fields) function stairsplus:register_panel(modname, subname, recipeitem, fields)
local defs = stairsplus.copytable(panels_defs) local defs = table.copy(stairsplus.defs["panel"])
local desc = S("%s Panel"):format(fields.description) local desc = S("%s Panel"):format(fields.description)
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
for k, v in pairs(fields) do for k, v in pairs(fields) do

View File

@ -20,50 +20,22 @@ function register_slab(modname, subname, recipeitem, groups, images, description
}) })
end end
local slabs_defs = {
[""] = 8,
["_quarter"] = 4,
["_three_quarter"] = 12,
["_1"] = 1,
["_2"] = 2,
["_14"] = 14,
["_15"] = 15,
["_two_sides"] = {
{ -0.5, -0.5, -0.5, 0.5, -7/16, 7/16 },
{ -0.5, -0.5, 7/16, 0.5, 0.5, 0.5 }
},
["_three_sides"] = {
{ -7/16, -0.5, -0.5, 0.5, -7/16, 7/16 },
{ -7/16, -0.5, 7/16, 0.5, 0.5, 0.5 },
{ -0.5, -0.5, -0.5, -7/16, 0.5, 0.5 }
},
["_three_sides_u"] = {
{ -0.5, -0.5, -0.5, 0.5, 0.5, -7/16 },
{ -0.5, -0.5, -7/16, 0.5, -7/16, 7/16 },
{ -0.5, -0.5, 7/16, 0.5, 0.5, 0.5 }
}
}
for k,v in pairs(slabs_defs) do
table.insert(stairsplus.shapes_list, { "slab_", k })
end
function stairsplus:register_slab_alias(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_slab_alias(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(slabs_defs) local defs = table.copy(stairsplus.defs["slab"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias(modname_old .. ":slab_" .. subname_old .. alternate, modname_new .. ":slab_" .. subname_new .. alternate) minetest.register_alias(modname_old .. ":slab_" .. subname_old .. alternate, modname_new .. ":slab_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_slab_alias_force(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_slab_alias_force(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(slabs_defs) local defs = table.copy(stairsplus.defs["slab"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias_force(modname_old .. ":slab_" .. subname_old .. alternate, modname_new .. ":slab_" .. subname_new .. alternate) minetest.register_alias_force(modname_old .. ":slab_" .. subname_old .. alternate, modname_new .. ":slab_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_slab(modname, subname, recipeitem, fields) function stairsplus:register_slab(modname, subname, recipeitem, fields)
local defs = stairsplus.copytable(slabs_defs) local defs = table.copy(stairsplus.defs["slab"])
local desc_base = S("%s Slab"):format(fields.description) local desc_base = S("%s Slab"):format(fields.description)
for alternate, shape in pairs(defs) do for alternate, shape in pairs(defs) do
local def = {} local def = {}

View File

@ -7,109 +7,6 @@ Licensed under the zlib license. See LICENSE.md for more information.
local S = moreblocks.intllib local S = moreblocks.intllib
local box_slope = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
{-0.5, -0.25, -0.25, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.25, 0.5},
{-0.5, 0.25, 0.25, 0.5, 0.5, 0.5}
}
}
local box_slope_half = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, -0.25, 0.5, -0.25, 0.5},
{-0.5, -0.25, 0, 0.5, -0.125, 0.5},
{-0.5, -0.125, 0.25, 0.5, 0, 0.5},
}
}
local box_slope_half_raised = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.125, 0.5},
{-0.5, 0.125, -0.25, 0.5, 0.25, 0.5},
{-0.5, 0.25, 0, 0.5, 0.375, 0.5},
{-0.5, 0.375, 0.25, 0.5, 0.5, 0.5},
}
}
--==============================================================
local box_slope_inner = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
{-0.5, -0.5, -0.25, 0.5, 0, 0.5},
{-0.5, -0.5, -0.5, 0.25, 0, 0.5},
{-0.5, 0, -0.5, 0, 0.25, 0.5},
{-0.5, 0, 0, 0.5, 0.25, 0.5},
{-0.5, 0.25, 0.25, 0.5, 0.5, 0.5},
{-0.5, 0.25, -0.5, -0.25, 0.5, 0.5},
}
}
local box_slope_inner_half = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, -0.25, 0.5, -0.25, 0.5},
{-0.5, -0.375, -0.5, 0.25, -0.25, 0.5},
{-0.5, -0.25, -0.5, 0, -0.125, 0.5},
{-0.5, -0.25, 0, 0.5, -0.125, 0.5},
{-0.5, -0.125, 0.25, 0.5, 0, 0.5},
{-0.5, -0.125, -0.5, -0.25, 0, 0.5},
}
}
local box_slope_inner_half_raised = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.125, 0.5},
{-0.5, 0.125, -0.25, 0.5, 0.25, 0.5},
{-0.5, 0.125, -0.5, 0.25, 0.25, 0.5},
{-0.5, 0.25, -0.5, 0, 0.375, 0.5},
{-0.5, 0.25, 0, 0.5, 0.375, 0.5},
{-0.5, 0.375, 0.25, 0.5, 0.5, 0.5},
{-0.5, 0.375, -0.5, -0.25, 0.5, 0.5},
}
}
--==============================================================
local box_slope_outer = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
{-0.5, -0.25, -0.25, 0.25, 0, 0.5},
{-0.5, 0, 0, 0, 0.25, 0.5},
{-0.5, 0.25, 0.25, -0.25, 0.5, 0.5}
}
}
local box_slope_outer_half = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, -0.25, 0.25, -0.25, 0.5},
{-0.5, -0.25, 0, 0, -0.125, 0.5},
{-0.5, -0.125, 0.25, -0.25, 0, 0.5}
}
}
local box_slope_outer_half_raised = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.125, 0.5},
{-0.5, 0.125, -0.25, 0.25, 0.25, 0.5},
{-0.5, 0.25, 0, 0, 0.375, 0.5},
{-0.5, 0.375, 0.25, -0.25, 0.5, 0.5}
}
}
-- Node will be called <modname>:slope_<subname> -- Node will be called <modname>:slope_<subname>
function register_slope(modname, subname, recipeitem, groups, images, description, drop, light) function register_slope(modname, subname, recipeitem, groups, images, description, drop, light)
@ -123,122 +20,22 @@ function register_slope(modname, subname, recipeitem, groups, images, descriptio
}) })
end end
local slopes_defs = {
[""] = {
mesh = "moreblocks_slope.obj",
collision_box = box_slope,
selection_box = box_slope,
},
["_half"] = {
mesh = "moreblocks_slope_half.obj",
collision_box = box_slope_half,
selection_box = box_slope_half,
},
["_half_raised"] = {
mesh = "moreblocks_slope_half_raised.obj",
collision_box = box_slope_half_raised,
selection_box = box_slope_half_raised,
},
--==============================================================
["_inner"] = {
mesh = "moreblocks_slope_inner.obj",
collision_box = box_slope_inner,
selection_box = box_slope_inner,
},
["_inner_half"] = {
mesh = "moreblocks_slope_inner_half.obj",
collision_box = box_slope_inner_half,
selection_box = box_slope_inner_half,
},
["_inner_half_raised"] = {
mesh = "moreblocks_slope_inner_half_raised.obj",
collision_box = box_slope_inner_half_raised,
selection_box = box_slope_inner_half_raised,
},
--==============================================================
["_inner_cut"] = {
mesh = "moreblocks_slope_inner_cut.obj",
collision_box = box_slope_inner,
selection_box = box_slope_inner,
},
["_inner_cut_half"] = {
mesh = "moreblocks_slope_inner_cut_half.obj",
collision_box = box_slope_inner_half,
selection_box = box_slope_inner_half,
},
["_inner_cut_half_raised"] = {
mesh = "moreblocks_slope_inner_cut_half_raised.obj",
collision_box = box_slope_inner_half_raised,
selection_box = box_slope_inner_half_raised,
},
--==============================================================
["_outer"] = {
mesh = "moreblocks_slope_outer.obj",
collision_box = box_slope_outer,
selection_box = box_slope_outer,
},
["_outer_half"] = {
mesh = "moreblocks_slope_outer_half.obj",
collision_box = box_slope_outer_half,
selection_box = box_slope_outer_half,
},
["_outer_half_raised"] = {
mesh = "moreblocks_slope_outer_half_raised.obj",
collision_box = box_slope_outer_half_raised,
selection_box = box_slope_outer_half_raised,
},
--==============================================================
["_outer_cut"] = {
mesh = "moreblocks_slope_outer_cut.obj",
collision_box = box_slope_outer,
selection_box = box_slope_outer,
},
["_outer_cut_half"] = {
mesh = "moreblocks_slope_outer_cut_half.obj",
collision_box = box_slope_outer_half,
selection_box = box_slope_outer_half,
},
["_outer_cut_half_raised"] = {
mesh = "moreblocks_slope_outer_cut_half_raised.obj",
collision_box = box_slope_outer_half_raised,
selection_box = box_slope_outer_half_raised,
},
["_cut"] = {
mesh = "moreblocks_slope_cut.obj",
collision_box = box_slope_outer,
selection_box = box_slope_outer,
},
}
for k,v in pairs(slopes_defs) do
table.insert(stairsplus.shapes_list, { "slope_", k })
end
function stairsplus:register_slope_alias(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_slope_alias(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(slopes_defs) local defs = table.copy(stairsplus.defs["slope"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias(modname_old .. ":slope_" .. subname_old .. alternate, modname_new .. ":slope_" .. subname_new .. alternate) minetest.register_alias(modname_old .. ":slope_" .. subname_old .. alternate, modname_new .. ":slope_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_slope_alias_force(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_slope_alias_force(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(slopes_defs) local defs = table.copy(stairsplus.defs["slope"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias_force(modname_old .. ":slope_" .. subname_old .. alternate, modname_new .. ":slope_" .. subname_new .. alternate) minetest.register_alias_force(modname_old .. ":slope_" .. subname_old .. alternate, modname_new .. ":slope_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_slope(modname, subname, recipeitem, fields) function stairsplus:register_slope(modname, subname, recipeitem, fields)
local defs = stairsplus.copytable(slopes_defs) local defs = table.copy(stairsplus.defs["slope"])
local desc = S("%s Slope"):format(fields.description) local desc = S("%s Slope"):format(fields.description)
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
for k, v in pairs(fields) do for k, v in pairs(fields) do

View File

@ -20,111 +20,22 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
}) })
end end
local stairs_defs = {
[""] = {
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},
},
},
},
["_half"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0, 0, 0.5},
{-0.5, 0, 0, 0, 0.5, 0.5},
},
},
},
["_right_half" ]= {
node_box = {
type = "fixed",
fixed = {
{0, -0.5, -0.5, 0.5, 0, 0.5},
{0, 0, 0, 0.5, 0.5, 0.5},
},
},
},
["_inner"] = {
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},
},
},
},
["_outer"] = {
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},
},
},
},
["_alt"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
},
["_alt_1"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.0625, -0.5, 0.5, 0, 0},
{-0.5, 0.4375, 0, 0.5, 0.5, 0.5},
},
},
},
["_alt_2"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.125, -0.5, 0.5, 0, 0},
{-0.5, 0.375, 0, 0.5, 0.5, 0.5},
},
},
},
["_alt_4"] = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.25, -0.5, 0.5, 0, 0},
{-0.5, 0.25, 0, 0.5, 0.5, 0.5},
},
},
},
}
for k,v in pairs(stairs_defs) do
table.insert(stairsplus.shapes_list, { "stair_", k })
end
function stairsplus:register_stair_alias(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_stair_alias(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(stairs_defs) local defs = table.copy(stairsplus.defs["stair"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate) minetest.register_alias(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_stair_alias_force(modname_old, subname_old, modname_new, subname_new) function stairsplus:register_stair_alias_force(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(stairs_defs) local defs = table.copy(stairsplus.defs["stair"])
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
minetest.register_alias_force(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate) minetest.register_alias_force(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate)
end end
end end
function stairsplus:register_stair(modname, subname, recipeitem, fields) function stairsplus:register_stair(modname, subname, recipeitem, fields)
local defs = stairsplus.copytable(stairs_defs) local defs = table.copy(stairsplus.defs["stair"])
local desc = S("%s Stairs"):format(fields.description) local desc = S("%s Stairs"):format(fields.description)
for alternate, def in pairs(defs) do for alternate, def in pairs(defs) do
for k, v in pairs(fields) do for k, v in pairs(fields) do