Skip to content

Commit

Permalink
add furniture
Browse files Browse the repository at this point in the history
  • Loading branch information
wsor4035 committed Jul 28, 2024
1 parent 2ad7061 commit 7f45da4
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 5 deletions.
2 changes: 2 additions & 0 deletions mods/fl_furniture/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
wsor(aka wsor4035): code
Thomas-S: nodeboxes(MIT)
54 changes: 54 additions & 0 deletions mods/fl_furniture/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
local furnitures = {
chair = {
{ -0.3, -0.5, 0.2, -0.2, 0.5, 0.3 }, -- foot 1
{ 0.2, -0.5, 0.2, 0.3, 0.5, 0.3 }, -- foot 2
{ 0.2, -0.5, -0.3, 0.3, -0.1, -0.2 }, -- foot 3
{ -0.3, -0.5, -0.3, -0.2, -0.1, -0.2 }, -- foot 4
{ -0.3, -0.1, -0.3, 0.3, 0, 0.2 }, -- seating
{ -0.2, 0.1, 0.25, 0.2, 0.4, 0.26 } -- conector 1-2
},
table = {
{ -0.4, -0.5, -0.4, -0.3, 0.4, -0.3 }, -- foot 1
{ 0.3, -0.5, -0.4, 0.4, 0.4, -0.3 }, -- foot 2
{ -0.4, -0.5, 0.3, -0.3, 0.4, 0.4 }, -- foot 3
{ 0.3, -0.5, 0.3, 0.4, 0.4, 0.4 }, -- foot 4
{ -0.5, 0.4, -0.5, 0.5, 0.5, 0.5 } -- table top
},
bench = {
{ -0.5, -0.1, 0, 0.5, 0, 0.5 }, -- seating
{ -0.4, -0.5, 0, -0.3, -0.1, 0.5 }, -- foot 1
{ 0.3, -0.5, 0, 0.4, -0.1, 0.5 } -- foot 2
}
}

for name, nodebox in pairs(furnitures) do
for _, wood_type in pairs(fl_trees.types) do
minetest.register_node("fl_furniture:" .. wood_type .. "_" .. name, {
description = wood_type .. " " .. name,
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
tiles = {
{
name = "farlands_" .. wood_type .. "_planks.png",
align_style = "world",
}
},
node_box = {
type = "fixed",
fixed = nodebox
},
groups = {dig_tree = 1, oddly_breakable_by_hand = 2},
sounds = fl_trees.sounds.wood()
})
end

if minetest.get_modpath("i3") then
local wood_types = table.copy(fl_trees.types)
wood_types[#wood_types] = nil
i3.compress("fl_furniture:apple_" .. name, {
replace = "apple",
by = wood_types
})
end
end
3 changes: 3 additions & 0 deletions mods/fl_furniture/mod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = fl_furniture
depends = fl_trees
optional_depends = i3
2 changes: 2 additions & 0 deletions mods/fl_trees/init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
fl_trees = {}

fl_trees.types = {"acacia", "aspen", "pine", "spruce", "yellow_ipe", "willow", "baobab", "palm", "jungletree", "apple"}

local modpath = minetest.get_modpath("fl_trees")

dofile(modpath .. "/sounds.lua")
Expand Down
9 changes: 4 additions & 5 deletions mods/fl_trees/nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,18 @@ minetest.register_node("fl_trees:dead_aspen_leaves", {
groups = {dig_tree = 3, tree = 1, leaf = 1},
})

local wtypes = {"acacia", "aspen", "pine", "spruce", "yellow_ipe", "willow", "baobab", "palm", "jungletree", "apple"}

for _, wood in pairs(wtypes) do
for _, wood in pairs(fl_trees.types) do
tree_nodes(wood)
end

if minetest.get_modpath("i3") then
local types = {"plank", "trunk", "leaves"}
wtypes[#wtypes] = nil
local wood_types = table.copy(fl_trees.types)
wood_types[#wood_types] = nil
for _, type in pairs(types) do
i3.compress("fl_trees:apple_" .. type, {
replace = "apple",
by = wtypes
by = wood_types
})
end
end

0 comments on commit 7f45da4

Please sign in to comment.