Convert node cut by Xdecor

Registrations
  -Simplify and add alias for xdecor

Micreoblocks, panels, slabs, stairs
  -Simplify for forcing alias or normal
  -Add function for convert block xdecor
  -Add alias in register.

Init
  function
     uppercase
      calculate the number of capital letters for lbm name
    normal_alias_or_force
      ....
  Add function for alll alias Xdecor

Add Settingtypes
This commit is contained in:
Jat15 2017-11-19 03:28:30 +01:00
parent f6e0db21b2
commit 78693c37be
7 changed files with 151 additions and 24 deletions

4
settingtypes.txt Normal file
View File

@ -0,0 +1,4 @@
#
moreblocks.circular_saw_crafting (If false desactive a craft the circular saw) bool true
moreblocks.conversion_xdecor>moreblocks (Convert all block cutting by xdecor) bool false

View File

@ -49,6 +49,28 @@ function stairsplus:prepare_groups(groups)
return result
end
function stairsplus:uppercase_index_string(words)
return string.gsub(
string.gsub(
minetest.serialize(
string.find(
words,"%u"
)
),
"return ", "_"
),
",", "_"
)
end
function stairsplus:normal_alias_or_force(force)
if force then
return minetest.register_alias_force
else
return minetest.register_alias
end
end
function stairsplus:register_all(modname, subname, recipeitem, fields)
self:register_stair(modname, subname, recipeitem, fields)
self:register_slab (modname, subname, recipeitem, fields)
@ -72,6 +94,12 @@ function stairsplus:register_alias_force_all(modname_old, subname_old, modname_n
self:register_panel_alias_force(modname_old, subname_old, modname_new, subname_new)
self:register_micro_alias_force(modname_old, subname_old, modname_new, subname_new)
end
function stairsplus:register_xdecor_alias_all(modname_old, subname_old, modname_new, subname_new, force)
self:register_stairs_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
self:register_slabs_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
self:register_panels_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
self:register_micro_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
end
function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, images, description, drop, light)
stairsplus:register_all(modname, subname, recipeitem, {

View File

@ -69,18 +69,46 @@ 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_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
if not(minetest.settings:get_bool("moreblocks.conversion_xdecor>moreblocks")) then
return
end
minetest.register_lbm({
name = ":replace_xdecor_mano_cube_" .. modname_old .. "_" .. string.lower(subname_old) .. "_" .. stairsplus:uppercase_index_string(subname_old) .. "_" ..
modname_new .."_" .. string.lower(subname_new) .. stairsplus:uppercase_index_string(subname_new) .. string.gsub(minetest.serialize(force),"return ", "_"),
nodenames = {modname_old .. ":" .. subname_old .. "_nanoslab", modname_old .. ":" .. subname_old .."_cube"},
run_at_every_load = false,
action = function(pos, node)
if modname_old .. ":" .. subname_old .. "_nanoslab" == node.name then
nodename = modname_new .. ":micro_" .. subname_new .. "_1"
else
nodename = modname_new .. ":micro_" .. subname_new
end
if node.param2 == 0 or node.param2%4 == 0 then
minetest.set_node(pos, {name = nodename, param2 = node.param2+3})
else
minetest.set_node(pos, {name = nodename, param2 = node.param2-1})
end
end,
})
end
function register_micro_alias_and_force(modname_old, subname_old, modname_new, subname_new, force)
local stairsplus_alias = stairsplus:normal_alias_or_force(force)
local defs = stairsplus.copytable(microblocks_defs)
for alternate, def in pairs(defs) do
minetest.register_alias(modname_old .. ":micro_" .. subname_old .. alternate, modname_new .. ":micro_" .. subname_new .. alternate)
stairsplus_alias(modname_old .. ":micro_" .. subname_old .. alternate, modname_new .. ":micro_" .. subname_new .. alternate)
end
stairsplus:register_micro_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
end
function stairsplus:register_micro_alias(modname_old, subname_old, modname_new, subname_new)
register_micro_alias_and_force(modname_old, subname_old, modname_new, subname_new, false)
end
function stairsplus:register_micro_alias_force(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(microblocks_defs)
for alternate, def in pairs(defs) do
minetest.register_alias_force(modname_old .. ":micro_" .. subname_old .. alternate, modname_new .. ":micro_" .. subname_new .. alternate)
end
register_micro_alias_and_force(modname_old, subname_old, modname_new, subname_new, true)
end
function stairsplus:register_micro(modname, subname, recipeitem, fields)
@ -102,6 +130,7 @@ function stairsplus:register_micro(modname, subname, recipeitem, fields)
minetest.register_node(":" ..modname.. ":micro_" ..subname..alternate, def)
end
minetest.register_alias(modname.. ":micro_" ..subname.. "_bottom", modname.. ":micro_" ..subname)
stairsplus:register_micro_xdecor_alias(modname, subname, modname, subname, false)
circular_saw.known_nodes[recipeitem] = {modname, subname}

View File

@ -69,18 +69,47 @@ 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_panels_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
if not(minetest.settings:get_bool("moreblocks.conversion_xdecor>moreblocks")) then
return
end
minetest.register_lbm({
name = ":replace_xdecor_panel_micropanel_" .. modname_old .. "_" .. string.lower(subname_old) .. "_" .. stairsplus:uppercase_index_string(subname_old) .. "_" ..
modname_new .. "_" .. string.lower(subname_new) .. stairsplus:uppercase_index_string(subname_new) .. string.gsub(minetest.serialize(force),"return ", "_"),
nodenames = {modname_old .. ":" .. subname_old .. "_micropanel", modname_old .. ":" .. subname_old .. "_panel"},
run_at_every_load = false,
action = function(pos, node)
if modname_old .. ":" .. subname_old .. "_micropanel" == node.name then
nodename = modname_new .. ":panel_" .. subname_new .. "_1"
else
nodename = modname_new .. ":panel_" .. subname_new
end
if node.param2 == 0 or node.param2%4 == 0 then
minetest.set_node(pos, {name = nodename, param2 = node.param2+2})
elseif node.param2%4 == 3 or node.param2%2 == 0 then
minetest.set_node(pos, {name = nodename, param2 = node.param2-2})
else
minetest.set_node(pos, {name = nodename, param2 = node.param2+2})
end
end,
})
end
function register_panel_alias_and_force(modname_old, subname_old, modname_new, subname_new, force)
local stairsplus_alias = stairsplus:normal_alias_or_force(force)
local defs = stairsplus.copytable(panels_defs)
for alternate, def in pairs(defs) do
minetest.register_alias(modname_old .. ":panel_" .. subname_old .. alternate, modname_new .. ":panel_" .. subname_new .. alternate)
stairsplus_alias(modname_old .. ":panel_" .. subname_old .. alternate, modname_new .. ":panel_" .. subname_new .. alternate)
end
stairsplus:register_panels_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
end
function stairsplus:register_panel_alias(modname_old, subname_old, modname_new, subname_new)
register_panel_alias_and_force(modname_old, subname_old, modname_new, subname_new, false)
end
function stairsplus:register_panel_alias_force(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(panels_defs)
for alternate, def in pairs(defs) do
minetest.register_alias_force(modname_old .. ":panel_" .. subname_old .. alternate, modname_new .. ":panel_" .. subname_new .. alternate)
end
register_panel_alias_and_force(modname_old, subname_old, modname_new, subname_new, true)
end
function stairsplus:register_panel(modname, subname, recipeitem, fields)
@ -102,6 +131,7 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields)
minetest.register_node(":" ..modname.. ":panel_" ..subname..alternate, def)
end
minetest.register_alias(modname.. ":panel_" ..subname.. "_bottom", modname.. ":panel_" ..subname)
stairsplus:register_panels_xdecor_alias(modname, subname, modname, subname, false)
circular_saw.known_nodes[recipeitem] = {modname, subname}

View File

@ -72,6 +72,7 @@ for _, name in pairs(default_nodes) do
stairsplus:register_all(mod, name, nodename, ndef)
minetest.register_alias_force("stairs:stair_" .. name, mod .. ":stair_" .. name)
minetest.register_alias_force("stairs:slab_" .. name, mod .. ":slab_" .. name)
stairsplus:register_xdecor_alias_all("default", name, mod, name, false)
end
-- farming registrations
@ -87,6 +88,7 @@ if minetest.get_modpath("farming") then
stairsplus:register_all(mod, name, nodename, ndef)
minetest.register_alias_force("stairs:stair_" .. name, mod .. ":stair_" .. name)
minetest.register_alias_force("stairs:slab_" .. name, mod .. ":slab_" .. name)
stairsplus:register_xdecor_alias_all("farming", name, mod, name, false)
end
end

View File

@ -48,18 +48,31 @@ 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_slabs_xdecor_alias(modname_old, subname_old, modname_new, subname_new)
if not(minetest.settings:get_bool("moreblocks.conversion_xdecor>moreblocks")) then
return
end
local stairsplus_alias = stairsplus:normal_alias_or_force(force)
stairsplus_alias(modname_old .. ":" .. subname_old .."_microslab", modname_new .. ":slab_" .. subname_new .. "_1")
stairsplus_alias("stairs:slab_" .. subname_old, modname_new .. ":slab_" .. subname_new)
end
function register_slab_alias_and_force(modname_old, subname_old, modname_new, subname_new, force)
local stairsplus_alias = stairsplus:normal_alias_or_force(force)
local defs = stairsplus.copytable(slabs_defs)
for alternate, def in pairs(defs) do
minetest.register_alias(modname_old .. ":slab_" .. subname_old .. alternate, modname_new .. ":slab_" .. subname_new .. alternate)
stairsplus_alias(modname_old .. ":slab_" .. subname_old .. alternate, modname_new .. ":slab_" .. subname_new .. alternate)
end
stairsplus:register_slabs_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
end
function stairsplus:register_slab_alias(modname_old, subname_old, modname_new, subname_new)
register_slab_alias_and_force(modname_old, subname_old, modname_new, subname_new, false)
minetest.register_alias("stairs:slab_" .. subname_old, modname_new .. ":slab_" .. subname_new)
end
function stairsplus:register_slab_alias_force(modname_old, subname_old, modname_new, subname_new)
local defs = stairsplus.copytable(slabs_defs)
for alternate, def in pairs(defs) do
minetest.register_alias_force(modname_old .. ":slab_" .. subname_old .. alternate, modname_new .. ":slab_" .. subname_new .. alternate)
end
register_slab_alias_and_force(modname_old, subname_old, modname_new, subname_new, true)
end
function stairsplus:register_slab(modname, subname, recipeitem, fields)
@ -100,6 +113,8 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields)
minetest.register_node(":" .. modname .. ":slab_" .. subname .. alternate, def)
end
stairsplus:register_slabs_xdecor_alias(modname, subname, modname, subname, false)
circular_saw.known_nodes[recipeitem] = {modname, subname}
-- Some saw-less recipes:

View File

@ -109,18 +109,35 @@ 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)
local defs = stairsplus.copytable(stairs_defs)
for alternate, def in pairs(defs) do
minetest.register_alias(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate)
function stairsplus:register_stairs_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
if not(minetest.settings:get_bool("moreblocks.conversion_xdecor>moreblocks")) then
return
end
local stairsplus_alias = stairsplus:normal_alias_or_force(force)
stairsplus_alias(modname_old .. ":" .. subname_old .."_thinstair", modname_new .. ":stair_" ..subname_new .. "_alt_1")
stairsplus_alias(modname_old .. ":" .. subname_old .."_doublepanel", modname_new .. ":stair_" ..subname_new .. "_alt")
stairsplus_alias(modname_old .. ":" .. subname_old .."_halfstair", modname_new .. ":stair_" ..subname_new .. "_half")
stairsplus_alias(modname_old .. ":" .. subname_old .."_outerstair", modname_new .. ":stair_" ..subname_new .. "_outer")
stairsplus_alias(modname_old .. ":" .. subname_old .."_innerstair", modname_new .. ":stair_" ..subname_new .. "_inner")
stairsplus_alias("stairs:stair_" .. subname_old, modname_new .. ":stair_" .. subname_new)
end
function stairsplus:register_stair_alias_force(modname_old, subname_old, modname_new, subname_new)
function register_stair_alias_and_force(modname_old, subname_old, modname_new, subname_new, force)
local stairsplus_alias = stairsplus:normal_alias_or_force(force)
local defs = stairsplus.copytable(stairs_defs)
for alternate, def in pairs(defs) do
minetest.register_alias_force(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate)
stairsplus_alias(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate)
end
stairsplus:register_stairs_xdecor_alias(modname_old, subname_old, modname_new, subname_new, force)
end
function stairsplus:register_stair_alias(modname_old, subname_old, modname_new, subname_new)
register_stair_alias_and_force(modname_old, subname_old, modname_new, subname_new, false)
end
function stairsplus:register_stair_alias_force(modname_old, subname_old, modname_new, subname_new)
register_stair_alias_and_force(modname_old, subname_old, modname_new, subname_new, true)
end
function stairsplus:register_stair(modname, subname, recipeitem, fields)
@ -145,6 +162,8 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields)
minetest.register_node(":" .. modname .. ":stair_" .. subname .. alternate, def)
end
stairsplus:register_stairs_xdecor_alias(modname, subname, modname, subname, false)
circular_saw.known_nodes[recipeitem] = {modname, subname}
-- Some saw-less recipes: