Modified selection and collision box

Code modified to support additional materials.
This commit is contained in:
laza83 2018-11-29 20:14:13 +01:00 committed by GitHub
parent ee8103d004
commit 2d2e49810a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 600 additions and 37 deletions

View File

@ -5,42 +5,19 @@ Crown Mold, Baseboards, Columns and more To minetest
Licence - DWYWPL
If you want to add or remove a texture simply edit the table at the top of millwork.lua file.
If you want to add or remove a texture simply edit the materials.lua file.
Right now I have these textures: White, Sandstone, Desert Sand and Clay. The others are commented out.
Each texture has 28 nodes so careful that you don't add too many textures.
Each texture has 24 nodes so careful that you don't add too many textures.
local material = {--{Name for description}, {image without .png}, {item name}, {mod name}
{ "White", "crownmold_white","white","wool"},
-- { "Cobble", "default_cobble","cobble","default"},
{ "Sandstone", "default_sandstone","sandstone","default"},
-- { "Desert Stone", "default_desert_stone","desert_stone","default"},
-- { "Stone", "default_stone","stone","default"},
-- { "Tree", "default_tree","tree","default"},
{ "Desert Sand", "default_desert_sand","desert_sand","default"},
{ "Clay", "default_clay","clay","default"},
-- { "Dirt", "default_dirt","dirt","default"},
}
Newish API example:
API example:
```lua
mymillwork.register_all(
"default_stone",
"Stone",
"default_stone.png",
{cracky = 3,not_in_creative_inventory=1},
"default:stone"
mymillwork.register("default:stone",
"default_stone",
"Stone",
"default_stone.png",
{cracky=3, stone=1, not_in_creative_inventory=1},
)
```

View File

@ -2,11 +2,9 @@ Crown molding, columns and baseboards of different styles.
If you want to add or remove a texture simply edit the table at the top of millwork.lua file.
If you want to add or remove a texture simply edit the materials.lua file.
Right now I have these textures: White, Sandstone, Desert Sand and Clay. The others are commented out.
Each texture has 28 nodes so careful that you don't add too many textures.
Each texture has 24 nodes so careful that you don't add too many textures.

View File

@ -1,4 +1,4 @@
mymillwork = {}
dofile(minetest.get_modpath("mymillwork").."/millwork.lua")
dofile(minetest.get_modpath("mymillwork").."/machines.lua")
dofile(minetest.get_modpath("mymillwork").."/register.lua")
dofile(minetest.get_modpath("mymillwork").."/nodes.lua")
dofile(minetest.get_modpath("mymillwork").."/materials.lua")

195
materials.lua Normal file
View File

