add banisters, placed on side of blocks

when placing, code will try to determine if the bannister should be
left- or right-sided.  Defaults to left-sided; hold shift while placing
to force right-sided.
This commit is contained in:
Vanessa Ezekowitz 2015-04-27 03:04:22 -04:00
parent c0bb7fc784
commit c8633be1dc
8 changed files with 445 additions and 2 deletions

View File

@ -3162,6 +3162,24 @@ minetest.register_craft({
},
})
for i in ipairs(homedecor.banister_materials) do
local name = homedecor.banister_materials[i][1]
local topmat = homedecor.banister_materials[i][5]
local vertmat = homedecor.banister_materials[i][6]
local dye1 = homedecor.banister_materials[i][7]
local dye2 = homedecor.banister_materials[i][8]
minetest.register_craft({
output = "homedecor:banister_"..name.."_left 2",
recipe = {
{ topmat, "", dye1 },
{ vertmat, topmat, "" },
{ dye2, vertmat, topmat }
},
})
end
if (minetest.get_modpath("technic") and minetest.get_modpath("dye") and minetest.get_modpath("bees")) then
technic.register_separating_recipe({ input = {"bees:wax 1"}, output = {"homedecor:oil_extract 2","dye:yellow 1"} })
end

View File

@ -197,3 +197,49 @@ function homedecor.unextend_bed(pos, color)
end
end
function homedecor.place_banister(itemstack, placer, pointed_thing)
local pos, def = select_node(pointed_thing)
if def.on_rightclick then
return def.on_rightclick(pointed_thing.under, minetest.get_node(pos), placer, itemstack)
end
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local abovepos = { x=pos.x, y=pos.y+1, z=pos.z }
local abovenode = minetest.get_node(abovepos)
local adef = minetest.registered_nodes[abovenode.name]
local placer_name = placer:get_player_name()
if not (adef and adef.buildable_to) then
minetest.chat_send_player(placer_name, "Not enough room - the upper space is occupied!" )
return
end
if minetest.is_protected(abovepos, placer_name) then
minetest.chat_send_player(placer_name, "Someone already owns that spot." )
return
end
local rxd = homedecor.fdir_to_right[fdir+1][1]
local rzd = homedecor.fdir_to_right[fdir+1][2]
local fxd = homedecor.fdir_to_fwd[fdir+1][1]
local fzd = homedecor.fdir_to_fwd[fdir+1][2]
local right_fwd_above_pos = { x=pos.x+rxd+fxd, y=pos.y+1, z=pos.z+rzd+fzd }
local right_fwd_above_node = minetest.get_node(right_fwd_above_pos)
local new_place_name = itemstack:get_name()
if placer:get_player_control()["sneak"]
or not is_buildable_to(placer_name, right_fwd_above_pos, nil, right_fwd_above_pos) then
new_place_name = string.gsub(new_place_name, "_left", "_right")
end
minetest.set_node(pos, {name = new_place_name, param2 = fdir})
itemstack:take_item()
return itemstack
end

View File

@ -138,8 +138,6 @@ dofile(homedecor.modpath.."/misc-electrical.lua")
dofile(homedecor.modpath.."/paintings.lua")
dofile(homedecor.modpath.."/window_treatments.lua")
dofile(homedecor.modpath.."/crafts.lua")
dofile(homedecor.modpath.."/furniture.lua")
dofile(homedecor.modpath.."/furniture_medieval.lua")
dofile(homedecor.modpath.."/furniture_recipes.lua")
@ -152,4 +150,6 @@ dofile(homedecor.modpath.."/trash_cans.lua")
dofile(homedecor.modpath.."/handlers/locked.lua")
dofile(homedecor.modpath.."/crafts.lua")
print("[HomeDecor] "..S("Loaded!"))

View File

