1
0
mirror of https://github.com/Sokomine/cottages.git synced 2025-07-17 07:00:22 +02:00

refactor, cleanup, API, bugfixes (#1)

This commit is contained in:
fluxionary
2022-10-09 14:13:47 -07:00
committed by flux
parent dbe69bcfaf
commit 846308ef5a
106 changed files with 5594 additions and 4596 deletions

111
modules/roof/api.lua Normal file
View File

@ -0,0 +1,111 @@
local S = cottages.S
local ci = cottages.craftitems
function cottages.roof.register_roof(name, material, tiles)
minetest.register_node("cottages:roof_" .. name, {
description = S("Roof " .. name),
drawtype = "nodebox",
tiles = tiles,
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2},
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},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
is_ground_content = false,
})
minetest.register_node("cottages:roof_connector_" .. name, {
description = S("Roof connector " .. name),
drawtype = "nodebox",
-- top, bottom, side1, side2, inner, outer
tiles = tiles,
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2},
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},
},
},
selection_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},
},
},
is_ground_content = false,
})
-- this one is the slab version of the above roof
minetest.register_node("cottages:roof_flat_" .. name, {
description = S("Roof (flat) " .. name),
drawtype = "nodebox",
-- top, bottom, side1, side2, inner, outer
-- this one is from all sides - except from the underside - of the given material
tiles = {tiles[1], tiles[2], tiles[1], tiles[1], tiles[1], tiles[1]},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
},
is_ground_content = false,
})
minetest.register_craft({
output = "cottages:roof_" .. name .. " 6",
recipe = {
{"", "", material},
{"", material, ""},
{material, "", ""}
}
})
minetest.register_craft({
output = "cottages:roof_connector_" .. name,
recipe = {
{"cottages:roof_" .. name},
{ci.wood},
}
})
minetest.register_craft({
output = "cottages:roof_flat_" .. name .. " 2",
recipe = {
{"cottages:roof_" .. name, "cottages:roof_" .. name},
}
})
-- convert flat roofs back to normal roofs
minetest.register_craft({
output = "cottages:roof_" .. name,
recipe = {
{"cottages:roof_flat_" .. name, "cottages:roof_flat_" .. name}
}
})
end -- of cottages.register_roof( name, tiles, basic_material )

13
modules/roof/crafts.lua Normal file
View File

@ -0,0 +1,13 @@
local ci = cottages.craftitems
minetest.register_craft({
output = "cottages:reet",
recipe = {{ci.papyrus, ci.papyrus},
{ci.papyrus, ci.papyrus},
},
})
minetest.register_craft({
output = "cottages:slate_vertical",
recipe = {{ci.stone, ci.wood}}
})

5
modules/roof/init.lua Normal file
View File

@ -0,0 +1,5 @@
cottages.roof = {}
cottages.dofile("modules", "roof", "api")
cottages.dofile("modules", "roof", "nodes")
cottages.dofile("modules", "roof", "crafts")

86
modules/roof/nodes.lua Normal file
View File

@ -0,0 +1,86 @@
local S = cottages.S
local ci = cottages.craftitems
if cottages.settings.roof.use_farming_straw_stairs then
minetest.register_alias("cottages:roof_straw", "stairs:stair_straw")
minetest.register_alias("cottages:roof_connector_straw", "stairs:stair_straw")
minetest.register_alias("cottages:roof_flat_straw", "stairs:slab_straw")
else
cottages.roof.register_roof(
"straw",
"cottages:straw_mat",
{cottages.textures.straw, cottages.textures.straw,
cottages.textures.straw, cottages.textures.straw,
cottages.textures.straw, cottages.textures.straw}
)
end
cottages.roof.register_roof(
"reet",
ci.papyrus,
{"cottages_reet.png", "cottages_reet.png",
"cottages_reet.png", "cottages_reet.png",
"cottages_reet.png", "cottages_reet.png"}
)
cottages.roof.register_roof(
"wood",
ci.wood,
{cottages.textures.roof_wood, cottages.textures.roof_sides,
cottages.textures.roof_sides, cottages.textures.roof_sides,
cottages.textures.roof_sides, cottages.textures.roof_wood}
)
cottages.roof.register_roof(
"black",
ci.coal_lump,
{"cottages_homedecor_shingles_asphalt.png", cottages.textures.roof_sides,
cottages.textures.roof_sides, cottages.textures.roof_sides,
cottages.textures.roof_sides, "cottages_homedecor_shingles_asphalt.png"}
)
cottages.roof.register_roof(
"red",
ci.clay_brick,
{"cottages_homedecor_shingles_terracotta.png", cottages.textures.roof_sides,
cottages.textures.roof_sides, cottages.textures.roof_sides,
cottages.textures.roof_sides, "cottages_homedecor_shingles_terracotta.png"}
)
cottages.roof.register_roof(
"brown",
ci.dirt,
{"cottages_homedecor_shingles_wood.png", cottages.textures.roof_sides,
cottages.textures.roof_sides, cottages.textures.roof_sides,
cottages.textures.roof_sides, "cottages_homedecor_shingles_wood.png"}
)
cottages.roof.register_roof(
"slate",
ci.stone,
{"cottages_slate.png", cottages.textures.roof_sides,
"cottages_slate.png", "cottages_slate.png",
cottages.textures.roof_sides, "cottages_slate.png"}
)
--------
minetest.register_node("cottages:reet", {
description = S("Reed for thatching"),
tiles = {"cottages_reet.png"},
groups = {hay = 3, snappy = 3, choppy = 3, oddly_breakable_by_hand = 3, flammable = 3},
sounds = cottages.sounds.leaves,
is_ground_content = false,
})
minetest.register_node("cottages:slate_vertical", {
description = S("Vertical Slate"),
tiles = {"cottages_slate.png", cottages.textures.roof_sides,
"cottages_slate.png", "cottages_slate.png",
cottages.textures.roof_sides, "cottages_slate.png"},
paramtype2 = "facedir",
groups = {cracky = 2, stone = 1},
sounds = cottages.sounds.stone,
is_ground_content = false,
})