add computer desk

This commit is contained in:
Vanessa Ezekowitz 2014-06-29 09:06:26 -04:00
parent 328ceacd25
commit f8efeee4d7
13 changed files with 107 additions and 0 deletions

View File

@ -489,3 +489,110 @@ minetest.register_node('homedecor:utility_table_legs', {
},
})
local function get_nodedef_field(nodename, fieldname)
if not minetest.registered_nodes[nodename] then
return nil
end
return minetest.registered_nodes[nodename][fieldname]
end
local fdir_to_right = {
{ 1, 0 },
{ 0, -1 },
{ -1, 0 },
{ 0, 1 },
}
minetest.register_node("homedecor:desk", {
drawtype = "nodebox",
description = "Desk",
tiles = {
"homedecor_desk_top_l.png",
"homedecor_desk_bottom_l.png",
"homedecor_desk_rside_l.png",
"homedecor_desk_lside_l.png",
"homedecor_desk_back_l.png",
"homedecor_desk_front_l.png"
},
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.4375, 0.375, 0.5, 0.5},
{-0.5, 0.4375, -0.4375, 0.5, 0.5, 0.5},
{-0.4375, -0.4375, -0.5, 0.3125, -0.0625, -0.4375},
{-0.4375, 0, -0.5, 0.3125, 0.375, 0.5},
{0.3125, -0.375, 0.4375, 0.5, 0.25, 0.5},
}
},
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 1.5, 0.5, 0.5 }
},
groups = { snappy = 3 },
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.under
local pnode = minetest.get_node(pointed_thing.under)
local rnodedef = minetest.registered_nodes[pnode.name]
if not rnodedef["buildable_to"] then
pos = pointed_thing.above
end
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local pos2 = { x = pos.x + fdir_to_right[fdir+1][1], y=pos.y, z = pos.z + fdir_to_right[fdir+1][2] }
local tnode = minetest.get_node(pos)
local tnode2 = minetest.get_node(pos2)
if get_nodedef_field(tnode.name, "buildable_to")
and get_nodedef_field(tnode2.name, "buildable_to")
and not minetest.is_protected(pos, placer:get_player_name())
and not minetest.is_protected(pos2, placer:get_player_name()) then
minetest.add_node(pos, { name = "homedecor:desk", param2 = fdir })
minetest.add_node(pos2, { name = "homedecor:desk_r", param2 = fdir })
if not homedecor.expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local fdir = oldnode.param2
local pos2 = { x = pos.x + fdir_to_right[fdir+1][1], y=pos.y, z = pos.z + fdir_to_right[fdir+1][2] }
if minetest.get_node(pos2).name == "homedecor:desk_r" then
minetest.remove_node(pos2)
end
end
})
minetest.register_node("homedecor:desk_r", {
drawtype = "nodebox",
tiles = {
"homedecor_desk_top_r.png",
"homedecor_desk_bottom_r.png",
"homedecor_desk_rside_r.png",
"homedecor_desk_lside_r.png",
"homedecor_desk_back_r.png",
"homedecor_desk_front_r.png"
},
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.5, 0.4375, -0.4375, 0.5, 0.5, 0.5},
{0.375, -0.5, -0.4375, 0.5, 0.5, 0.5},
{-0.5, 0.3125, -0.4375, 0.5, 0.375, 0.5},
{-0.5, 0.3125, -0.4375, -0.4375, 0.5, 0.5},
{-0.5, -0.375, 0.4375, 0.4375, 0.25, 0.5},
}
},
selection_box = {
type = "fixed",
fixed = { 0,0,0,0,0,0 }
},
groups = { snappy = 3, not_in_creative_inventory=1 }
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B