mirror of
https://github.com/pyrollo/display_modpack.git
synced 2025-06-30 23:20:43 +02:00
Release 2017-08-26
This commit is contained in:
136
signs/nodes.lua
136
signs/nodes.lua
@ -22,17 +22,20 @@ local S = signs.intllib
|
||||
local F = function(...) return minetest.formspec_escape(S(...)) end
|
||||
|
||||
-- Poster specific formspec
|
||||
local function on_rightclick_poster(pos, node, player)
|
||||
local function on_rightclick_poster(pos, node, player, itemstack, pointed_thing)
|
||||
local formspec
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
if not minetest.is_protected(pos, player:get_player_name()) then
|
||||
formspec =
|
||||
"size[6.5,7.5]"..
|
||||
"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")).."]"..
|
||||
"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")).."]"..
|
||||
"button_exit[2,7;2,1;ok;"..F("Write").."]"
|
||||
minetest.show_formspec(player:get_player_name(),
|
||||
"signs:poster@"..minetest.pos_to_string(pos),
|
||||
node.name.."@"..minetest.pos_to_string(pos),
|
||||
formspec)
|
||||
else
|
||||
formspec = "size[8,9]"..
|
||||
@ -45,14 +48,14 @@ local function on_rightclick_poster(pos, node, player)
|
||||
"",
|
||||
formspec)
|
||||
end
|
||||
|
||||
return itemstack
|
||||
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
|
||||
if fields and fields.ok then
|
||||
if fields and (fields.ok or fields.key_enter) then
|
||||
meta:set_string("display_text", fields.display_text)
|
||||
meta:set_string("text", fields.text)
|
||||
meta:set_string("infotext", "\""..fields.display_text
|
||||
@ -67,66 +70,55 @@ display_lib.register_display_entity("signs:text")
|
||||
|
||||
-- Sign models and registration
|
||||
local models = {
|
||||
wooden_right={
|
||||
depth=1/16,
|
||||
width = 14/16,
|
||||
height = 7/16,
|
||||
entity_fields = {
|
||||
size = { x = 12/16, y = 5/16 },
|
||||
resolution = { x = 112, y = 64 },
|
||||
maxlines = 2,
|
||||
color="#000",
|
||||
},
|
||||
node_fields = {
|
||||
description=S("Wooden direction sign"),
|
||||
tiles={"signs_wooden_direction.png"},
|
||||
inventory_image="signs_wooden_inventory.png",
|
||||
on_place=signs.on_place_direction,
|
||||
on_rightclick = signs.on_right_click_direction,
|
||||
drawtype = "mesh",
|
||||
mesh = "signs_dir_right.obj",
|
||||
selection_box = { type="wallmounted",
|
||||
wall_side = {-0.5, -7/32, -7/16, -7/16, 7/32, 0.5},
|
||||
wall_bottom = {-0.5, -0.5, -0.5, 0.5, -7/16, 0.5},
|
||||
wall_top = {-0.5, 0.5, -0.5, 0.5, 7/16, 0.5}},
|
||||
collision_box = { type="wallmounted",
|
||||
wall_side = {-0.5, -7/32, -7/16, -7/16, 7/32, 0.5},
|
||||
wall_bottom = {-0.5, -0.5, -0.5, 0.5, -7/16, 0.5},
|
||||
wall_top = {-0.5, 0.5, -0.5, 0.5, 7/16, 0.5}},
|
||||
},
|
||||
},
|
||||
wooden_left={
|
||||
wooden_right_sign = {
|
||||
depth = 1/16,
|
||||
width = 14/16,
|
||||
height = 7/16,
|
||||
entity_fields = {
|
||||
size = { x = 12/16, y = 5/16 },
|
||||
right = -3/32,
|
||||
size = { x = 12/16, y = 6/16 },
|
||||
resolution = { x = 112, y = 64 },
|
||||
maxlines = 2,
|
||||
color="#000",
|
||||
},
|
||||
node_fields = {
|
||||
description=S("Wooden direction sign"),
|
||||
tiles={"signs_wooden_direction.png"},
|
||||
inventory_image="signs_wooden_inventory.png",
|
||||
on_place=signs.on_place_direction,
|
||||
on_rightclick = signs.on_right_click_direction,
|
||||
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,
|
||||
drawtype = "mesh",
|
||||
mesh = "signs_dir_left.obj",
|
||||
selection_box = { type="wallmounted",
|
||||
wall_side = {-0.5, -7/32, -0.5, -7/16, 7/32, 7/16},
|
||||
wall_bottom = {-0.5, -0.5, -0.5, 0.5, -7/16, 0.5},
|
||||
wall_top = {-0.5, 0.5, -0.5, 0.5, 7/16, 0.5}},
|
||||
collision_box = { type="wallmounted",
|
||||
wall_side = {-0.5, -7/32, -0.5, -7/16, 7/32, 7/16},
|
||||
wall_bottom = {-0.5, -0.5, -0.5, 0.5, -7/16, 0.5},
|
||||
wall_top = {-0.5, 0.5, -0.5, 0.5, 7/16, 0.5}},
|
||||
groups={not_in_creative_inventory=1},
|
||||
drop="signs:wooden_right",
|
||||
mesh = "signs_dir_right.obj",
|
||||
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}},
|
||||
},
|
||||
},
|
||||
poster={
|
||||
depth=1/32,
|
||||
wooden_left_sign = {
|
||||
depth = 1/16,
|
||||
width = 14/16,
|
||||
height = 7/16,
|
||||
entity_fields = {
|
||||
right = 3/32,
|
||||
size = { x = 12/16, y = 6/16 },
|
||||
resolution = { x = 112, y = 64 },
|
||||
maxlines = 2,
|
||||
color = "#000",
|
||||
},
|
||||
node_fields = {
|
||||
description = S("Wooden direction sign"),
|
||||
tiles = { "signs_wooden_direction.png" },
|
||||
inventory_image = "signs_wooden_inventory.png",
|
||||
signs_other_dir = 'signs:wooden_right_sign',
|
||||
drawtype = "mesh",
|
||||
mesh = "signs_dir_left.obj",
|
||||
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",
|
||||
},
|
||||
},
|
||||
paper_poster = {
|
||||
depth = 1/32,
|
||||
width = 26/32,
|
||||
height = 30/32,
|
||||
entity_fields = {
|
||||
@ -136,39 +128,21 @@ local models = {
|
||||
valign="top",
|
||||
},
|
||||
node_fields = {
|
||||
description=S("Poster"),
|
||||
tiles={"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,
|
||||
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,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Node registration
|
||||
for name, model in pairs(models)
|
||||
do
|
||||
signs.register_sign("signs", name, model)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("homedecor") then
|
||||
print ("["..minetest.get_current_modname().."] homedecor mod is present, not overriding default:sign.")
|
||||
else
|
||||
-- Override default sign
|
||||
signs.register_sign(":default", "sign_wall", {
|
||||
depth = 1/16,
|
||||
width = 14/16,
|
||||
height = 10/16,
|
||||
entity_fields = {
|
||||
size = { x = 12/16, y = 8/16 },
|
||||
resolution = { x = 144, y = 64 },
|
||||
maxlines = 3,
|
||||
color="#000",
|
||||
},
|
||||
node_fields = {
|
||||
description="Sign",
|
||||
tiles={"signs_default.png"},
|
||||
inventory_image="signs_default_inventory.png",
|
||||
},
|
||||
})
|
||||
end
|
||||
|
Reference in New Issue
Block a user