summaryrefslogtreecommitdiff
path: root/lua/helpers.lua
diff options
context:
space:
mode:
authorLNJ <git@lnj.li>2017-04-05 14:52:34 +0200
committerLNJ <git@lnj.li>2017-04-05 14:53:17 +0200
commitdd97f22586580b5aa4e383cb900bb42414fd1497 (patch)
tree6c71d0094bdfd226f822972e8ba0f592e1a5bc71 /lua/helpers.lua
parentf1156cc1da2f61d3996878213d5a3b358ce7ec57 (diff)
Add 1x2 drawers, Add crafting recipes for 1x2 and 2x2
Diffstat (limited to 'lua/helpers.lua')
-rwxr-xr-xlua/helpers.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/lua/helpers.lua b/lua/helpers.lua
index 374cd95..b94b0a8 100755
--- a/lua/helpers.lua
+++ b/lua/helpers.lua
@@ -90,6 +90,36 @@ function drawers.spawn_visuals(pos)
if bdir.x > 0 then obj:setyaw(1.5 * math.pi) end
drawers.last_texture = nil
+ elseif drawerType == 2 then
+ local bdir = core.facedir_to_dir(node.param2)
+
+ local fdir1
+ local fdir2
+ if node.param2 == 2 or node.param2 == 0 then
+ fdir1 = vector.new(-bdir.x, 0.5, -bdir.z)
+ fdir2 = vector.new(-bdir.x, -0.5, -bdir.z)
+ else
+ fdir1 = vector.new(-bdir.x, 0.5, -bdir.z)
+ fdir2 = vector.new(-bdir.x, -0.5, -bdir.z)
+ end
+
+ objs = {}
+
+ drawers.last_visual_id = 1
+ drawers.last_texture = drawers.get_inv_image(core.get_meta(pos):get_string("name1"))
+ local pos1 = vector.add(pos, vector.multiply(fdir1, 0.438))
+ objs[1] = core.add_entity(pos1, "drawers:visual")
+
+ drawers.last_visual_id = 2
+ drawers.last_texture = drawers.get_inv_image(core.get_meta(pos):get_string("name2"))
+ local pos2 = vector.add(pos, vector.multiply(fdir2, 0.438))
+ objs[2] = core.add_entity(pos2, "drawers:visual")
+
+ for i,obj in pairs(objs) do
+ if bdir.x < 0 then obj:setyaw(0.5 * math.pi) end
+ if bdir.z < 0 then obj:setyaw(math.pi) end
+ if bdir.x > 0 then obj:setyaw(1.5 * math.pi) end
+ end
else -- 2x2 drawer
local bdir = core.facedir_to_dir(node.param2)