Fix disabled signs.

This commit is contained in:
kaeza 2013-08-16 13:11:29 -03:00
parent b0cbea42e0
commit 53e9690679
3 changed files with 118 additions and 109 deletions

View File

@ -446,10 +446,8 @@ minetest.register_node("homedecor:fence_chainlink_corner", {
}, },
}) })
if not homedecor_disable_signs then minetest.register_alias("homedecor:fence_wood_with_sign", "signs:sign_post")
minetest.register_alias("homedecor:fence_wood_with_sign", "signs:sign_post")
homedecor_register_fence_with_sign("default:fence_wood", "signs:sign_post") homedecor_register_fence_with_sign("default:fence_wood", "signs:sign_post")
homedecor_register_fence_with_sign("homedecor:fence_brass", "homedecor:fence_brass_with_sign") homedecor_register_fence_with_sign("homedecor:fence_brass", "homedecor:fence_brass_with_sign")
homedecor_register_fence_with_sign("homedecor:fence_wrought_iron", "homedecor:fence_wrought_iron_with_sign") homedecor_register_fence_with_sign("homedecor:fence_wrought_iron", "homedecor:fence_wrought_iron_with_sign")
end

View File

@ -83,9 +83,7 @@ dofile(minetest.get_modpath("homedecor").."/slopes.lua")
dofile(minetest.get_modpath("homedecor").."/door_models.lua") dofile(minetest.get_modpath("homedecor").."/door_models.lua")
dofile(minetest.get_modpath("homedecor").."/doors_and_gates.lua") dofile(minetest.get_modpath("homedecor").."/doors_and_gates.lua")
if not homedecor_disable_signs then dofile(minetest.get_modpath("homedecor").."/signs_lib.lua")
dofile(minetest.get_modpath("homedecor").."/signs_lib.lua")
end
dofile(minetest.get_modpath("homedecor").."/fences.lua") dofile(minetest.get_modpath("homedecor").."/fences.lua")

View File