@ -672,3 +672,76 @@ for _, i in ipairs(n) do
})
end
homedecor.banister_materials = {
{ "wood",
"wood",
"default_wood.png",
"default_wood.png",
"group:wood",
"group:stick",
"",
""
},
{ "white_dark",
"dark topped",
"homedecor_white_wood.png",
"homedecor_dark_wood.png",
"group:wood",
"group:stick",
"dye:brown",
"dye:white"
},
{ "brass",
"brass",
"homedecor_white_wood.png",
"homedecor_tile_brass2.png",
"technic:brass_ingot",
"group:stick",
"",
"dye:white"
},
{ "wrought_iron",
"wrought iron",
"homedecor_tile_wrought_iron2.png",
"homedecor_tile_wrought_iron2.png",
"homedecor:pole_wrought_iron",
"homedecor:pole_wrought_iron",
"",
""
}
}
for _, side in ipairs({"left", "right"}) do
for i in ipairs(homedecor.banister_materials) do
local name = homedecor.banister_materials[i][1]
local cbox = {
type = "fixed",
fixed = { -9/16, -3/16, 5/16, 9/16, 24/16, 8/16}
}
local onplace = nil
groups = { snappy = 3, not_in_creative_inventory = 1}
if side == "left" then
onplace = homedecor.place_banister
groups = { snappy = 3 }
end
homedecor.register("banister_"..name.."_"..side, {
description = S("banister ("..homedecor.banister_materials[i][2]..", "..side.." side)"),
mesh = "homedecor_banister_"..side..".obj",
tiles = {
homedecor.banister_materials[i][3],
homedecor.banister_materials[i][4]
},
groups = groups,
selection_box = cbox,
collision_box = cbox,
on_place = onplace,
drop = "homedecor:banister_"..name.."_left",
})
end
end

View File

@ -0,0 +1,153 @@
# Blender v2.73 (sub 0) OBJ File: 'bannister.blend'
# www.blender.org
o Cylinder
v 0.265203 0.250000 0.437499
v 0.202703 1.187500 0.437499
v 0.265203 1.250000 0.437499
v -0.297297 -0.187500 0.437499
v -0.234797 0.812500 0.437499
v 0.202703 0.250000 0.437499
v -0.047297 1.000000 0.499999
v 0.483953 1.468750 0.499999
v -0.578547 0.531250 0.499999
v 0.421453 1.531250 0.499999
v -0.516047 0.468750 0.499999
v 0.265203 0.250000 0.374999
v 0.202703 1.187500 0.374999
v 0.265203 1.250000 0.374999
v -0.297297 0.750000 0.437499
v -0.234797 -0.187500 0.437499
v 0.202703 0.250000 0.374999
v 0.483953 1.468750 0.312499
v -0.578547 0.531250 0.312499
v 0.421453 1.531250 0.312499
v -0.516047 0.468750 0.312499
v -0.234797 -0.187500 0.374999
v -0.297297 0.750000 0.374999
v -0.234797 0.812500 0.374999
v -0.297297 -0.187500 0.374999
v 0.265203 0.250000 0.499999
v -0.297297 -0.187500 0.499999
v 0.202703 0.250000 0.499999
v -0.234797 -0.187500 0.499999
v 0.265203 0.312500 0.437499
v -0.297297 -0.125000 0.437499
v 0.202703 0.312500 0.437499
v -0.234797 -0.125000 0.437499
v 0.265203 0.312500 0.499999
v -0.297297 -0.125000 0.499999
v 0.202703 0.312500 0.499999
v -0.234797 -0.125000 0.499999
vt 0.062500 0.812500
vt 0.062500 0.750000
vt 1.000000 0.750000
vt 0.937500 0.812500
vt 0.062500 0.937500
vt 0.937500 0.937500
vt 1.000000 1.000000
vt 0.062500 1.000000
vt 0.625000 0.375000
vt 0.625000 0.312500
vt 0.750000 0.312500
vt 0.750000 0.375000
vt 0.062500 0.875000
vt 1.000000 0.812500
vt 0.937500 0.875000
vt 1.000000 0.937500
vt 0.812500 0.375000
vt 0.812500 0.312500
vt 0.937500 0.312500
vt 0.937500 0.375000
vt 1.000000 0.062500
vt 0.062500 0.062500
vt 0.062500 0.000000
vt 1.000000 0.000000
vt 0.062500 0.625000
vt 0.937500 0.625000
vt 0.937500 0.687500
vt 0.062500 0.687500
vt 1.000000 0.250000
vt 0.062500 0.250000
vt 0.062500 0.187500
vt 1.000000 0.187500
vt 0.062500 0.437500
vt 0.937500 0.437500
vt 0.937500 0.500000
vt 0.062500 0.500000
vt 0.062500 0.375000
vt 0.125000 0.375000
vt 0.125000 0.437500
vt 0.125000 0.250000
vt 0.125000 0.312500
vt 0.062500 0.312500
vt 0.437500 0.375000
vt 0.375000 0.375000
vt 0.375000 0.312500
vt 0.437500 0.312500
vt 0.562500 0.375000
vt 0.500000 0.375000
vt 0.500000 0.312500
vt 0.562500 0.312500
vt 0.125000 0.062500
vt 0.125000 0.125000
vt 0.062500 0.125000
vt 0.062500 0.562500
vt 0.125000 0.562500
vt 0.125000 0.625000
vt 1.000000 0.125000
vt 0.000000 0.125000
vt 0.000000 0.062500
vt 0.000000 0.250000
vt 0.000000 0.187500
vt 0.187500 0.875000
vt 0.000000 0.875000
vt 0.000000 0.812500
vt 0.187500 0.812500
vt 0.250000 0.875000
vt 0.250000 0.812500
vt 0.437500 0.812500
vt 0.437500 0.875000
vt 1.000000 0.500000
vt 0.000000 0.500000
vt 0.000000 0.312500
vt 1.000000 0.312500
vt 0.000000 0.562500
vt 1.000000 0.562500
vt 0.000000 0.750000
vn -0.000000 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.707100 0.707100 0.000000
vn -0.707100 -0.707100 0.000000
vn 0.707100 -0.707100 0.000000
vn -0.707100 0.707100 0.000000
g Cylinder_Cylinder_verticals
s off
f 6/1/1 1/2/1 3/3/1 2/4/1
f 17/5/2 13/6/2 14/7/2 12/8/2
f 17/9/3 12/10/3 26/11/3 28/12/3
f 4/13/1 16/1/1 5/14/1 15/15/1
f 25/13/2 23/15/2 24/16/2 22/5/2
f 25/17/3 22/18/3 29/19/3 27/20/3
f 3/21/4 1/22/4 12/23/4 14/24/4
f 6/25/5 2/26/5 13/27/5 17/28/5
f 5/29/4 16/30/4 22/31/4 24/32/4
f 4/33/5 15/34/5 23/35/5 25/36/5
f 27/37/5 35/38/5 31/39/5 4/33/5
f 16/30/4 33/40/4 37/41/4 29/42/4
f 32/43/6 36/44/6 34/45/6 30/46/6
f 31/47/6 35/48/6 37/49/6 33/50/6
f 1/22/4 30/51/4 34/52/4 26/53/4
f 28/54/5 36/55/5 32/56/5 6/25/5
f 26/22/1 34/51/1 36/52/1 28/53/1
f 29/30/1 37/40/1 35/41/1 27/42/1
g Cylinder_Cylinder_top
f 10/57/1 9/58/1 11/59/1 8/21/1
f 20/32/2 18/29/2 21/60/2 19/61/2
f 10/62/7 8/63/7 18/64/7 20/65/7
f 9/66/8 19/67/8 21/68/8 11/69/8
f 8/70/9 11/71/9 21/72/9 18/73/9
f 9/74/10 10/75/10 20/3/10 19/76/10

