1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-23 00:20:17 +01:00

introduce nodebox abstractions used by fences, like corner nodeboxes, and indirectly slab_x; update fences accordingly

This commit is contained in:
Tim 2015-08-19 15:32:19 +02:00
parent 7d087815c8
commit 91092d99be
2 changed files with 27 additions and 82 deletions

View File

@ -71,14 +71,8 @@ homedecor.register("fence_picket", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0.498, 0.5, 0.5, 0.498 }
},
selection_box = homedecor.nodebox.slab_z(-0.1),
node_box = homedecor.nodebox.slab_z(-0.002),
})
homedecor.register("fence_picket_corner", {
@ -93,20 +87,8 @@ homedecor.register("fence_picket_corner", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 },
{ -0.5, -0.5, -0.5, -0.4, 0.5, 0.4 }
}
},
node_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, 0.498, 0.5, 0.5, 0.5 },
{ -0.5, -0.5, -0.5, -0.498, 0.5, 0.5 }
}
},
selection_box = homedecor.nodebox.corner_xz(0.1, -0.1),
node_box = homedecor.nodebox.corner_xz(0.002, -0.002),
})
homedecor.register("fence_picket_white", {
@ -121,14 +103,8 @@ homedecor.register("fence_picket_white", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0.498, 0.5, 0.5, 0.498 }
},
selection_box = homedecor.nodebox.slab_z(-0.1),
node_box = homedecor.nodebox.slab_z(-0.002),
})
homedecor.register("fence_picket_corner_white", {
@ -143,20 +119,8 @@ homedecor.register("fence_picket_corner_white", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 },
{ -0.5, -0.5, -0.5, -0.4, 0.5, 0.4 }
}
},
node_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, 0.498, 0.5, 0.5, 0.5 },
{ -0.5, -0.5, -0.5, -0.498, 0.5, 0.5 }
}
},
selection_box = homedecor.nodebox.corner_xz(0.1, -0.1),
node_box = homedecor.nodebox.corner_xz(0.002, -0.002),
})
homedecor.register("fence_privacy", {
@ -171,10 +135,7 @@ homedecor.register("fence_privacy", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, 5/16, 0.5, 0.5, 8/16 }
},
selection_box = homedecor.nodebox.slab_z(-3/16),
node_box = {
type = "fixed",
fixed = {
@ -201,7 +162,7 @@ homedecor.register("fence_privacy_corner", {
selection_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, 5/16, 0.5, 0.5, 0.5 },
homedecor.box.slab_z(-3/16),
{ -0.5, -0.5, -0.5, -5/16, 0.5, 5/16 },
}
},
@ -226,10 +187,7 @@ homedecor.register("fence_barbed_wire", {
tiles = {"homedecor_fence_barbed_wire.png"},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0.375, 0.5, 0.5, 0.5 }
},
selection_box = homedecor.nodebox.slab_z(-0.125),
node_box = {
type = "fixed",
fixed = {
@ -247,13 +205,7 @@ homedecor.register("fence_barbed_wire_corner", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, 0.375, 0.5, 0.5, 0.5 },
{ -0.5, -0.5, -0.5, -0.375, 0.5, 0.375 }
}
},
selection_box = homedecor.nodebox.corner_xz(0.125, -0.125),
node_box = {
type = "fixed",
fixed = {
@ -279,10 +231,7 @@ homedecor.register("fence_chainlink", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0.375, 0.5, 0.5, 0.5 }
},
selection_box = homedecor.nodebox.slab_z(-0.125),
node_box = {
type = "fixed",
fixed = {
@ -307,13 +256,7 @@ homedecor.register("fence_chainlink_corner", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, 0.375, 0.5, 0.5, 0.5 },
{ -0.5, -0.5, -0.5, -0.375, 0.5, 0.375 }
}
},
selection_box = homedecor.nodebox.corner_xz(0.125, -0.125),
node_box = {
type = "fixed",
fixed = {
@ -342,10 +285,7 @@ homedecor.register("fence_wrought_iron_2", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0.42, 0.5, 0.5, 0.5 }
},
selection_box = homedecor.nodebox.slab_z(-0.08),
node_box = {
type = "fixed",
fixed = {
@ -372,13 +312,7 @@ homedecor.register("fence_wrought_iron_2_corner", {
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, 0.42, 0.5, 0.5, 0.5 },
{ -0.5, -0.5, -0.5, -0.42, 0.5, 0.5 }
}
},
selection_box = homedecor.nodebox.corner_xz(0.08, -0.08),
node_box = {
type = "fixed",
fixed = {

View File

@ -4,8 +4,11 @@
-- a box is defined as {x1, y1, z1, x2, y2, z2}
homedecor.box = {
-- slab starting from -x (after rotation: left)
slab_x = function(depth) return { -0.5, -0.5, -0.5, -0.5+depth, 0.5, 0.5 } end,
-- bottom slab (starting from -y) with height optionally shifted upwards
slab_y = function(height, shift) return { -0.5, -0.5+(shift or 0), -0.5, 0.5, -0.5+height+(shift or 0), 0.5 } end,
-- slab starting from -z (+z with negative depth)
slab_z = function(depth)
-- for consistency with the other functions here, we have to assume that a "z" slab starts from -z and extends by depth,
-- but since conventionally a lot of nodes place slabs against +z for player convenience, we define
@ -28,6 +31,14 @@ homedecor.nodebox = {
-- { type="regular" },
regular = { type="regular" },
null = { type = "fixed", fixed = { 0, 0, 0, 0, 0, 0 } },
corner_xz = function(depth_x, depth_z) return {
type="fixed",
fixed={
homedecor.box.slab_x(depth_x),
homedecor.box.slab_z(depth_z),
-- { -0.5, -0.5, -0.5, 0.5-depth, 0.5, -0.5+depth } -- slab_x without the overlap, but actually looks a bit worse
}
} end,
}
local mt = {}