@ -0,0 +1,195 @@
local nici = 1
-- Default Materials
--default:stone
mymillwork.register("default:stone",
"default_stone",
"Stone",
"default_stone.png",
{cracky=3, stone=1, not_in_creative_inventory=nici}
)
--default:cobble
mymillwork.register("default:cobble",
"default_cobble",
"Cobblestone",
"default_cobble.png",
{cracky=3, stone=2, not_in_creative_inventory=nici}
)
--default:stonebrick
mymillwork.register("default:stonebrick",
"default_stone_brick",
"Stone Brick",
"default_stone_brick.png",
{cracky=2, stone=1, not_in_creative_inventory=nici}
)
--default:stone_block
--default:mossycobble
mymillwork.register("default:mossycobble",
"default_mossy_cobble",
"Mossy Cobble",
"default_mossycobble.png",
{cracky=3, stone=1, not_in_creative_inventory=nici}
)
--default:desert_stone
mymillwork.register("default:desert_stone",
"default_desert_stone",
"Desert Stone",
"default_desert_stone.png",
{cracky=3, stone=1, not_in_creative_inventory=nici}
)
--default:desert_cobble
--default:desert_stonebrick
--default:desert_stone_block
--default:sandstone
mymillwork.register("default:sandstone",
"default_sandstone",
"Sandstone",
"default_sandstone.png",
{crumbly=1, cracky = 3, not_in_creative_inventory=nici}
)
--default:sandstonebrick
--default:sandstone_block
--default:desert_sandstone
mymillwork.register("default:desert_sandstone",
"default_desert_sandstone",
"Desert Sandstone",
"default_desert_sandstone.png",
{crumbly=1, cracky = 3, not_in_creative_inventory=nici}
)
--default:desert_sandstone_brick
--default:desert_sandstone_block
--default:silver_sandstone
mymillwork.register("default:silver_sandstone",
"default_silver_sandstone",
"Silver Sandstone",
"default_silver_sandstone.png",
{crumbly=1, cracky = 3, not_in_creative_inventory=nici}
)
--default:silver_sandstone_brick
--default:silver_sandstone_block
--default:obsidian
mymillwork.register("default:obsidian",
"default_obsidian",
"Obsidian",
"default_obsidian.png",
{cracky=1, level=2, not_in_creative_inventory=nici}
)
--default:obsidianbrick
--default:obsidian_block
--default:clay
mymillwork.register("default:clay",
"default_clay",
"Clay",
"default_clay.png",
{crumbly=3, not_in_creative_inventory=nici}
)
--default:snow
--default:snowblock
--default:ice
--default:tree
--default:wood
mymillwork.register("default:wood",
"default_wood",
"Wood",
"default_wood.png",
{choppy=2, oddly_breakable_by_hand=2, flammable=2, wood=1, not_in_creative_inventory=nici}
)
--default:jungletree
--default:junglewood
mymillwork.register("default:junglewood",
"default_junglewood",
"Jungle Wood",
"default_junglewood.png",
{choppy=2, oddly_breakable_by_hand=2, flammable=2, wood=1, not_in_creative_inventory=nici}
)
--default:pine_tree
--default:pine_wood
mymillwork.register("default:pine_wood",
"default_pine_wood",
"Pine Wood",
"default_pine_wood.png",
{choppy=3, oddly_breakable_by_hand=2, flammable=3, wood=1, not_in_creative_inventory=nici}
)
--default:acacia_tree
--default:acacia_wood
mymillwork.register("default:acacia_wood",
"default_acacia_wood",
"Acacia Wood",
"default_acacia_wood.png",
{choppy=2, oddly_breakable_by_hand=2, flammable=2, wood=1, not_in_creative_inventory=nici}
)
--default:aspen_tree
--default:aspen_wood
mymillwork.register("default:aspen_wood",
"default_aspen_wood",
"Aspen Wood",
"default_aspen_wood.png",
{choppy=3, oddly_breakable_by_hand=2, flammable=3, wood=1, not_in_creative_inventory=nici}
)
--default:coalblock
mymillwork.register("default:coalblock",
"default_coal_block",
"Coal Block",
"default_coal_block.png",
{cracky=3, not_in_creative_inventory=nici}
)
--default:steelblock
--default:copperblock
--default:tinblock
--default:bronzeblock
--default:goldblock
--default:mese
--default:diamondblock
mymillwork.register("default:diamondblock",
"default_diamond_block",
"Diamond Block",
"default_diamond_block.png",
{cracky=1, level=3, not_in_creative_inventory=nici}
)
--default:glass
mymillwork.register("default:glass",
"default_glass",
"Glass",
"default_glass.png",
{cracky=3, oddly_breakable_by_hand=3, not_in_creative_inventory=nici}
)
--default:obsidian_glass
--default:brick
mymillwork.register("default:brick",
"default_brick",
"Brick",
"default_brick.png",
{cracky=3, not_in_creative_inventory=nici}
)

393
nodes.lua Normal file
View File