View File

@ -0,0 +1,153 @@
# Blender v2.73 (sub 0) OBJ File: 'bannister_right.blend'
# www.blender.org
o Cylinder
v -0.265203 0.250000 0.437499
v -0.202703 1.187500 0.437499
v -0.265203 1.250000 0.437499
v 0.297297 -0.187500 0.437499
v 0.234797 0.812500 0.437499
v -0.202703 0.250000 0.437499
v 0.047297 1.000000 0.499999
v -0.483953 1.468750 0.499999
v 0.578547 0.531250 0.499999
v -0.421453 1.531250 0.499999
v 0.516047 0.468750 0.499999
v -0.265203 0.250000 0.374999
v -0.202703 1.187500 0.374999
v -0.265203 1.250000 0.374999
v 0.297297 0.750000 0.437499
v 0.234797 -0.187500 0.437499
v -0.202703 0.250000 0.374999
v -0.483953 1.468750 0.312499
v 0.578547 0.531250 0.312499
v -0.421453 1.531250 0.312499
v 0.516047 0.468750 0.312499
v 0.234797 -0.187500 0.374999
v 0.297297 0.750000 0.374999
v 0.234797 0.812500 0.374999
v 0.297297 -0.187500 0.374999
v -0.265203 0.250000 0.499999
v 0.297297 -0.187500 0.499999
v -0.202703 0.250000 0.499999
v 0.234797 -0.187500 0.499999
v -0.265203 0.312500 0.437499
v 0.297297 -0.125000 0.437499
v -0.202703 0.312500 0.437499
v 0.234797 -0.125000 0.437499
v -0.265203 0.312500 0.499999
v 0.297297 -0.125000 0.499999
v -0.202703 0.312500 0.499999
v 0.234797 -0.125000 0.499999
vt 0.062500 0.812500
vt 0.937500 0.812500
vt 1.000000 0.750000
vt 0.062500 0.750000
vt 0.062500 0.937500
vt 0.062500 1.000000
vt 1.000000 1.000000
vt 0.937500 0.937500
vt 0.625000 0.375000
vt 0.750000 0.375000
vt 0.750000 0.312500
vt 0.625000 0.312500
vt 0.062500 0.875000
vt 0.937500 0.875000
vt 1.000000 0.812500
vt 1.000000 0.937500
vt 0.812500 0.375000
vt 0.937500 0.375000
vt 0.937500 0.312500
vt 0.812500 0.312500
vt 1.000000 0.062500
vt 1.000000 0.000000
vt 0.062500 0.000000
vt 0.062500 0.062500
vt 0.062500 0.625000
vt 0.062500 0.687500
vt 0.937500 0.687500
vt 0.937500 0.625000
vt 1.000000 0.250000
vt 1.000000 0.187500
vt 0.062500 0.187500
vt 0.062500 0.250000
vt 0.062500 0.437500
vt 0.062500 0.500000
vt 0.937500 0.500000
vt 0.937500 0.437500
vt 0.062500 0.375000
vt 0.125000 0.437500
vt 0.125000 0.375000
vt 0.062500 0.312500
vt 0.125000 0.312500
vt 0.125000 0.250000
vt 0.437500 0.375000
vt 0.437500 0.312500
vt 0.375000 0.312500
vt 0.375000 0.375000
vt 0.562500 0.375000
vt 0.562500 0.312500
vt 0.500000 0.312500
vt 0.500000 0.375000
vt 0.062500 0.125000
vt 0.125000 0.125000
vt 0.125000 0.062500
vt 0.062500 0.562500
vt 0.125000 0.625000
vt 0.125000 0.562500
vt 1.000000 0.125000
vt 0.000000 0.062500
vt 0.000000 0.125000
vt 0.000000 0.187500
vt 0.000000 0.250000
vt 0.187500 0.875000
vt 0.187500 0.812500
vt 0.000000 0.812500
vt 0.000000 0.875000
vt 0.250000 0.875000
vt 0.437500 0.875000
vt 0.437500 0.812500
vt 0.250000 0.812500
vt 1.000000 0.500000
vt 1.000000 0.312500
vt 0.000000 0.312500
vt 0.000000 0.500000
vt 0.000000 0.562500
vt 0.000000 0.750000
vt 1.000000 0.562500
vn 0.000000 0.000000 1.000000
vn -0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 0.000000 1.000000 0.000000
vn -0.707100 0.707100 0.000000
vn 0.707100 -0.707100 0.000000
vn -0.707100 -0.707100 0.000000
vn 0.707100 0.707100 0.000000
g Cylinder_Cylinder_verticals
s off
f 6/1/1 2/2/1 3/3/1 1/4/1
f 17/5/2 12/6/2 14/7/2 13/8/2
f 17/9/3 28/10/3 26/11/3 12/12/3
f 4/13/1 15/14/1 5/15/1 16/1/1
f 25/13/2 22/5/2 24/16/2 23/14/2
f 25/17/3 27/18/3 29/19/3 22/20/3
f 3/21/4 14/22/4 12/23/4 1/24/4
f 6/25/5 17/26/5 13/27/5 2/28/5
f 5/29/4 24/30/4 22/31/4 16/32/4
f 4/33/5 25/34/5 23/35/5 15/36/5
f 27/37/5 4/33/5 31/38/5 35/39/5
f 16/32/4 29/40/4 37/41/4 33/42/4
f 32/43/6 30/44/6 34/45/6 36/46/6
f 31/47/6 33/48/6 37/49/6 35/50/6
f 1/24/4 26/51/4 34/52/4 30/53/4
f 28/54/5 6/25/5 32/55/5 36/56/5
f 26/24/1 28/51/1 36/52/1 34/53/1
f 29/32/1 27/40/1 35/41/1 37/42/1
g Cylinder_Cylinder_top
f 10/57/1 8/21/1 11/58/1 9/59/1
f 20/30/2 19/60/2 21/61/2 18/29/2
f 10/62/7 20/63/7 18/64/7 8/65/7
f 9/66/8 11/67/8 21/68/8 19/69/8
f 8/70/9 18/71/9 21/72/9 11/73/9
f 9/74/10 19/75/10 20/3/10 10/76/10

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B