hi this is actually really good may I suggest a way to compact all that code into 1 nice and small function?
you can use a for loop like this(this is a snippet of code from my skytest mod feel free to use this snippet)
Code: Select all
for name, data in pairs({
dirt = {
mat = "default:dirt",
tex = "default_dirt.png",
},
obsidian = {
mat = "default:obsidian",
tex = "default_obsidian.png",
},
}) do
minetest.register_node("packed_things:compressed_"..name.."_9c", {
description = "compressed "..name.." 9c",
tiles = {""..data.tex.."^[colorize:black:50"},
groups = {cracky = 2}
})
minetest.register_node("packed_things:double_compressed_"..name.."_81c", {
description = "double compressed "..name.." 81c",
tiles = {""..data.tex.."^[colorize:black:70"},
groups = {cracky = 2}
})
minetest.register_node("packed_things:triple_compressed_"..name.."_729c", {
description = "triple compressed "..name.." 729c",
tiles = {""..data.tex.."^[colorize:black:90"},
groups = {cracky = 2}
})
minetest.register_node("packed_things:quadruple_compressed_"..name.."_6561c", {
description = "quadruple compressed "..name.." 6561c",
tiles = {""..data.tex.."^[colorize:black:130"},
groups = {cracky = 2}
})
minetest.register_node("packed_things:quintuple_compressed_"..name.."_59049c", {
description = "quintuple compressed "..name.." 59,049c",
tiles = {""..data.tex.."^[colorize:black:150"},
groups = {cracky = 2}
})
minetest.register_node("packed_things:sextuple_compressed_"..name.."_531441c", {
description = "sextuple compressed "..name.." 531,441c",
tiles = {""..data.tex.."^[colorize:black:170"},
groups = {cracky = 2}
})
minetest.register_node("packed_things:septuple_compressed_"..name.."_4782969c", {
description = "septuple compressed "..name.." 4,782,969c",
tiles = {""..data.tex.."^[colorize:black:190"},
groups = {cracky = 2}
})
minetest.register_node("packed_things:octuple_compressed_"..name.."_43046721c", {
description = "octuple compressed "..name.." 43,046,721c",
tiles = {""..data.tex.."^[colorize:black:210"},
drawtype = "nodebox",
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
-- top (Y+)
{-0.0625, 0, -0.0625, 0.0625, 0.0625, 0.0625},
{-0.125, 0.0625, -0.125, 0.125, 0.125, -0.0625},
{-0.125, 0.0625, 0.0625, 0.125, 0.125, 0.125},
{0.0625, 0.0625, -0.0625, 0.125, 0.125, 0.0625},
{-0.125, 0.0625, -0.0625, -0.0625, 0.125, 0.0625},
{0.125, 0.125, -0.1875, 0.1875, 0.1875, 0.1875},
{-0.1875, 0.125, -0.1875, -0.125, 0.1875, 0.1875},
{-0.125, 0.125, 0.125, 0.125, 0.1875, 0.1875},
{-0.125, 0.125, -0.1875, 0.125, 0.1875, -0.125},
{-0.25, 0.1875, 0.1875, 0.25, 0.25, 0.25},
{-0.25, 0.1875, -0.25, 0.25, 0.25, -0.1875},
{0.1875, 0.1875, -0.1875, 0.25, 0.25, 0.1875},
{-0.25, 0.1875, -0.1875, -0.1875, 0.25, 0.1875},
{-0.3125, 0.25, -0.3125, -0.25, 0.3125, 0.3125},
{0.25, 0.25, -0.3125, 0.3125, 0.3125, 0.3125},
{-0.25, 0.25, -0.3125, 0.25, 0.3125, -0.25},
{-0.25, 0.25, 0.25, 0.25, 0.3125, 0.3125},
{-0.375, 0.3125, 0.3125, 0.375, 0.375, 0.375},
{-0.375, 0.3125, -0.375, 0.375, 0.375, -0.3125},
{0.3125, 0.3125, -0.3125, 0.375, 0.375, 0.3125},
{-0.375, 0.3125, -0.3125, -0.3125, 0.375, 0.3125},
{-0.4375, 0.375, -0.4375, -0.375, 0.4375, 0.4375},
{0.375, 0.375, -0.4375, 0.4375, 0.4375, 0.4375},
{-0.4375, 0.375, 0.375, 0.4375, 0.4375, 0.4375},
{-0.375, 0.375, -0.4375, 0.375, 0.4375, -0.375},
-- bottom (Y-)
{-0.0625, -0.0625, -0.0625, 0.0625, -0, 0.0625},
{0.0625, -0.125, -0.125, 0.125, -0.0625, 0.125},
{-0.125, -0.125, -0.125, -0.0625, -0.0625, 0.125},
{-0.0625, -0.125, -0.125, 0.0625, -0.0625, -0.0625},
{-0.0625, -0.125, 0.0625, 0.0625, -0.0625, 0.125},
{-0.1875, -0.1875, -0.1875, 0.1875, -0.125, -0.125},
{-0.1875, -0.1875, 0.125, 0.1875, -0.125, 0.1875},
{-0.1875, -0.1875, -0.125, -0.125, -0.125, 0.125},
{0.125, -0.1875, -0.125, 0.1875, -0.125, 0.125},
{-0.25, -0.25, -0.25, -0.1875, -0.1875, 0.25},
{0.1875, -0.25, -0.25, 0.25, -0.1875, 0.25},
{-0.1875, -0.25, -0.25, 0.1875, -0.1875, -0.1875},
{-0.1875, -0.25, 0.1875, 0.1875, -0.1875, 0.25},
{-0.3125, -0.3125, 0.25, 0.3125, -0.25, 0.3125},
{-0.3125, -0.3125, -0.3125, 0.3125, -0.25, -0.25},
{0.25, -0.3125, -0.25, 0.3125, -0.25, 0.25},
{-0.3125, -0.3125, -0.25, -0.25, -0.25, 0.25},
{-0.375, -0.375, -0.375, -0.3125, -0.3125, 0.375},
{0.3125, -0.375, -0.375, 0.375, -0.3125, 0.375},
{-0.3125, -0.375, -0.375, 0.3125, -0.3125, -0.3125},
{-0.3125, -0.375, 0.3125, 0.3125, -0.3125, 0.375},
{-0.4375, -0.4375, 0.375, 0.4375, -0.375, 0.4375},
{-0.4375, -0.4375, -0.4375, 0.4375, -0.375, -0.375},
{-0.4375, -0.4375, -0.4375, -0.375, -0.375, 0.4375},
{0.375, -0.4375, -0.375, 0.4375, -0.375, 0.375},
-- right (X+)
{0, -0.0625, -0.0625, 0.0625, 0.0625, 0.0625},
{0.0625, -0.125, -0.125, 0.125, 0.125, -0.0625},
{0.0625, -0.125, 0.0625, 0.125, 0.125, 0.125},
{0.0625, -0.125, -0.0625, 0.125, -0.0625, 0.0625},
{0.0625, 0.0625, -0.0625, 0.125, 0.125, 0.0625},
{0.125, -0.1875, -0.1875, 0.1875, -0.125, 0.1875},
{0.125, 0.125, -0.1875, 0.1875, 0.1875, 0.1875},
{0.125, -0.125, 0.125, 0.1875, 0.125, 0.1875},
{0.125, -0.125, -0.1875, 0.1875, 0.125, -0.125},
{0.1875, -0.25, 0.1875, 0.25, 0.25, 0.25},
{0.1875, -0.25, -0.25, 0.25, 0.25, -0.1875},
{0.1875, -0.25, -0.1875, 0.25, -0.1875, 0.1875},
{0.1875, 0.1875, -0.1875, 0.25, 0.25, 0.1875},
{0.25, 0.25, -0.3125, 0.3125, 0.3125, 0.3125},
{0.25, -0.3125, -0.3125, 0.3125, -0.25, 0.3125},
{0.25, -0.25, -0.3125, 0.3125, 0.25, -0.25},
{0.25, -0.25, 0.25, 0.3125, 0.25, 0.3125},
{0.3125, -0.375, 0.3125, 0.375, 0.375, 0.375},
{0.3125, -0.375, -0.375, 0.375, 0.375, -0.3125},
{0.3125, -0.375, -0.3125, 0.375, -0.3125, 0.3125},
{0.3125, 0.3125, -0.3125, 0.375, 0.375, 0.3125},
{0.375, 0.375, -0.4375, 0.4375, 0.4375, 0.4375},
{0.375, -0.4375, -0.4375, 0.4375, -0.375, 0.4375},
{0.375, -0.4375, 0.375, 0.4375, 0.4375, 0.4375},
{0.375, -0.375, -0.4375, 0.4375, 0.375, -0.375},
-- left (X-)
{-0.0625, -0.0625, -0.0625, -0, 0.0625, 0.0625},
{-0.125, -0.125, 0.0625, -0.0625, 0.125, 0.125},
{-0.125, -0.125, -0.125, -0.0625, 0.125, -0.0625},
{-0.125, -0.125, -0.0625, -0.0625, -0.0625, 0.0625},
{-0.125, 0.0625, -0.0625, -0.0625, 0.125, 0.0625},
{-0.1875, -0.1875, -0.1875, -0.125, -0.125, 0.1875},
{-0.1875, 0.125, -0.1875, -0.125, 0.1875, 0.1875},
{-0.1875, -0.125, -0.1875, -0.125, 0.125, -0.125},
{-0.1875, -0.125, 0.125, -0.125, 0.125, 0.1875},
{-0.25, -0.25, -0.25, -0.1875, 0.25, -0.1875},
{-0.25, -0.25, 0.1875, -0.1875, 0.25, 0.25},
{-0.25, -0.25, -0.1875, -0.1875, -0.1875, 0.1875},
{-0.25, 0.1875, -0.1875, -0.1875, 0.25, 0.1875},
{-0.3125, 0.25, -0.3125, -0.25, 0.3125, 0.3125},
{-0.3125, -0.3125, -0.3125, -0.25, -0.25, 0.3125},
{-0.3125, -0.25, 0.25, -0.25, 0.25, 0.3125},
{-0.3125, -0.25, -0.3125, -0.25, 0.25, -0.25},
{-0.375, -0.375, -0.375, -0.3125, 0.375, -0.3125},
{-0.375, -0.375, 0.3125, -0.3125, 0.375, 0.375},
{-0.375, -0.375, -0.3125, -0.3125, -0.3125, 0.3125},
{-0.375, 0.3125, -0.3125, -0.3125, 0.375, 0.3125},
{-0.4375, 0.375, -0.4375, -0.375, 0.4375, 0.4375},
{-0.4375, -0.4375, -0.4375, -0.375, -0.375, 0.4375},
{-0.4375, -0.4375, -0.4375, -0.375, 0.4375, -0.375},
{-0.4375, -0.375, 0.375, -0.375, 0.375, 0.4375},
-- back (Z+)
{-0.0625, -0.0625, 0, 0.0625, 0.0625, 0.0625},
{0.0625, -0.125, 0.0625, 0.125, 0.125, 0.125},
{-0.125, -0.125, 0.0625, -0.0625, 0.125, 0.125},
{-0.0625, -0.125, 0.0625, 0.0625, -0.0625, 0.125},
{-0.0625, 0.0625, 0.0625, 0.0625, 0.125, 0.125},
{-0.1875, -0.1875, 0.125, 0.1875, -0.125, 0.1875},
{-0.1875, 0.125, 0.125, 0.1875, 0.1875, 0.1875},
{-0.1875, -0.125, 0.125, -0.125, 0.125, 0.1875},
{0.125, -0.125, 0.125, 0.1875, 0.125, 0.1875},
{-0.25, -0.25, 0.1875, -0.1875, 0.25, 0.25},
{0.1875, -0.25, 0.1875, 0.25, 0.25, 0.25},
{-0.1875, -0.25, 0.1875, 0.1875, -0.1875, 0.25},
{-0.1875, 0.1875, 0.1875, 0.1875, 0.25, 0.25},
{-0.3125, 0.25, 0.25, 0.3125, 0.3125, 0.3125},
{-0.3125, -0.3125, 0.25, 0.3125, -0.25, 0.3125},
{0.25, -0.25, 0.25, 0.3125, 0.25, 0.3125},
{-0.3125, -0.25, 0.25, -0.25, 0.25, 0.3125},
{-0.375, -0.375, 0.3125, -0.3125, 0.375, 0.375},
{0.3125, -0.375, 0.3125, 0.375, 0.375, 0.375},
{-0.3125, -0.375, 0.3125, 0.3125, -0.3125, 0.375},
{-0.3125, 0.3125, 0.3125, 0.3125, 0.375, 0.375},
{-0.4375, 0.375, 0.375, 0.4375, 0.4375, 0.4375},
{-0.4375, -0.4375, 0.375, 0.4375, -0.375, 0.4375},
{-0.4375, -0.4375, 0.375, -0.375, 0.4375, 0.4375},
{0.375, -0.375, 0.375, 0.4375, 0.375, 0.4375},
-- front (Z-)
{-0.0625, -0.0625, -0.0625, 0.0625, 0.0625, -0},
{-0.125, -0.125, -0.125, -0.0625, 0.125, -0.0625},
{0.0625, -0.125, -0.125, 0.125, 0.125, -0.0625},
{-0.0625, -0.125, -0.125, 0.0625, -0.0625, -0.0625},
{-0.0625, 0.0625, -0.125, 0.0625, 0.125, -0.0625},
{-0.1875, -0.1875, -0.1875, 0.1875, -0.125, -0.125},
{-0.1875, 0.125, -0.1875, 0.1875, 0.1875, -0.125},
{0.125, -0.125, -0.1875, 0.1875, 0.125, -0.125},
{-0.1875, -0.125, -0.1875, -0.125, 0.125, -0.125},
{0.1875, -0.25, -0.25, 0.25, 0.25, -0.1875},
{-0.25, -0.25, -0.25, -0.1875, 0.25, -0.1875},
{-0.1875, -0.25, -0.25, 0.1875, -0.1875, -0.1875},
{-0.1875, 0.1875, -0.25, 0.1875, 0.25, -0.1875},
{-0.3125, 0.25, -0.3125, 0.3125, 0.3125, -0.25},
{-0.3125, -0.3125, -0.3125, 0.3125, -0.25, -0.25},
{-0.3125, -0.25, -0.3125, -0.25, 0.25, -0.25},
{0.25, -0.25, -0.3125, 0.3125, 0.25, -0.25},
{0.3125, -0.375, -0.375, 0.375, 0.375, -0.3125},
{-0.375, -0.375, -0.375, -0.3125, 0.375, -0.3125},
{-0.3125, -0.375, -0.375, 0.3125, -0.3125, -0.3125},
{-0.3125, 0.3125, -0.375, 0.3125, 0.375, -0.3125},
{-0.4375, 0.375, -0.4375, 0.4375, 0.4375, -0.375},
{-0.4375, -0.4375, -0.4375, 0.4375, -0.375, -0.375},
{0.375, -0.4375, -0.4375, 0.4375, 0.4375, -0.375},
{-0.4375, -0.375, -0.4375, -0.375, 0.375, -0.375},
-- corner frame
{-0.4375, 0.4375, 0.4375, 0.4375, 0.5, 0.5},
{-0.4375, -0.5, 0.4375, 0.4375, -0.4375, 0.5},
{-0.5, -0.5, 0.4375, -0.4375, 0.5, 0.5},
{0.4375, -0.5, 0.4375, 0.5, 0.5, 0.5},
{-0.5, 0.4375, -0.4375, -0.4375, 0.5, 0.4375},
{-0.5, -0.5, -0.4375, -0.4375, -0.4375, 0.4375},
{0.4375, 0.4375, -0.4375, 0.5, 0.5, 0.4375},
{0.4375, -0.5, -0.4375, 0.5, -0.4375, 0.4375},
{-0.5, 0.4375, -0.5, 0.5, 0.5, -0.4375},
{-0.5, -0.5, -0.5, 0.5, -0.4375, -0.4375},
{0.4375, -0.4375, -0.5, 0.5, 0.4375, -0.4375},
{-0.5, -0.4375, -0.5, -0.4375, 0.4375, -0.4375},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
})
minetest.register_craft({
output = "packed_things:compressed_"..name.."_9c",
recipe = {
{data.mat, data.mat, data.mat },
{data.mat, data.mat, data.mat },
{data.mat, data.mat, data.mat },
}
})
minetest.register_craft({
output = "packed_things:double_compressed_"..name.."_81c",
recipe = {
{"packed_things:compressed_"..name.."_9c","packed_things:compressed_"..name.."_9c","packed_things:compressed_"..name.."_9c"},
{"packed_things:compressed_"..name.."_9c","packed_things:compressed_"..name.."_9c","packed_things:compressed_"..name.."_9c"},
{"packed_things:compressed_"..name.."_9c","packed_things:compressed_"..name.."_9c","packed_things:compressed_"..name.."_9c"},
}
})
minetest.register_craft({
output = "packed_things:triple_compressed_"..name.."_729c",
recipe = {
{"packed_things:double_compressed_"..name.."_81c","packed_things:double_compressed_"..name.."_81c","packed_things:double_compressed_"..name.."_81c"},
{"packed_things:double_compressed_"..name.."_81c","packed_things:double_compressed_"..name.."_81c","packed_things:double_compressed_"..name.."_81c"},
{"packed_things:double_compressed_"..name.."_81c","packed_things:double_compressed_"..name.."_81c","packed_things:double_compressed_"..name.."_81c"},
}
})
minetest.register_craft({
output = "packed_things:quadruple_compressed_"..name.."_6561c",
recipe = {
{"packed_things:triple_compressed_"..name.."_729c", "packed_things:triple_compressed_"..name.."_729c", "packed_things:triple_compressed_"..name.."_729c"},
{"packed_things:triple_compressed_"..name.."_729c", "packed_things:triple_compressed_"..name.."_729c", "packed_things:triple_compressed_"..name.."_729c"},
{"packed_things:triple_compressed_"..name.."_729c", "packed_things:triple_compressed_"..name.."_729c", "packed_things:triple_compressed_"..name.."_729c"},
}
})
minetest.register_craft({
output = "packed_things:quintuple_compressed_"..name.."_59049c",
recipe = {
{"packed_things:quadruple_compressed_"..name.."_6561c","packed_things:quadruple_compressed_"..name.."_6561c","packed_things:quadruple_compressed_"..name.."_6561c"},
{"packed_things:quadruple_compressed_"..name.."_6561c","packed_things:quadruple_compressed_"..name.."_6561c","packed_things:quadruple_compressed_"..name.."_6561c"},
{"packed_things:quadruple_compressed_"..name.."_6561c","packed_things:quadruple_compressed_"..name.."_6561c","packed_things:quadruple_compressed_"..name.."_6561c"},
}
})
minetest.register_craft({
output = "packed_things:sextuple_compressed_"..name.."_531441c",
recipe = {
{"packed_things:quintuple_compressed_"..name.."_59049c","packed_things:quintuple_compressed_"..name.."_59049c","packed_things:quintuple_compressed_"..name.."_59049c"},
{"packed_things:quintuple_compressed_"..name.."_59049c","packed_things:quintuple_compressed_"..name.."_59049c","packed_things:quintuple_compressed_"..name.."_59049c"},
{"packed_things:quintuple_compressed_"..name.."_59049c","packed_things:quintuple_compressed_"..name.."_59049c","packed_things:quintuple_compressed_"..name.."_59049c"},
}
})
minetest.register_craft({
output = "packed_things:septuple_compressed_"..name.."_4782969c",
recipe = {
{"packed_things:sextuple_compressed_"..name.."_531441c","packed_things:sextuple_compressed_"..name.."_531441c","packed_things:sextuple_compressed_"..name.."_531441c"},
{"packed_things:sextuple_compressed_"..name.."_531441c","packed_things:sextuple_compressed_"..name.."_531441c","packed_things:sextuple_compressed_"..name.."_531441c"},
{"packed_things:sextuple_compressed_"..name.."_531441c","packed_things:sextuple_compressed_"..name.."_531441c","packed_things:sextuple_compressed_"..name.."_531441c"},
}
})
minetest.register_craft({
output = "packed_things:octuple_compressed_"..name.."_43046721c",
recipe = {
{"packed_things:septuple_compressed_"..name.."_4782969c","packed_things:septuple_compressed_"..name.."_4782969c","packed_things:septuple_compressed_"..name.."_4782969c"},
{"packed_things:septuple_compressed_"..name.."_4782969c","packed_things:septuple_compressed_"..name.."_4782969c","packed_things:septuple_compressed_"..name.."_4782969c"},
{"packed_things:septuple_compressed_"..name.."_4782969c","packed_things:septuple_compressed_"..name.."_4782969c","packed_things:septuple_compressed_"..name.."_4782969c"},
}
})
--uncompressed "..name.."
minetest.register_craft({
output = ""..data.mat.." 9",
recipe = {
{"packed_things:compressed_"..name.."_9c","",""},
{"","",""},
{"","",""},
}
})
minetest.register_craft({
output = "packed_things:compressed_"..name.."_9c 9",
recipe = {
{"packed_things:double_compressed_"..name.."_81c","",""},
{"","",""},
{"","",""},
}
})
minetest.register_craft({
output = "packed_things:double_compressed_"..name.."_81c 9",
recipe = {
{"packed_things:triple_compressed_"..name.."_729c","",""},
{"","",""},
{"","",""},
}
})
minetest.register_craft({
output = "packed_things:triple_compressed_"..name.."_729c 9",
recipe = {
{"packed_things:quadruple_compressed_"..name.."_6561c","",""},
{"","",""},
{"","",""},
}
})
minetest.register_craft({
output = "packed_things:quadruple_compressed_"..name.."_6561c 9",
recipe = {
{"packed_things:quintuple_compressed_"..name.."_59049c","",""},
{"","",""},
{"","",""},
}
})
minetest.register_craft({
output = "packed_things:quintuple_compressed_"..name.."_59049c 9",
recipe = {
{"packed_things:sextuple_compressed_"..name.."_531441c","",""},
{"","",""},
{"","",""},
}
})
minetest.register_craft({
output = "packed_things:sextuple_compressed_"..name.."_531441c 9",
recipe = {
{"packed_things:septuple_compressed_"..name.."_4782969c","",""},
{"","",""},
{"","",""},
}
})
minetest.register_craft({
output = "packed_things:septuple_compressed_"..name.."_4782969c 9",
recipe = {
{"packed_things:octuple_compressed_"..name.."_43046721c","",""},
{"","",""},
{"","",""},
}
})
end
1. adding all the nodes
2. compressing crafts aka the 9=1 and so forth
3. uncrafts 1=9 and so forth
4. all the nodes have cool descriptions like "octuple compressed cobble 43,046,721c"
5. all the max tier blocks (the octuple compressed ones) have a really cool node box look
6.no need to create new textures for each node this loop will automatically make the more compressed ones look darker each compressed node looks darker than the last
7. I have already changed the mod id to packed_things for yay so its super easy for you to copy paste and use
8. its super compact code
9. its insanely easy to add a new block just go to the top and copy
replace the "default:dirt" with the id of the new block to be compressed and replace the "default_dirt.png" with the texture for the compressed blocks and bada bing bada boom you have just added a whole new set of compressed blocks with only 4 new lines of code it should look like this(using snow as an example)