@ -100,113 +100,115 @@ homedecor_update_sign = function(pos, fields)
text:setyaw(sign_info.yaw) text:setyaw(sign_info.yaw)
end end
minetest.register_node(":default:sign_wall", { if not homedecor_disable_signs then
description = "Sign", minetest.register_node(":default:sign_wall", {
inventory_image = "default_sign_wall.png", description = "Sign",
wield_image = "default_sign_wall.png", inventory_image = "default_sign_wall.png",
node_placement_prediction = "", wield_image = "default_sign_wall.png",
paramtype = "light", node_placement_prediction = "",
sunlight_propagates = true, paramtype = "light",
paramtype2 = "facedir", sunlight_propagates = true,
drawtype = "nodebox", paramtype2 = "facedir",
node_box = {type = "fixed", fixed = {-0.45, -0.15, 0.4, 0.45, 0.45, 0.498}}, drawtype = "nodebox",
selection_box = {type = "fixed", fixed = {-0.45, -0.15, 0.4, 0.45, 0.45, 0.498}}, node_box = {type = "fixed", fixed = {-0.45, -0.15, 0.4, 0.45, 0.45, 0.498}},
tiles = {"signs_top.png", "signs_bottom.png", "signs_side.png", "signs_side.png", "signs_back.png", "signs_front.png"}, selection_box = {type = "fixed", fixed = {-0.45, -0.15, 0.4, 0.45, 0.45, 0.498}},
groups = sign_groups, tiles = {"signs_top.png", "signs_bottom.png", "signs_side.png", "signs_side.png", "signs_back.png", "signs_front.png"},
groups = sign_groups,
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local name local name
name = minetest.get_node(pointed_thing.under).name name = minetest.get_node(pointed_thing.under).name
if fences_with_sign[name] then if fences_with_sign[name] then
if homedecor_node_is_owned(pointed_thing.under, placer) then if homedecor_node_is_owned(pointed_thing.under, placer) then
return itemstack return itemstack
end
else
name = minetest.get_node(pointed_thing.above).name
local def = minetest.registered_nodes[name]
if homedecor_node_is_owned(pointed_thing.above, placer)
or (not def.buildable_to) then
return itemstack
end
end end
local node=minetest.get_node(pointed_thing.under)
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
else else
name = minetest.get_node(pointed_thing.above).name local above = pointed_thing.above
local def = minetest.registered_nodes[name] local under = pointed_thing.under
if homedecor_node_is_owned(pointed_thing.above, placer) local dir = {x = under.x - above.x,
or (not def.buildable_to) then y = under.y - above.y,
return itemstack z = under.z - above.z}
local wdir = minetest.dir_to_wallmounted(dir)
local placer_pos = placer:getpos()
if placer_pos then
dir = {
x = above.x - placer_pos.x,
y = above.y - placer_pos.y,
z = above.z - placer_pos.z
}
end end
end
local node=minetest.get_node(pointed_thing.under) local fdir = minetest.dir_to_facedir(dir)
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then local sign_info
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer) local pt_name = minetest.get_node(under).name
else print(dump(pt_name))
local above = pointed_thing.above
local under = pointed_thing.under
local dir = {x = under.x - above.x,
y = under.y - above.y,
z = under.z - above.z}
local wdir = minetest.dir_to_wallmounted(dir) if fences_with_sign[pt_name] then
minetest.add_node(under, {name = fences_with_sign[pt_name], param2 = fdir})
sign_info = signs_post[fdir + 1]
local placer_pos = placer:getpos() elseif wdir == 0 then
if placer_pos then --how would you add sign to ceiling?
dir = { minetest.add_item(above, "default:sign_wall")
x = above.x - placer_pos.x, itemstack:take_item()
y = above.y - placer_pos.y, return itemstack
z = above.z - placer_pos.z elseif wdir == 1 then
} minetest.add_node(above, {name = "signs:sign_yard", param2 = fdir})
end sign_info = signs_yard[fdir + 1]
else
minetest.add_node(above, {name = "default:sign_wall", param2 = fdir})
sign_info = signs[fdir + 1]
end
local fdir = minetest.dir_to_facedir(dir) local text = minetest.add_entity({x = above.x + sign_info.delta.x,
y = above.y + sign_info.delta.y,
z = above.z + sign_info.delta.z}, "signs:text")
text:setyaw(sign_info.yaw)
local sign_info
local pt_name = minetest.get_node(under).name if not homedecor_expect_infinite_stacks then
print(dump(pt_name))
if fences_with_sign[pt_name] then
minetest.add_node(under, {name = fences_with_sign[pt_name], param2 = fdir})
sign_info = signs_post[fdir + 1]
elseif wdir == 0 then
--how would you add sign to ceiling?
minetest.add_item(above, "default:sign_wall")
itemstack:take_item() itemstack:take_item()
return itemstack end
elseif wdir == 1 then return itemstack
minetest.add_node(above, {name = "signs:sign_yard", param2 = fdir})
sign_info = signs_yard[fdir + 1]
else
minetest.add_node(above, {name = "default:sign_wall", param2 = fdir})
sign_info = signs[fdir + 1]
end end
end,
local text = minetest.add_entity({x = above.x + sign_info.delta.x, on_construct = function(pos)
y = above.y + sign_info.delta.y, homedecor_construct_sign(pos)
z = above.z + sign_info.delta.z}, "signs:text") end,
text:setyaw(sign_info.yaw) on_destruct = function(pos)
homedecor_destruct_sign(pos)
end,
if not homedecor_expect_infinite_stacks then on_receive_fields = function(pos, formname, fields, sender)
itemstack:take_item() if fields then
end print(S("%s wrote \"%s\" to sign at %s"):format(
return itemstack (sender:get_player_name() or ""),
end fields.text,
end, minetest.pos_to_string(pos)
on_construct = function(pos) ))
homedecor_construct_sign(pos) end
end, homedecor_update_sign(pos, fields)
on_destruct = function(pos) end,
homedecor_destruct_sign(pos) on_punch = function(pos, node, puncher)
end, homedecor_update_sign(pos)
on_receive_fields = function(pos, formname, fields, sender) end,
if fields then })
print(S("%s wrote \"%s\" to sign at %s"):format( end
(sender:get_player_name() or ""),
fields.text,
minetest.pos_to_string(pos)
))
end
homedecor_update_sign(pos, fields)
end,
on_punch = function(pos, node, puncher)
homedecor_update_sign(pos)
end,
})
minetest.register_node(":signs:sign_yard", { minetest.register_node(":signs:sign_yard", {
paramtype = "light", paramtype = "light",
@ -281,17 +283,28 @@ minetest.register_node(":signs:sign_post", {
}, },
}) })
local signs_text_on_activate
if not homedecor_disable_signs then
signs_text_on_activate = function(self)
local meta = minetest.get_meta(self.object:getpos())
local text = meta:get_string("text")
self.object:set_properties({textures={homedecor_generate_texture(homedecor_create_lines(text))}})
end
else
signs_text_on_activate = function(self)
self.object:remove()
end
end
minetest.register_entity(":signs:text", { minetest.register_entity(":signs:text", {
collisionbox = { 0, 0, 0, 0, 0, 0 }, collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "upright_sprite", visual = "upright_sprite",
textures = {}, textures = {},
on_activate = function(self) on_activate = signs_text_on_activate,
local meta = minetest.get_meta(self.object:getpos())
local text = meta:get_string("text")
self.object:set_properties({textures={homedecor_generate_texture(homedecor_create_lines(text))}})
end
}) })
-- CONSTANTS -- CONSTANTS