summaryrefslogtreecommitdiff
path: root/lua/api.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/api.lua
parentf1156cc1da2f61d3996878213d5a3b358ce7ec57 (diff)
Add 1x2 drawers, Add crafting recipes for 1x2 and 2x2
Diffstat (limited to 'lua/api.lua')
-rwxr-xr-xlua/api.lua37
1 files changed, 35 insertions, 2 deletions
diff --git a/lua/api.lua b/lua/api.lua
index ba0550c..6c9df78 100755
--- a/lua/api.lua
+++ b/lua/api.lua
@@ -68,6 +68,11 @@ end
-- destruct drawer
function drawers.drawer_on_destruct(pos)
drawers.remove_visuals(pos)
+
+ -- clean up visual cache
+ if drawers.drawer_visuals[core.serialize(pos)] then
+ drawers.drawer_visuals[core.serialize(pos)] = nil
+ end
end
-- drop all items
@@ -157,28 +162,56 @@ function drawers.register_drawer(name, def)
def1.description = def.description .. " Drawer"
def1.tiles = def.tiles or def.tiles1
def1.tiles1 = nil
+ def1.tiles2 = nil
def1.tiles4 = nil
def1.groups.drawer = 1
core.register_node(name .. "1", def1)
core.register_alias(name, name .. "1") -- 1x1 drawer is the default one
+ -- 1x2 = 2
+ def2 = table.copy(def)
+ def2.description = def.description .. " Drawers (1x2)"
+ def2.tiles = def.tiles2
+ def2.tiles1 = nil
+ def2.tiles2 = nil
+ def2.tiles4 = nil
+ def2.groups.drawer = 2
+ core.register_node(name .. "2", def2)
+
-- 2x2 = 4
def4 = table.copy(def)
def4.description = def.description .. " Drawers (2x2)"
def4.tiles = def.tiles4
def4.tiles1 = nil
+ def4.tiles2 = nil
def4.tiles4 = nil
def4.groups.drawer = 4
core.register_node(name .. "4", def4)
if (not def.no_craft) and def.material then
core.register_craft({
- output = name,
+ output = name .. "1",
recipe = {
{def.material, def.material, def.material},
- {"", drawers.CHEST_ITEMSTRING, ""},
+ { "", drawers.CHEST_ITEMSTRING, "" },
{def.material, def.material, def.material}
}
})
+ core.register_craft({
+ output = name .. "2 2",
+ recipe = {
+ {def.material, drawers.CHEST_ITEMSTRING, def.material},
+ {def.material, def.material, def.material},
+ {def.material, drawers.CHEST_ITEMSTRING, def.material}
+ }
+ })
+ core.register_craft({
+ output = name .. "4 4",
+ recipe = {
+ {drawers.CHEST_ITEMSTRING, def.material, drawers.CHEST_ITEMSTRING},
+ { def.material, def.material, def.material },
+ {drawers.CHEST_ITEMSTRING, def.material, drawers.CHEST_ITEMSTRING}
+ }
+ })
end
end