1
0
mirror of https://github.com/pyrollo/display_modpack.git synced 2024-11-12 13:20:30 +01:00

Check existence of material before registering stele

This commit is contained in:
Pierre-Yves Rollo 2015-12-03 15:43:39 +01:00
parent a7e80f4b98
commit dc7aea71ee

View File

@ -14,52 +14,55 @@ display_lib.register_display_entity("steles:text")
for _, material in ipairs(steles.materials) do for _, material in ipairs(steles.materials) do
local ndef = minetest.registered_nodes[material] local ndef = minetest.registered_nodes[material]
local parts = material:split(":")
minetest.register_node("steles:"..parts[2].."_stele", { if ndef then
description = ndef.description.." Stele", local parts = material:split(":")
sunlight_propagates = true,
paramtype = "light", minetest.register_node("steles:"..parts[2].."_stele", {
paramtype2 = "facedir", description = ndef.description.." Stele",
tiles = ndef.tiles, sunlight_propagates = true,
drawtype = "nodebox", paramtype = "light",
node_box = { paramtype2 = "facedir",
type = "fixed", tiles = ndef.tiles,
fixed = { drawtype = "nodebox",
{-5/16, -4/16, -2/16, 5/16, 0.5, 2/16}, node_box = {
{-7/16, -0.5, -4/16, 7/16, -4/16, 4/16} type = "fixed",
} fixed = {
}, {-5/16, -4/16, -2/16, 5/16, 0.5, 2/16},
groups = ndef.groups, {-7/16, -0.5, -4/16, 7/16, -4/16, 4/16}
display_entities = { }
["steles:text"] = {
on_display_update = font_lib.on_display_update,
depth = -2/16-0.001, height = 2/16,
size = { x = 14/16, y = 12/16 },
resolution = { x = 144, y = 64 },
maxlines = 3,
}, },
}, groups = ndef.groups,
on_place = display_lib.on_place, display_entities = {
on_construct = function(pos) ["steles:text"] = {
local meta = minetest.get_meta(pos) on_display_update = font_lib.on_display_update,
meta:set_string("formspec", "size[6,4]".. depth = -2/16-0.001, height = 2/16,
"textarea[0.5,0.7;5.5,2;display_text;Displayed text (3 lines max);${display_text}]".. size = { x = 14/16, y = 12/16 },
"button_exit[2,3;2,1;ok;Write]") resolution = { x = 144, y = 64 },
display_lib.on_construct(pos) maxlines = 3,
end, },
on_destruct = display_lib.on_destruct, },
on_rotate = display_lib.on_rotate, on_place = display_lib.on_place,
on_receive_fields = function(pos, formname, fields, player) on_construct = function(pos)
if not minetest.is_protected(pos, player:get_player_name()) then local meta = minetest.get_meta(pos)
local meta = minetest.get_meta(pos) meta:set_string("formspec", "size[6,4]"..
if fields and fields.ok then "textarea[0.5,0.7;5.5,2;display_text;Displayed text (3 lines max);${display_text}]"..
meta:set_string("display_text", fields.display_text) "button_exit[2,3;2,1;ok;Write]")
meta:set_string("infotext", "\""..fields.display_text.."\"") display_lib.on_construct(pos)
display_lib.update_entities(pos)
end
end
end, end,
}) on_destruct = display_lib.on_destruct,
on_rotate = display_lib.on_rotate,
on_receive_fields = function(pos, formname, fields, player)
if not minetest.is_protected(pos, player:get_player_name()) then
local meta = minetest.get_meta(pos)
if fields and fields.ok then
meta:set_string("display_text", fields.display_text)
meta:set_string("infotext", "\""..fields.display_text.."\"")
display_lib.update_entities(pos)
end
end
end,
})
end
end end