summaryrefslogtreecommitdiff
path: root/homedecor_common/nodeboxes.lua
diff options
context:
space:
mode:
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-04-24 18:59:36 -0400
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-04-24 18:59:36 -0400
commita5eef1c5de77fa7770877802e66c3e1c53f9a0da (patch)
tree0f36e64a58e5f5bb7d95be6ae692f58f2ebfe483 /homedecor_common/nodeboxes.lua
parentdda854cf06f90a04a03844e19c4d4ad220e38fe4 (diff)
downloaddreambuilder_modpack-a5eef1c5de77fa7770877802e66c3e1c53f9a0da.tar
dreambuilder_modpack-a5eef1c5de77fa7770877802e66c3e1c53f9a0da.tar.gz
dreambuilder_modpack-a5eef1c5de77fa7770877802e66c3e1c53f9a0da.tar.bz2
dreambuilder_modpack-a5eef1c5de77fa7770877802e66c3e1c53f9a0da.tar.xz
dreambuilder_modpack-a5eef1c5de77fa7770877802e66c3e1c53f9a0da.zip
update castles, areas, homedecor, plantlife,
gloopblocks, hotbar, inspector, maptools, mesecons, moreblocks, moreores, technic, teleport_request, and worldedit switched to caverealms_lite (with minor fixes by me) switched to CWz's fork of player_textures The homedecor update brings in the big split, and will require you to re-enable all modpack components in order to avoid loss of content.
Diffstat (limited to 'homedecor_common/nodeboxes.lua')
-rw-r--r--homedecor_common/nodeboxes.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/homedecor_common/nodeboxes.lua b/homedecor_common/nodeboxes.lua
new file mode 100644
index 0000000..c0a7df7
--- /dev/null
+++ b/homedecor_common/nodeboxes.lua
@@ -0,0 +1,59 @@
+-- please keep any non-generic nodeboxe with its node definition
+-- this file should not accumulate any left over nodeboxes
+-- but is meant to host any abstractions or calculations based on nodeboxes
+
+-- 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
+ -- a "negative" depth as a depth extending from the other side, i.e. +z
+ if depth > 0 then
+ -- slab starting from -z
+ return { -0.5, -0.5, -0.5, 0.5, 0.5, -0.5+depth }
+ else
+ -- slab starting from +z (z1=0.5-(-depth))
+ return { -0.5, -0.5, 0.5+depth, 0.5, 0.5, 0.5 }
+ end
+ end,
+ bar_y = function(radius) return {-radius, -0.5, -radius, radius, 0.5, radius} end,
+ cuboid = function(radius_x, radius_y, radius_z) return {-radius_x, -radius_y, -radius_z, radius_x, radius_y, radius_z} end,
+}
+
+homedecor.nodebox = {
+ -- { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
+ -- can be used in-place as:
+ -- { 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 = {}
+mt.__index = function(table, key)
+ local ref = homedecor.box[key]
+ local ref_type = type(ref)
+ if ref_type == "function" then
+ return function(...)
+ return { type = "fixed", fixed = ref(...) }
+ end
+ elseif ref_type == "table" then
+ return { type = "fixed", fixed = ref }
+ elseif ref_type == "nil" then
+ error(key .. "could not be found among nodebox presets and functions")
+ end
+ error("unexpected datatype " .. tostring(type(ref)) .. " while looking for " .. key)
+end
+setmetatable(homedecor.nodebox, mt)