Add automatic placement/orientation of double doors. Place a door, then

a second of the same kind to its right and the second becomes
right-facing.

Made all doors place the left-facing one by default (even if the one you
are placing says it is right-facing, e.g. for leftover inventory).

Hold 'sneak' (Shift) while you place any door to force it to ignore its
neighbors and become right-facing.

Got rid of obsolete left-/right-facing conversion crafts.
This commit is contained in:
Vanessa Ezekowitz 2013-10-27 23:44:56 -04:00
parent b483733540
commit 2a020c2c49
2 changed files with 24 additions and 163 deletions

View File

@ -1300,22 +1300,6 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_plain_bottom_left",
recipe = {
"homedecor:door_wood_plain_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_plain_bottom_right",
recipe = {
"homedecor:door_wood_plain_bottom_left"
},
})
-- fancy exterior
minetest.register_craft( {
@ -1327,23 +1311,6 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_exterior_fancy_bottom_left",
recipe = {
"homedecor:door_exterior_fancy_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_exterior_fancy_bottom_right",
recipe = {
"homedecor:door_exterior_fancy_bottom_left"
},
})
-- wood and glass (grid style)
-- bare
@ -1366,22 +1333,6 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_bottom_left",
recipe = {
"homedecor:door_wood_glass_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_bottom_right",
recipe = {
"homedecor:door_wood_glass_bottom_left"
},
})
-- mahogany
minetest.register_craft( {
@ -1395,17 +1346,6 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_mahogany_bottom_right 2",
recipe = {
"default:dirt",
"default:coal_lump",
"homedecor:door_wood_glass_bottom_right",
"homedecor:door_wood_glass_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_mahogany_bottom_left 2",
@ -1416,32 +1356,6 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_mahogany_bottom_right 2",
recipe = {
"group:dye,unicolor_dark_orange",
"homedecor:door_wood_glass_bottom_right",
"homedecor:door_wood_glass_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_mahogany_bottom_left",
recipe = {
"homedecor:door_wood_glass_mahogany_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_mahogany_bottom_right",
recipe = {
"homedecor:door_wood_glass_mahogany_bottom_left"
},
})
-- white
minetest.register_craft( {
@ -1454,32 +1368,6 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_white_bottom_right 2",
recipe = {
"group:dye,basecolor_white",
"homedecor:door_wood_glass_bottom_right",
"homedecor:door_wood_glass_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_white_bottom_left",
recipe = {
"homedecor:door_wood_glass_white_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_wood_glass_white_bottom_right",
recipe = {
"homedecor:door_wood_glass_white_bottom_left"
},
})
-- Solid glass with metal handle
minetest.register_craft( {
@ -1491,22 +1379,6 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_glass_bottom_left",
recipe = {
"homedecor:door_glass_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_glass_bottom_right",
recipe = {
"homedecor:door_glass_bottom_left"
},
})
-- Closet doors
-- oak
@ -1520,22 +1392,6 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_closet_oak_bottom_left",
recipe = {
"homedecor:door_closet_oak_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_closet_oak_bottom_right",
recipe = {
"homedecor:door_closet_oak_bottom_left"
},
})
-- mahogany
minetest.register_craft( {
@ -1559,19 +1415,3 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_closet_mahogany_bottom_left",
recipe = {
"homedecor:door_closet_mahogany_bottom_right"
},
})
minetest.register_craft( {
type = "shapeless",
output = "homedecor:door_closet_mahogany_bottom_right",
recipe = {
"homedecor:door_closet_mahogany_bottom_left"
},
})

View File

@ -231,6 +231,11 @@ for i in ipairs(sides) do
end
})
local dgroups = {snappy=3, not_in_creative_inventory=1}
if side == "left" then
dgroups = {snappy=3}
end
minetest.register_node("homedecor:door_"..doorname.."_bottom_"..side, {
description = doordesc.." "..S("(%s-opening)"):format(side),
drawtype = "nodebox",
@ -238,7 +243,7 @@ for i in ipairs(sides) do
inventory_image = "homedecor_door_"..doorname.."_"..side.."_inv.png",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=3},
groups = dgroups,
sounds = default.node_sound_wood_defaults(),
walkable = true,
use_texture_alpha = texalpha,
@ -253,7 +258,8 @@ for i in ipairs(sides) do
end
end,
on_place = function(itemstack, placer, pointed_thing)
homedecor.place_door(itemstack, placer, pointed_thing, doorname, side)
local keys=placer:get_player_control()
homedecor.place_door(itemstack, placer, pointed_thing, doorname, keys["sneak"])
return itemstack
end,
on_rightclick = function(pos, node, clicker)
@ -266,6 +272,7 @@ for i in ipairs(sides) do
on_punch = function(pos, node, puncher)
minetest.get_meta(pos):set_string('closed',nil)
end,
drop = "homedecor:door_"..doorname.."_bottom_left",
mesecons = {
effector = {
action_on = function(pos,node)
@ -414,7 +421,7 @@ local function get_nodedef_field(nodename, fieldname)
return minetest.registered_nodes[nodename][fieldname]
end
function homedecor.place_door(itemstack, placer, pointed_thing, name, side)
function homedecor.place_door(itemstack, placer, pointed_thing, name, forceright)
local pointed = pointed_thing.under
local pnode = minetest.get_node(pointed)
@ -445,6 +452,20 @@ function homedecor.place_door(itemstack, placer, pointed_thing, name, side)
minetest.chat_send_player( placer:get_player_name(), S('Not enough space above that spot to place a door!') )
else
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local p_tests = {
{x=pos1.x-1, y=pos1.y, z=pos1.z},
{x=pos1.x, y=pos1.y, z=pos1.z+1},
{x=pos1.x+1, y=pos1.y, z=pos1.z},
{x=pos1.x, y=pos1.y, z=pos1.z-1},
}
print("fdir="..fdir)
local testnode = minetest.get_node(p_tests[fdir+1])
local side = "left"
if string.find(testnode.name, "homedecor:door_"..name.."_bottom_left") or forceright then
side = "right"
end
local def = { name = "homedecor:door_"..name.."_bottom_"..side, param2=fdir}
addDoorNode(pos1, def, true)
minetest.add_node(pos2, { name = "homedecor:door_"..name.."_top_"..side, param2=fdir})