mirror of
https://github.com/minetest-mods/drawers.git
synced 2024-11-09 16:33:44 +01:00
Add 1x2 drawers, Add crafting recipes for 1x2 and 2x2
This commit is contained in:
parent
f1156cc1da
commit
dd97f22586
@ -33,6 +33,7 @@ License of media:
|
|||||||
Copyright (C) 2014 Justin Aquadro (MIT):
|
Copyright (C) 2014 Justin Aquadro (MIT):
|
||||||
textures/drawers_wood.png
|
textures/drawers_wood.png
|
||||||
textures/drawers_wood_front_1.png
|
textures/drawers_wood_front_1.png
|
||||||
|
textures/drawers_wood_front_2.png
|
||||||
textures/drawers_wood_front_4.png
|
textures/drawers_wood_front_4.png
|
||||||
|
|
||||||
Everything not listed in here:
|
Everything not listed in here:
|
||||||
|
2
init.lua
2
init.lua
@ -61,6 +61,8 @@ drawers.register_drawer("drawers:wood", {
|
|||||||
description = "Wooden",
|
description = "Wooden",
|
||||||
tiles1 = {"drawers_wood.png", "drawers_wood.png", "drawers_wood.png",
|
tiles1 = {"drawers_wood.png", "drawers_wood.png", "drawers_wood.png",
|
||||||
"drawers_wood.png", "drawers_wood.png", "drawers_wood_front_1.png"},
|
"drawers_wood.png", "drawers_wood.png", "drawers_wood_front_1.png"},
|
||||||
|
tiles2 = {"drawers_wood.png", "drawers_wood.png", "drawers_wood.png",
|
||||||
|
"drawers_wood.png", "drawers_wood.png", "drawers_wood_front_2.png"},
|
||||||
tiles4 = {"drawers_wood.png", "drawers_wood.png", "drawers_wood.png",
|
tiles4 = {"drawers_wood.png", "drawers_wood.png", "drawers_wood.png",
|
||||||
"drawers_wood.png", "drawers_wood.png", "drawers_wood_front_4.png"},
|
"drawers_wood.png", "drawers_wood.png", "drawers_wood_front_4.png"},
|
||||||
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
groups = {choppy = 3, oddly_breakable_by_hand = 2},
|
||||||
|
37
lua/api.lua
37
lua/api.lua
@ -68,6 +68,11 @@ end
|
|||||||
-- destruct drawer
|
-- destruct drawer
|
||||||
function drawers.drawer_on_destruct(pos)
|
function drawers.drawer_on_destruct(pos)
|
||||||
drawers.remove_visuals(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
|
end
|
||||||
|
|
||||||
-- drop all items
|
-- drop all items
|
||||||
@ -157,28 +162,56 @@ function drawers.register_drawer(name, def)
|
|||||||
def1.description = def.description .. " Drawer"
|
def1.description = def.description .. " Drawer"
|
||||||
def1.tiles = def.tiles or def.tiles1
|
def1.tiles = def.tiles or def.tiles1
|
||||||
def1.tiles1 = nil
|
def1.tiles1 = nil
|
||||||
|
def1.tiles2 = nil
|
||||||
def1.tiles4 = nil
|
def1.tiles4 = nil
|
||||||
def1.groups.drawer = 1
|
def1.groups.drawer = 1
|
||||||
core.register_node(name .. "1", def1)
|
core.register_node(name .. "1", def1)
|
||||||
core.register_alias(name, name .. "1") -- 1x1 drawer is the default one
|
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
|
-- 2x2 = 4
|
||||||
def4 = table.copy(def)
|
def4 = table.copy(def)
|
||||||
def4.description = def.description .. " Drawers (2x2)"
|
def4.description = def.description .. " Drawers (2x2)"
|
||||||
def4.tiles = def.tiles4
|
def4.tiles = def.tiles4
|
||||||
def4.tiles1 = nil
|
def4.tiles1 = nil
|
||||||
|
def4.tiles2 = nil
|
||||||
def4.tiles4 = nil
|
def4.tiles4 = nil
|
||||||
def4.groups.drawer = 4
|
def4.groups.drawer = 4
|
||||||
core.register_node(name .. "4", def4)
|
core.register_node(name .. "4", def4)
|
||||||
|
|
||||||
if (not def.no_craft) and def.material then
|
if (not def.no_craft) and def.material then
|
||||||
core.register_craft({
|
core.register_craft({
|
||||||
output = name,
|
output = name .. "1",
|
||||||
recipe = {
|
recipe = {
|
||||||
{def.material, def.material, def.material},
|
{def.material, def.material, def.material},
|
||||||
{"", drawers.CHEST_ITEMSTRING, ""},
|
{ "", drawers.CHEST_ITEMSTRING, "" },
|
||||||
{def.material, def.material, def.material}
|
{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
|
||||||
end
|
end
|
||||||
|
@ -90,6 +90,36 @@ function drawers.spawn_visuals(pos)
|
|||||||
if bdir.x > 0 then obj:setyaw(1.5 * math.pi) end
|
if bdir.x > 0 then obj:setyaw(1.5 * math.pi) end
|
||||||
|
|
||||||
drawers.last_texture = nil
|
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
|
else -- 2x2 drawer
|
||||||
local bdir = core.facedir_to_dir(node.param2)
|
local bdir = core.facedir_to_dir(node.param2)
|
||||||
|
|
||||||
|
@ -85,16 +85,26 @@ core.register_entity("drawers:visual", {
|
|||||||
local node = core.get_node(self.drawer_pos)
|
local node = core.get_node(self.drawer_pos)
|
||||||
|
|
||||||
-- collisionbox
|
-- collisionbox
|
||||||
local colbox = {-0.4374, -0.4374, 0, 0.4374, 0.4374, 0} -- for param2 = 0 or 2
|
local colbox
|
||||||
|
if self.drawerType ~= 2 then
|
||||||
if node.param2 == 1 or node.param2 == 3 then
|
if node.param2 == 1 or node.param2 == 3 then
|
||||||
colbox = {0, -0.4374, -0.4374, 0, 0.4374, 0.4374}
|
colbox = {0, -0.4374, -0.4374, 0, 0.4374, 0.4374}
|
||||||
|
else
|
||||||
|
colbox = {-0.4374, -0.4374, 0, 0.4374, 0.4374, 0} -- for param2 = 0 or 2
|
||||||
end
|
end
|
||||||
-- only half the size if it's a small drawer
|
-- only half the size if it's a small drawer
|
||||||
if self.drawerType >= 2 then
|
if self.drawerType > 1 then
|
||||||
for i,j in pairs(colbox) do
|
for i,j in pairs(colbox) do
|
||||||
colbox[i] = j * 0.5
|
colbox[i] = j * 0.5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if node.param2 == 1 or node.param2 == 3 then
|
||||||
|
colbox = {0, -0.2187, -0.4374, 0, 0.2187, 0.4374}
|
||||||
|
else
|
||||||
|
colbox = {-0.4374, -0.2187, 0, 0.4374, 0.2187, 0} -- for param2 = 0 or 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- visual size
|
-- visual size
|
||||||
local visual_size = {x = 0.6, y = 0.6}
|
local visual_size = {x = 0.6, y = 0.6}
|
||||||
|
BIN
textures/drawers_wood_front_2.png
Normal file
BIN
textures/drawers_wood_front_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 245 B |
Loading…
Reference in New Issue
Block a user