Merge branch 'sign_r90'
This commit is contained in:
commit
4cc54d29ab
@ -2,6 +2,38 @@ local S = minetest.get_translator("rp_default")
|
|||||||
|
|
||||||
local SIGN_MAX_TEXT_LENGTH = 64
|
local SIGN_MAX_TEXT_LENGTH = 64
|
||||||
|
|
||||||
|
local on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", rp_formspec.get_page("rp_default:field"))
|
||||||
|
-- Show empty sign text in quotation marks
|
||||||
|
meta:set_string("infotext", S('""'))
|
||||||
|
meta:set_string("text", "")
|
||||||
|
end
|
||||||
|
local on_receive_fields = function(pos, formname, fields, sender)
|
||||||
|
if fields.text == nil then return end
|
||||||
|
if minetest.is_protected(pos, sender:get_player_name()) and
|
||||||
|
not minetest.check_player_privs(sender, "protection_bypass") then
|
||||||
|
minetest.record_protection_violation(pos, sender:get_player_name())
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local text = fields.text
|
||||||
|
if string.len(text) > SIGN_MAX_TEXT_LENGTH then
|
||||||
|
text = string.sub(text, 1, SIGN_MAX_TEXT_LENGTH)
|
||||||
|
end
|
||||||
|
minetest.log("action", (sender:get_player_name() or "")..
|
||||||
|
" wrote \""..text.."\" to sign at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
meta:set_string("text", text)
|
||||||
|
-- Show sign text in quotation marks
|
||||||
|
meta:set_string("infotext", S('"@1"', text))
|
||||||
|
|
||||||
|
default.write_name(pos, meta:get_string("text"))
|
||||||
|
end
|
||||||
|
local on_destruct = function(pos)
|
||||||
|
default.write_name(pos, "")
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node(
|
minetest.register_node(
|
||||||
"rp_default:sign",
|
"rp_default:sign",
|
||||||
{
|
{
|
||||||
@ -24,32 +56,57 @@ minetest.register_node(
|
|||||||
groups = {choppy = 2,handy = 2,attached_node = 1},
|
groups = {choppy = 2,handy = 2,attached_node = 1},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = rp_sounds.node_sound_defaults(),
|
sounds = rp_sounds.node_sound_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = on_construct,
|
||||||
--local n = minetest.get_node(pos)
|
on_receive_fields = on_receive_fields,
|
||||||
local meta = minetest.get_meta(pos)
|
on_destruct = on_destruct,
|
||||||
meta:set_string("formspec", rp_formspec.get_page("rp_default:field"))
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
-- Show empty sign text in quotation marks
|
if not placer or not placer:is_player() then
|
||||||
meta:set_string("infotext", S('""'))
|
return itemstack
|
||||||
meta:set_string("text", "")
|
end
|
||||||
end,
|
if pointed_thing.type ~= "node" then
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
if fields.text == nil then return end
|
end
|
||||||
if minetest.is_protected(pos, sender:get_player_name()) and
|
if pointed_thing.under.y == pointed_thing.above.y then
|
||||||
not minetest.check_player_privs(sender, "protection_bypass") then
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
minetest.record_protection_violation(pos, sender:get_player_name())
|
end
|
||||||
return itemstack
|
|
||||||
end
|
local r90 = false
|
||||||
local meta = minetest.get_meta(pos)
|
local yaw = placer:get_look_horizontal()
|
||||||
local text = fields.text
|
if not ((yaw > (1/4)*math.pi and yaw < (3/4)*math.pi) or (yaw > (5/4)*math.pi and yaw < (7/4)*math.pi)) then
|
||||||
if string.len(text) > SIGN_MAX_TEXT_LENGTH then
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
text = string.sub(text, 1, SIGN_MAX_TEXT_LENGTH)
|
end
|
||||||
end
|
local r90sign = ItemStack("rp_default:sign_r90")
|
||||||
minetest.log("action", (sender:get_player_name() or "")..
|
r90sign = minetest.item_place_node(r90sign, placer, pointed_thing)
|
||||||
" wrote \""..text.."\" to sign at "..
|
if r90sign:is_empty() then
|
||||||
minetest.pos_to_string(pos))
|
itemstack:take_item()
|
||||||
meta:set_string("text", text)
|
end
|
||||||
-- Show sign text in quotation marks
|
return itemstack
|
||||||
meta:set_string("infotext", S('"@1"', text))
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node(
|
||||||
|
"rp_default:sign_r90",
|
||||||
|
{
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = {"default_sign.png^[transformR90"},
|
||||||
|
inventory_image = "default_sign_inventory.png^[transformR90",
|
||||||
|
wield_image = "default_sign_inventory.png^[transformR90",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "wallmounted",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
walkable = false,
|
||||||
|
node_box = {
|
||||||
|
type = "wallmounted",
|
||||||
|
wall_top = {-0.5+(4/16), 0.5, -0.5+(1/16), 0.5-(4/16), 0.5-(1/16), 0.5-(1/16)},
|
||||||
|
wall_bottom = {-0.5+(4/16), -0.5, -0.5+(1/16), 0.5-(4/16), -0.5+(1/16), 0.5-(1/16)},
|
||||||
|
wall_side = {-0.5, -0.5+(1/16), -0.5+(4/16), -0.5+(1/16), 0.5-(1/16), 0.5-(4/16)},
|
||||||
|
},
|
||||||
|
groups = {choppy = 2,handy = 2,attached_node = 1, not_in_creative_inventory=1},
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = rp_sounds.node_sound_defaults(),
|
||||||
|
on_construct = on_construct,
|
||||||
|
on_receive_fields = on_receive_fields,
|
||||||
|
on_destruct = on_destruct,
|
||||||
|
drop = "rp_default:sign",
|
||||||
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user