0
0
Fork 0

Place trapdoors upside-down when placed at top

This commit is contained in:
Wuzzy 2017-06-05 21:26:11 +02:00
parent dfe03efd1b
commit 07d36c9ded
1 changed files with 26 additions and 0 deletions

View File

@ -664,6 +664,32 @@ function mcl_doors:register_trapdoor(name, def)
punch(pos) punch(pos)
end), end),
}}, }},
on_place = function(itemstack, placer, pointed_thing)
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local param2 = 0
local placer_pos = placer:getpos()
if placer_pos then
param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos))
end
local finepos = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
local fpos = finepos.y % 1
local origname = itemstack:get_name()
if p0.y - 1 == p1.y or (fpos > 0 and fpos < 0.5)
or (fpos < -0.5 and fpos > -0.999999999) then
param2 = param2 + 20
if param2 == 21 then
param2 = 23
elseif param2 == 23 then
param2 = 21
end
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end,
on_rightclick = on_rightclick, on_rightclick = on_rightclick,
}) })