minetest-mm/mods/bakedclay/init.lua

255 lines
5.8 KiB
Lua
Raw Normal View History

2020-10-26 17:38:53 +01:00
2024-12-19 12:55:40 +01:00
-- translation support
local S = minetest.get_translator("bakedclay")
-- list of clay colours
2020-10-26 17:38:53 +01:00
local clay = {
2024-12-19 12:55:40 +01:00
{"natural", S("Natural")},
{"white", S("White")},
{"grey", S("Grey")},
{"black", S("Black")},
{"red", S("Red")},
{"yellow", S("Yellow")},
{"green", S("Green")},
{"cyan", S("Cyan")},
{"blue", S("Blue")},
{"magenta", S("Magenta")},
{"orange", S("Orange")},
{"violet", S("Violet")},
{"brown", S("Brown")},
{"pink", S("Pink")},
{"dark_grey", S("Dark Grey")},
{"dark_green", S("Dark Green")}
2020-10-26 17:38:53 +01:00
}
2024-12-19 12:55:40 +01:00
-- check mod support
2020-10-26 17:38:53 +01:00
local techcnc_mod = minetest.get_modpath("technic_cnc")
local stairs_mod = minetest.get_modpath("stairs")
local stairsplus_mod = minetest.get_modpath("moreblocks")
2024-12-19 12:55:40 +01:00
and minetest.global_exists("stairsplus")
local stairsplus_compat = minetest.settings:get_bool("stairsplus_clay_compatibility") ~= false
-- scroll through colours
2020-10-26 17:38:53 +01:00
for _, clay in pairs(clay) do
2024-12-19 12:55:40 +01:00
-- register node
2020-10-26 17:38:53 +01:00
minetest.register_node("bakedclay:" .. clay[1], {
2024-12-19 12:55:40 +01:00
description = clay[2] .. " " .. S("Baked Clay"),
2020-10-26 17:38:53 +01:00
tiles = {"baked_clay_" .. clay[1] ..".png"},
groups = {cracky = 3, bakedclay = 1},
2024-12-19 12:55:40 +01:00
sounds = default.node_sound_stone_defaults(),
is_ground_content = false
2020-10-26 17:38:53 +01:00
})
2024-12-19 12:55:40 +01:00
-- register craft recipe
2021-07-24 12:22:10 +02:00
2020-10-26 17:38:53 +01:00
if clay[1] ~= "natural" then
2021-07-24 12:22:10 +02:00
2020-10-26 17:38:53 +01:00
minetest.register_craft({
output = "bakedclay:" .. clay[1] .. " 8",
recipe = {
{"group:bakedclay", "group:bakedclay", "group:bakedclay"},
{"group:bakedclay", "dye:" .. clay[1], "group:bakedclay"},
{"group:bakedclay", "group:bakedclay", "group:bakedclay"}
2021-07-24 12:22:10 +02:00
}
2020-10-26 17:38:53 +01:00
})
end
2021-07-24 12:22:10 +02:00
-- stairs plus
2024-12-19 12:55:40 +01:00
2020-10-26 17:38:53 +01:00
if stairsplus_mod then
2021-07-24 12:22:10 +02:00
stairsplus:register_all("bakedclay", "baked_clay_" .. clay[1],
"bakedclay:" .. clay[1], {
2024-12-19 12:55:40 +01:00
description = clay[2] .. " " .. S("Baked Clay"),
2020-10-26 17:38:53 +01:00
tiles = {"baked_clay_" .. clay[1] .. ".png"},
groups = {cracky = 3},
2021-07-24 12:22:10 +02:00
sounds = default.node_sound_stone_defaults()
2020-10-26 17:38:53 +01:00
})
2024-12-19 12:55:40 +01:00
if stairsplus_compat then
stairsplus:register_alias_all("bakedclay", clay[1],
"bakedclay", "baked_clay_" .. clay[1])
2020-10-26 17:38:53 +01:00
2024-12-19 12:55:40 +01:00
minetest.register_alias("stairs:slab_bakedclay_".. clay[1],
"bakedclay:slab_baked_clay_" .. clay[1])
2021-07-24 12:22:10 +02:00
2024-12-19 12:55:40 +01:00
minetest.register_alias("stairs:stair_bakedclay_".. clay[1],
"bakedclay:stair_baked_clay_" .. clay[1])
end
2021-07-24 12:22:10 +02:00
-- stairs redo
2024-12-19 12:55:40 +01:00
2020-10-26 17:38:53 +01:00
elseif stairs_mod and stairs.mod then
stairs.register_all("bakedclay_" .. clay[1], "bakedclay:" .. clay[1],
{cracky = 3},
{"baked_clay_" .. clay[1] .. ".png"},
2024-12-19 12:55:40 +01:00
clay[2] .. " " .. S("Baked Clay"),
2020-10-26 17:38:53 +01:00
default.node_sound_stone_defaults())
2021-07-24 12:22:10 +02:00
-- default stairs
2024-12-19 12:55:40 +01:00
2020-10-26 17:38:53 +01:00
elseif stairs_mod then
stairs.register_stair_and_slab("bakedclay_".. clay[1], "bakedclay:".. clay[1],
{cracky = 3},
{"baked_clay_" .. clay[1] .. ".png"},
2024-12-19 12:55:40 +01:00
clay[2] .. " " .. S("Baked Clay Stair"),
clay[2] .. " " .. S("Baked Clay Slab"),
2020-10-26 17:38:53 +01:00
default.node_sound_stone_defaults())
end
2024-12-19 12:55:40 +01:00
-- register bakedclay for use in technic_cnc mod after all mods loaded
2020-10-26 17:38:53 +01:00
if techcnc_mod then
2024-12-19 12:55:40 +01:00
minetest.register_on_mods_loaded(function()
technic_cnc.register_all("bakedclay:" .. clay[1],
{cracky = 3, not_in_creative_inventory = 1},
{"baked_clay_" .. clay[1] .. ".png"},
clay[2] .. " Baked Clay")
end)
2020-10-26 17:38:53 +01:00
end
end
2024-12-19 12:55:40 +01:00
-- Terracotta blocks
2021-07-24 12:22:10 +02:00
for _, clay in pairs(clay) do
if clay[1] ~= "natural" then
local texture = "baked_clay_terracotta_" .. clay[1] ..".png"
minetest.register_node("bakedclay:terracotta_" .. clay[1], {
2024-12-19 12:55:40 +01:00
description = clay[2] .. " " .. S("Glazed Terracotta"),
2021-07-24 12:22:10 +02:00
tiles = {
texture .. "",
texture .. "",
texture .. "^[transformR180",
texture .. "",
texture .. "^[transformR270",
texture .. "^[transformR90",
},
paramtype2 = "facedir",
groups = {cracky = 3, terracotta = 1},
sounds = default.node_sound_stone_defaults(),
2024-12-19 12:55:40 +01:00
is_ground_content = false,
2021-07-24 12:22:10 +02:00
on_place = minetest.rotate_node
})
minetest.register_craft({
type = "cooking",
output = "bakedclay:terracotta_" .. clay[1],
recipe = "bakedclay:" .. clay[1]
})
end
end
2021-07-30 10:43:13 +02:00
minetest.register_alias("bakedclay:terracotta_light_blue", "bakedclay:terracotta_cyan")
2021-07-24 12:22:10 +02:00
2024-12-19 12:55:40 +01:00
-- cook clay block into natural baked clay
2020-10-26 17:38:53 +01:00
minetest.register_craft({
type = "cooking",
output = "bakedclay:natural",
2024-12-19 12:55:40 +01:00
recipe = "default:clay"
2020-10-26 17:38:53 +01:00
})
-- register a few extra dye colour options
2024-12-19 12:55:40 +01:00
minetest.register_craft({
2020-10-26 17:38:53 +01:00
output = "dye:green 4",
2024-12-19 12:55:40 +01:00
recipe = {{"default:cactus"}}
2020-10-26 17:38:53 +01:00
})
2024-12-19 12:55:40 +01:00
minetest.register_craft({
2020-10-26 17:38:53 +01:00
output = "dye:brown 4",
2024-12-19 12:55:40 +01:00
recipe = {{"default:dry_shrub"}}
2020-10-26 17:38:53 +01:00
})
2021-07-24 12:22:10 +02:00
-- only add light grey recipe if unifieddye mod isnt present (conflict)
2024-12-19 12:55:40 +01:00
2021-07-24 12:22:10 +02:00
if not minetest.get_modpath("unifieddyes") then
minetest.register_craft( {
2024-12-19 12:55:40 +01:00
output = "dye:dark_grey 3",
recipe = {{"dye:black", "dye:black", "dye:white"}}
})
minetest.register_craft( {
2021-07-24 12:22:10 +02:00
output = "dye:grey 3",
2024-12-19 12:55:40 +01:00
recipe = {{"dye:black", "dye:white", "dye:white"}}
2021-07-24 12:22:10 +02:00
})
end
-- 2x2 red baked clay makes 16x clay brick
2024-12-19 12:55:40 +01:00
2020-10-26 17:38:53 +01:00
minetest.register_craft( {
output = "default:clay_brick 16",
recipe = {
{"bakedclay:red", "bakedclay:red"},
2024-12-19 12:55:40 +01:00
{"bakedclay:red", "bakedclay:red"}
2020-10-26 17:38:53 +01:00
}
})
-- colored clay compatibility
2021-07-24 12:22:10 +02:00
2020-10-26 17:38:53 +01:00
if minetest.settings:get_bool("colored_clay_compatibility") == true then
2024-12-19 12:55:40 +01:00
local cc = {
{"black", "black"},
{"blue", "blue"},
{"bright", "natural"},
{"brown", "brown"},
{"cyan", "cyan"},
{"dark_green", "dark_green"},
{"dark_grey", "dark_grey"},
{"green", "green"},
{"grey", "grey"},
{"hardened", "natural"},
{"magenta", "magenta"},
{"orange", "orange"},
{"pink", "pink"},
{"red", "red"},
{"violet", "violet"},
{"white", "white"},
{"yellow", "yellow"}
}
2020-10-26 17:38:53 +01:00
2024-12-19 12:55:40 +01:00
for n = 1, #cc do
2020-10-26 17:38:53 +01:00
2024-12-19 12:55:40 +01:00
local nod1 = "colored_clay:" .. cc[n][1]
local nod2 = "bakedclay:" .. cc[n][2]
2020-10-26 17:38:53 +01:00
2024-12-19 12:55:40 +01:00
minetest.register_alias(nod1, nod2)
2020-10-26 17:38:53 +01:00
2024-12-19 12:55:40 +01:00
if stairsplus_mod then
stairsplus:register_alias_all("colored_clay", cc[n][1], "bakedclay", cc[n][2])
end
2020-10-26 17:38:53 +01:00
end
end
2024-12-19 12:55:40 +01:00
-- get mod path
2020-10-26 17:38:53 +01:00
2024-12-19 12:55:40 +01:00
local path = minetest.get_modpath("bakedclay")
2021-08-04 22:12:08 +02:00
2024-12-19 12:55:40 +01:00
-- add new flowers
dofile(path .. "/flowers.lua")
2021-08-04 22:12:08 +02:00
2024-12-19 12:55:40 +01:00
-- add lucky blocks if mod present
if minetest.get_modpath("lucky_block") then
dofile(path .. "/lucky_block.lua")
end
2020-10-26 17:38:53 +01:00
print ("[MOD] Baked Clay loaded")