2016-08-25 21:58:28 +02:00
|
|
|
--[[
|
|
|
|
signs mod for Minetest - Various signs with text displayed on
|
|
|
|
(c) Pierre-Yves Rollo
|
|
|
|
|
|
|
|
This file is part of signs.
|
|
|
|
|
|
|
|
signs is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
signs is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with signs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
--]]
|
|
|
|
|
2017-08-05 10:12:43 +02:00
|
|
|
local S = signs.intllib
|
|
|
|
local F = function(...) return minetest.formspec_escape(S(...)) end
|
|
|
|
|
2015-11-11 14:26:39 +01:00
|
|
|
-- Poster specific formspec
|
2017-08-26 14:12:38 +02:00
|
|
|
local function on_rightclick_poster(pos, node, player, itemstack, pointed_thing)
|
2015-11-11 14:26:39 +01:00
|
|
|
local formspec
|
|
|
|
local meta = minetest.get_meta(pos)
|
2017-08-26 14:12:38 +02:00
|
|
|
|
2015-11-11 14:26:39 +01:00
|
|
|
if not minetest.is_protected(pos, player:get_player_name()) then
|
|
|
|
formspec =
|
|
|
|
"size[6.5,7.5]"..
|
2017-08-26 14:12:38 +02:00
|
|
|
"field[0.5,0.7;6,1;display_text;"..F("Title")..";"..
|
|
|
|
minetest.formspec_escape(meta:get_string("display_text")).."]"..
|
|
|
|
"textarea[0.5,1.7;6,6;text;"..F("Text")..";"..
|
|
|
|
minetest.formspec_escape(meta:get_string("text")).."]"..
|
2017-08-05 10:12:43 +02:00
|
|
|
"button_exit[2,7;2,1;ok;"..F("Write").."]"
|
2015-11-11 14:26:39 +01:00
|
|
|
minetest.show_formspec(player:get_player_name(),
|
2017-08-26 14:12:38 +02:00
|
|
|
node.name.."@"..minetest.pos_to_string(pos),
|
2015-11-11 14:26:39 +01:00
|
|
|
formspec)
|
|
|
|
else
|
|
|
|
formspec = "size[8,9]"..
|
|
|
|
"size[6.5,7.5]"..
|
|
|
|
"label[0.5,0;"..minetest.formspec_escape(meta:get_string("display_text")).."]"..
|
|
|
|
"textarea[0.5,1;6,7;;"..minetest.formspec_escape(meta:get_string("text"))..";]"..
|
|
|
|
"bgcolor[#111]"..
|
2017-08-05 10:12:43 +02:00
|
|
|
"button_exit[2,7;2,1;ok;"..F("Close").."]"
|
2015-11-11 14:26:39 +01:00
|
|
|
minetest.show_formspec(player:get_player_name(),
|
|
|
|
"",
|
|
|
|
formspec)
|
|
|
|
end
|
2017-08-26 14:12:38 +02:00
|
|
|
return itemstack
|
2015-11-11 14:26:39 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Poster specific on_receive_fields callback
|
|
|
|
local function on_receive_fields_poster(pos, formname, fields, player)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
if not minetest.is_protected(pos, player:get_player_name()) then
|
2017-08-26 14:12:38 +02:00
|
|
|
if fields and (fields.ok or fields.key_enter) then
|
2015-11-11 14:26:39 +01:00
|
|
|
meta:set_string("display_text", fields.display_text)
|
|
|
|
meta:set_string("text", fields.text)
|
|
|
|
meta:set_string("infotext", "\""..fields.display_text
|
2017-08-05 10:12:43 +02:00
|
|
|
.."\"\n"..S("(right-click to read more text)"))
|
2015-11-11 14:26:39 +01:00
|
|
|
display_lib.update_entities(pos)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-28 20:44:04 +01:00
|
|
|
-- Text entity for all signs
|
2017-11-30 21:15:06 +01:00
|
|
|
display_lib.register_display_entity("signs:display_text")
|
2015-11-28 20:44:04 +01:00
|
|
|
|
|
|
|
-- Sign models and registration
|
|
|
|
local models = {
|
2017-08-26 14:12:38 +02:00
|
|
|
wooden_right_sign = {
|
|
|
|
depth = 1/16,
|
2015-11-28 20:44:04 +01:00
|
|
|
width = 14/16,
|
|
|
|
height = 7/16,
|
|
|
|
entity_fields = {
|
2017-08-26 14:12:38 +02:00
|
|
|
right = -3/32,
|
|
|
|
size = { x = 12/16, y = 6/16 },
|
2015-11-28 20:44:04 +01:00
|
|
|
resolution = { x = 112, y = 64 },
|
|
|
|
maxlines = 2,
|
|
|
|
color="#000",
|
|
|
|
},
|
|
|
|
node_fields = {
|
2017-08-26 14:12:38 +02:00
|
|
|
description = S("Wooden direction sign"),
|
|
|
|
tiles = { "signs_wooden_direction.png" },
|
|
|
|
inventory_image = "signs_wooden_inventory.png",
|
|
|
|
signs_other_dir = 'signs:wooden_left_sign',
|
|
|
|
on_place = signs.on_place_direction,
|
2016-08-25 21:58:28 +02:00
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "signs_dir_right.obj",
|
2017-08-26 14:12:38 +02:00
|
|
|
selection_box = { type="fixed", fixed = {-0.5, -7/32, 0.5, 7/16, 7/32, 7/16}},
|
|
|
|
collision_box = { type="fixed", fixed = {-0,5, -7/32, 0.5, 7/16, 7/32, 7/16}},
|
2015-11-11 14:26:39 +01:00
|
|
|
},
|
|
|
|
},
|
2017-08-26 14:12:38 +02:00
|
|
|
wooden_left_sign = {
|
2016-08-25 21:58:28 +02:00
|
|
|
depth = 1/16,
|
2015-11-28 20:44:04 +01:00
|
|
|
width = 14/16,
|
|
|
|
height = 7/16,
|
|
|
|
entity_fields = {
|
2017-08-26 14:12:38 +02:00
|
|
|
right = 3/32,
|
|
|
|
size = { x = 12/16, y = 6/16 },
|
2015-11-28 20:44:04 +01:00
|
|
|
resolution = { x = 112, y = 64 },
|
|
|
|
maxlines = 2,
|
2017-08-26 14:12:38 +02:00
|
|
|
color = "#000",
|
2015-11-28 20:44:04 +01:00
|
|
|
},
|
|
|
|
node_fields = {
|
2017-08-26 14:12:38 +02:00
|
|
|
description = S("Wooden direction sign"),
|
|
|
|
tiles = { "signs_wooden_direction.png" },
|
|
|
|
inventory_image = "signs_wooden_inventory.png",
|
|
|
|
signs_other_dir = 'signs:wooden_right_sign',
|
2016-08-25 21:58:28 +02:00
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "signs_dir_left.obj",
|
2017-08-26 14:12:38 +02:00
|
|
|
selection_box = { type="fixed", fixed = {-7/16, -7/32, 0.5, 0.5, 7/32, 7/16}},
|
|
|
|
collision_box = { type="fixed", fixed = {-7/16, -7/32, 0.5, 0.5, 7/32, 7/16}},
|
|
|
|
groups = { not_in_creative_inventory = 1 },
|
|
|
|
drop = "signs:wooden_right_sign",
|
2015-11-11 14:26:39 +01:00
|
|
|
},
|
|
|
|
},
|
2017-08-26 14:12:38 +02:00
|
|
|
paper_poster = {
|
|
|
|
depth = 1/32,
|
2015-11-28 20:44:04 +01:00
|
|
|
width = 26/32,
|
|
|
|
height = 30/32,
|
|
|
|
entity_fields = {
|
|
|
|
resolution = { x = 144, y = 64 },
|
|
|
|
maxlines = 1,
|
|
|
|
color="#000",
|
|
|
|
valign="top",
|
|
|
|
},
|
|
|
|
node_fields = {
|
2017-08-26 14:12:38 +02:00
|
|
|
description = S("Poster"),
|
|
|
|
tiles = { "signs_poster_sides.png", "signs_poster_sides.png",
|
|
|
|
"signs_poster_sides.png", "signs_poster_sides.png",
|
|
|
|
"signs_poster_sides.png", "signs_poster.png" },
|
|
|
|
inventory_image = "signs_poster_inventory.png",
|
|
|
|
on_construct = display_lib.on_construct,
|
|
|
|
on_rightclick = on_rightclick_poster,
|
|
|
|
on_receive_fields = on_receive_fields_poster,
|
2015-11-11 14:26:39 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-08-26 14:12:38 +02:00
|
|
|
-- Node registration
|
2015-11-28 20:44:04 +01:00
|
|
|
for name, model in pairs(models)
|
2015-11-11 14:26:39 +01:00
|
|
|
do
|
2015-11-28 20:44:04 +01:00
|
|
|
signs.register_sign("signs", name, model)
|
|
|
|
end
|
|
|
|
|