Fix sign text entity position problems

This commit is contained in:
Wuzzy 2017-07-26 16:02:55 +02:00
parent 461f5738d5
commit 4ff88e211d

@ -259,10 +259,10 @@ minetest.register_node("mcl_signs:wall_sign", {
local under = pointed_thing.under local under = pointed_thing.under
-- Use pointed node's on_rightclick function first, if present -- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node(under) local node_under = minetest.get_node(under)
if placer and not placer:get_player_control().sneak then if placer and not placer:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack
end end
end end
@ -281,7 +281,6 @@ minetest.register_node("mcl_signs:wall_sign", {
local fdir = minetest.dir_to_facedir(dir) local fdir = minetest.dir_to_facedir(dir)
local sign_info local sign_info
local place_pos
local nodeitem = ItemStack(itemstack) local nodeitem = ItemStack(itemstack)
-- Ceiling -- Ceiling
if wdir == 0 then if wdir == 0 then
@ -290,7 +289,6 @@ minetest.register_node("mcl_signs:wall_sign", {
-- Floor -- Floor
elseif wdir == 1 then elseif wdir == 1 then
-- Standing sign -- Standing sign
place_pos = above
-- Determine the sign rotation based on player's yaw -- Determine the sign rotation based on player's yaw
local yaw = math.pi*2 - placer:get_look_horizontal() local yaw = math.pi*2 - placer:get_look_horizontal()
@ -325,7 +323,6 @@ minetest.register_node("mcl_signs:wall_sign", {
-- Side -- Side
else else
-- Wall sign -- Wall sign
place_pos = above
local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir)
if not success then if not success then
return itemstack return itemstack
@ -333,6 +330,14 @@ minetest.register_node("mcl_signs:wall_sign", {
sign_info = signtext_info_wall[fdir + 1] sign_info = signtext_info_wall[fdir + 1]
end end
-- Determine spawn position of entity
local place_pos
if minetest.registered_nodes[node_under.name].buildable_to then
place_pos = under
else
place_pos = above
end
local text_entity = minetest.add_entity({ local text_entity = minetest.add_entity({
x = place_pos.x + sign_info.delta.x, x = place_pos.x + sign_info.delta.x,
y = place_pos.y + sign_info.delta.y, y = place_pos.y + sign_info.delta.y,