@ -0,0 +1,393 @@
mymillwork.registered = {}
mymillwork.nodes = {
{ suffix = "crownmould",
model = "mymillwork_mach1.obj",
mdesc = "Crown Mould",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.125, 0.5, -0.125, 0.375},
{-0.5, -0.375, 0.375, 0.5, 0.5, 0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.125, 0.5, -0.125, 0.375},
{-0.5, -0.375, 0.375, 0.5, 0.5, 0.5},
}
},
},
{ suffix = "crownmould_ic",
model = "mymillwork_mach2.obj",
mdesc = "Crown Mould IC",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.125, 0.375, -0.125, 0.375},
{0.125, -0.375, -0.5, 0.375, -0.125, 0.125},
{-0.5, -0.375, 0.375, 0.5, 0.5, 0.5},
{0.375, -0.375, -0.5, 0.5, 0.5, 0.375},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.125, 0.375, -0.125, 0.375},
{0.125, -0.375, -0.5, 0.375, -0.125, 0.125},
{-0.5, -0.375, 0.375, 0.5, 0.5, 0.5},
{0.375, -0.375, -0.5, 0.5, 0.5, 0.375},
}
},
},
{ suffix = "crownmould_oc",
model = "mymillwork_mach3.obj",
mdesc = "Crown Mould OC",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.125, -0.125, -0.125, 0.5},
{-0.5, -0.125, 0.375, -0.375, 0.5, 0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.125, -0.125, -0.125, 0.5},
{-0.5, -0.125, 0.375, -0.375, 0.5, 0.5},
}
},
},
{ suffix = "crownmould_beam",
model = "mymillwork_mach4.obj",
mdesc = "Crown Mould with Beam",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.125, 0.5, -0.125, 0.375},
{-0.25, -0.375, -0.5, 0.25, -0.1875, 0.125},
{-0.5, -0.375, 0.375, 0.5, 0.5, 0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.125, 0.5, -0.125, 0.375},
{-0.25, -0.375, -0.5, 0.25, -0.1875, 0.125},
{-0.5, -0.375, 0.375, 0.5, 0.5, 0.5},
}
},
},
{ suffix = "column",
model = "mymillwork_mach5.obj",
mdesc = "Column",
sbox = { type = "fixed",
fixed = {{-0.5,-0.5,-0.5,0.5,0.5,0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5,-0.5,-0.5,0.5,0.5,0.5},
}
},
},
{ suffix = "column_base",
model = "mymillwork_mach6.obj",
mdesc = "Column Base",
sbox = { type = "fixed",
fixed = {{-0.5,-0.5,-0.5,0.5,0.5,0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5,-0.5,-0.5,0.5,0.5,0.5},
}
},
},
{ suffix = "column_half",
model = "mymillwork_mach7.obj",
mdesc = "Half Column",
sbox = { type = "fixed",
fixed = {{-0.5,-0.5,0.0,0.5,0.5,0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5,-0.5,0.0,0.5,0.5,0.5},
}
},
},
{ suffix = "column_half_base",
model = "mymillwork_mach8.obj",
mdesc = "Half Column Base",
sbox = { type = "fixed",
fixed = {{-0.5,-0.5,0.0,0.5,0.5,0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5,-0.5,0.0,0.5,0.5,0.5},
}
},
},
{ suffix = "column_half_wbeam",
model = "mymillwork_mach9.obj",
mdesc = "Half Column Base With Beam",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.0, 0.5, 0.5, 0.5},
{-0.25, -0.375, -0.5, 0.25, -0.1875, 0.0},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
{-0.5, -0.375, 0.0, 0.5, 0.5, 0.5},
{-0.25, -0.375, -0.5, 0.25, -0.1875, 0.0},
}
},
},
{ suffix = "column_quarter",
model = "mymillwork_mach10.obj",
mdesc = "Quarter Column",
sbox = { type = "fixed",
fixed = {{-0.5,-0.5,0,0,0.5,0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5,-0.5,0,0,0.5,0.5},
}
},
},
{ suffix = "column_quarter_base",
model = "mymillwork_mach11.obj",
mdesc = "Quarter Column Base",
sbox = { type = "fixed",
fixed = {{-0.5,-0.5,0,0,0.5,0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5,-0.5,0,0,0.5,0.5},
}
},
},
{ suffix = "column_quarter_wbase",
model = "mymillwork_mach12.obj",
mdesc = "Quarter Column Base Baseboard",
sbox = { type = "fixed",
fixed = {{-0.5,-0.5,0,0,0.5,0.5},
{0.0, -0.5, 0.4375, 0.5, -0.1875, 0.5},
{-0.5, -0.5, -0.5, -0.4375, -0.1875, 0.0},
}
},
cbox = { type = "fixed",
fixed = {{-0.5,-0.5,0,0,0.5,0.5},
{0.0, -0.5, 0.4375, 0.5, -0.1875, 0.5},
{-0.5, -0.5, -0.5, -0.4375, -0.1875, 0.0},
}
},
},
{ suffix = "column_quarter_fancybase",
model = "mymillwork_mach13.obj",
mdesc = "Quarter Column Base Fancy Baseboard",
sbox = { type = "fixed",
fixed = {{-0.5,-0.5,0,0,0.5,0.5},
{0.0, -0.5, 0.3125, 0.5, 0.1875, 0.5},
{-0.5, -0.5, -0.5, -0.3125, 0.1875, 0.0},
}
},
cbox = { type = "fixed",
fixed = {{-0.5,-0.5,0,0,0.5,0.5},
{0.0, -0.5, 0.3125, 0.5, 0.1875, 0.5},
{-0.5, -0.5, -0.5, -0.3125, 0.1875, 0.0},
}
},
},
{ suffix = "ceiling",
model = "mymillwork_mach14.obj",
mdesc = "Ceiling",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
}
},
},
{ suffix = "ceiling_post",
model = "mymillwork_mach15.obj",
mdesc = "Ceiling with Post",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
{-0.125, -0.4375, -0.125, 0.125, 0.5, 0.125},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
{-0.125, -0.4375, -0.125, 0.125, 0.5, 0.125},
}
},
},
{ suffix = "beam",
model = "mymillwork_mach16.obj",
mdesc = "Beam",
sbox = { type = "fixed",
fixed = {{-0.25, -0.5, -0.5, 0.25, -0.1875, 0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.25, -0.5, -0.5, 0.25, -0.1875, 0.5},
}
},
},
{ suffix = "beam_t",
model = "mymillwork_mach17.obj",
mdesc = "Beam T",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.25, -0.25, -0.1875, 0.25},
{-0.25, -0.5, -0.5, 0.25, -0.1875, 0.5},
{0.25, -0.5, -0.25, 0.5, -0.1875, 0.25},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.25, -0.25, -0.1875, 0.25},
{-0.25, -0.5, -0.5, 0.25, -0.1875, 0.5},
{0.25, -0.5, -0.25, 0.5, -0.1875, 0.25},
}
},
},
{ suffix = "beam_ceiling_t",
model = "mymillwork_mach18.obj",
mdesc = "Ceiling with Beam T",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
{-0.5, -0.4375, -0.25, -0.25, -0.1875, 0.25},
{-0.25, -0.4375, -0.5, 0.25, -0.1875, 0.5},
{0.25, -0.4375, -0.25, 0.5, -0.1875, 0.25},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
{-0.5, -0.4375, -0.25, -0.25, -0.1875, 0.25},
{-0.25, -0.4375, -0.5, 0.25, -0.1875, 0.5},
{0.25, -0.4375, -0.25, 0.5, -0.1875, 0.25},
}
},
},
{ suffix = "base",
model = "mymillwork_mach19.obj",
mdesc = "Baseboard",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, 0.4375, 0.5, -0.1875, 0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, 0.4375, 0.5, -0.1875, 0.5},
}
},
},
{ suffix = "base_ic",
model = "mymillwork_mach20.obj",
mdesc = "Baseboard IC",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, 0.4375, 0.5, -0.1875, 0.5},
{-0.5, -0.5, -0.5, -0.4375, -0.1875, 0.4375},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, 0.4375, 0.5, -0.1875, 0.5},
}
},
},
{ suffix = "base_oc",
model = "mymillwork_mach21.obj",
mdesc = "Baseboard OC",
sbox = { type = "fixed",
fixed = {{0.4375, -0.5, 0.4375, 0.5, -0.1875, 0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, 0.4375, 0.5, -0.1875, 0.5},
}
},
},
{ suffix = "base_fancy",
model = "mymillwork_mach22.obj",
mdesc = "Fancy Baseboard",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, 0.3125, 0.5, 0.1875, 0.5},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, 0.3125, 0.5, 0.1875, 0.5},
}
},
},
{ suffix = "base_fancy_ic",
model = "mymillwork_mach23.obj",
mdesc = "Fancy Baseboard IC",
sbox = { type = "fixed",
fixed = {{-0.5, -0.5, 0.3125, 0.5, 0.1875, 0.5},
{-0.5, -0.5, -0.5, -0.3125, 0.1875, 0.3125},
}
},
cbox = { type = "fixed",
fixed = {{-0.5, -0.5, 0.3125, 0.5, 0.1875, 0.5},
{-0.5, -0.5, -0.5, -0.3125, 0.1875, 0.3125},
}
},
},
{ suffix = "base_fancy_oc",
model = "mymillwork_mach24.obj",
mdesc = "Fancy Baseboard OC",
sbox = { type = "fixed",
fixed = {{0.3125, -0.5, 0.3125, 0.5, 0.1875, 0.5},
}
},
cbox = { type = "fixed",
fixed = {{0.3125, -0.5, 0.3125, 0.5, 0.1875, 0.5},
}
},
},
}
function mymillwork.register(material, node_suffix, desc, image, group)
for __, data in ipairs(mymillwork.nodes) do
mymillwork.register_all(data.suffix, data.model, data.mdesc, data.sbox, data.cbox,
node_suffix, material, desc, image, group)
end
end
function mymillwork.register_all(suffix, model, mdesc, sbox, cbox, node_suffix, material, desc, image, group)
minetest.register_node("mymillwork:" .. suffix .. "_" .. node_suffix, {
description = desc .. " " .. mdesc,
drawtype = "mesh",
mesh = model,
tiles = { image },
selection_box = sbox,
collision_box = cbox,
paramtype = "light",
paramtype2 = "facedir",
groups = group,
on_place = minetest.rotate_node,
})
table.insert(mymillwork.registered, {material, node_suffix})
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 270 KiB