mirror of
https://github.com/mt-mods/signs_lib.git
synced 2025-06-28 13:56:06 +02:00
Compare commits
5 Commits
2019-09-15
...
2019-09-18
Author | SHA1 | Date | |
---|---|---|---|
2d29a539f8 | |||
4b2abfadce | |||
ee2dc495c3 | |||
f944337b1c | |||
a5e711d354 |
351
api.lua
351
api.lua
@ -29,6 +29,8 @@ signs_lib.standard_steel_groups.attached_node = nil
|
|||||||
signs_lib.standard_wood_sign_sounds = table.copy(minetest.registered_items["default:sign_wall_wood"].sounds)
|
signs_lib.standard_wood_sign_sounds = table.copy(minetest.registered_items["default:sign_wall_wood"].sounds)
|
||||||
signs_lib.standard_steel_sign_sounds = table.copy(minetest.registered_items["default:sign_wall_steel"].sounds)
|
signs_lib.standard_steel_sign_sounds = table.copy(minetest.registered_items["default:sign_wall_steel"].sounds)
|
||||||
|
|
||||||
|
signs_lib.default_text_scale = {x=10, y=10}
|
||||||
|
|
||||||
signs_lib.standard_yaw = {
|
signs_lib.standard_yaw = {
|
||||||
0,
|
0,
|
||||||
math.pi / -2,
|
math.pi / -2,
|
||||||
@ -83,7 +85,59 @@ signs_lib.rotate_walldir = {
|
|||||||
-- Initialize character texture cache
|
-- Initialize character texture cache
|
||||||
local ctexcache = {}
|
local ctexcache = {}
|
||||||
|
|
||||||
signs_lib.wallmounted_rotate = function(pos, node, user, mode)
|
-- entity handling
|
||||||
|
|
||||||
|
minetest.register_entity("signs_lib:text", {
|
||||||
|
collisionbox = { 0, 0, 0, 0, 0, 0 },
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "signs_lib_standard_wall_sign_entity.obj",
|
||||||
|
textures = {},
|
||||||
|
static_save = false
|
||||||
|
})
|
||||||
|
|
||||||
|
function signs_lib.delete_objects(pos)
|
||||||
|
print("delete_objects()")
|
||||||
|
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
||||||
|
for _, v in ipairs(objects) do
|
||||||
|
v:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function signs_lib.spawn_entity(pos, texture)
|
||||||
|
print("spawn_entity()")
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local def = minetest.registered_items[node.name]
|
||||||
|
if not def or not def.entity_info or not def.entity_info.yaw[node.param2 + 1] then return end
|
||||||
|
|
||||||
|
local text_scale = (node and node.text_scale) or signs_lib.default_text_scale
|
||||||
|
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
||||||
|
local obj
|
||||||
|
|
||||||
|
if #objects > 0 then
|
||||||
|
obj = objects[1]
|
||||||
|
else
|
||||||
|
obj = minetest.add_entity(pos, "signs_lib:text")
|
||||||
|
end
|
||||||
|
|
||||||
|
obj:setyaw(def.entity_info.yaw[node.param2 + 1])
|
||||||
|
|
||||||
|
if not texture then
|
||||||
|
obj:set_properties({
|
||||||
|
mesh = def.entity_info.mesh,
|
||||||
|
visual_size = text_scale,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
obj:set_properties({
|
||||||
|
mesh = def.entity_info.mesh,
|
||||||
|
visual_size = text_scale,
|
||||||
|
textures={texture},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- rotation
|
||||||
|
|
||||||
|
function signs_lib.wallmounted_rotate(pos, node, user, mode)
|
||||||
if not signs_lib.can_modify(pos, user) then return false end
|
if not signs_lib.can_modify(pos, user) then return false end
|
||||||
|
|
||||||
if mode ~= screwdriver.ROTATE_FACE or string.match(node.name, "_onpole") then
|
if mode ~= screwdriver.ROTATE_FACE or string.match(node.name, "_onpole") then
|
||||||
@ -93,17 +147,12 @@ signs_lib.wallmounted_rotate = function(pos, node, user, mode)
|
|||||||
local newparam2 = signs_lib.rotate_walldir[node.param2] or 0
|
local newparam2 = signs_lib.rotate_walldir[node.param2] or 0
|
||||||
|
|
||||||
minetest.swap_node(pos, { name = node.name, param2 = newparam2 })
|
minetest.swap_node(pos, { name = node.name, param2 = newparam2 })
|
||||||
for _, v in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do
|
signs_lib.delete_objects(pos)
|
||||||
local e = v:get_luaentity()
|
|
||||||
if e and e.name == "signs_lib:text" then
|
|
||||||
v:remove()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
signs_lib.update_sign(pos)
|
signs_lib.update_sign(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
signs_lib.facedir_rotate = function(pos, node, user, mode)
|
function signs_lib.facedir_rotate(pos, node, user, mode)
|
||||||
if not signs_lib.can_modify(pos, user) then return false end
|
if not signs_lib.can_modify(pos, user) then return false end
|
||||||
|
|
||||||
if mode ~= screwdriver.ROTATE_FACE or string.match(node.name, "_onpole") then
|
if mode ~= screwdriver.ROTATE_FACE or string.match(node.name, "_onpole") then
|
||||||
@ -113,18 +162,11 @@ signs_lib.facedir_rotate = function(pos, node, user, mode)
|
|||||||
local newparam2 = signs_lib.rotate_facedir[node.param2] or 0
|
local newparam2 = signs_lib.rotate_facedir[node.param2] or 0
|
||||||
|
|
||||||
minetest.swap_node(pos, { name = node.name, param2 = newparam2 })
|
minetest.swap_node(pos, { name = node.name, param2 = newparam2 })
|
||||||
for _, v in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do
|
signs_lib.delete_objects(pos)
|
||||||
local e = v:get_luaentity()
|
|
||||||
if e and e.name == "signs_lib:text" then
|
|
||||||
v:remove()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
signs_lib.update_sign(pos)
|
signs_lib.update_sign(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local DEFAULT_TEXT_SCALE = {x=10, y=10}
|
|
||||||
|
|
||||||
-- infinite stacks
|
-- infinite stacks
|
||||||
|
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
@ -235,15 +277,6 @@ local fences_with_sign = { }
|
|||||||
|
|
||||||
-- some local helper functions
|
-- some local helper functions
|
||||||
|
|
||||||
local function split_lines_and_words(text)
|
|
||||||
if not text then return end
|
|
||||||
local lines = { }
|
|
||||||
for _, line in ipairs(text:split("\n")) do
|
|
||||||
table.insert(lines, line:split(" "))
|
|
||||||
end
|
|
||||||
return lines
|
|
||||||
end
|
|
||||||
|
|
||||||
local math_max = math.max
|
local math_max = math.max
|
||||||
|
|
||||||
local function fill_line(x, y, w, c, font_size, colorbgw)
|
local function fill_line(x, y, w, c, font_size, colorbgw)
|
||||||
@ -422,26 +455,56 @@ local function make_sign_texture(lines, pos)
|
|||||||
return table.concat(texture, "")
|
return table.concat(texture, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_obj_text(obj, text, x, pos)
|
function signs_lib.split_lines_and_words(text)
|
||||||
local split = split_lines_and_words
|
if not text then return end
|
||||||
local text_ansi = Utf8ToAnsi(text)
|
local lines = { }
|
||||||
local n = minetest.registered_nodes[minetest.get_node(pos).name]
|
for _, line in ipairs(text:split("\n")) do
|
||||||
local text_scale = (n and n.text_scale) or DEFAULT_TEXT_SCALE
|
table.insert(lines, line:split(" "))
|
||||||
local texture = make_sign_texture(split(text_ansi), pos)
|
end
|
||||||
obj:set_properties({
|
return lines
|
||||||
textures={texture},
|
|
||||||
visual_size = text_scale,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
signs_lib.construct_sign = function(pos)
|
function signs_lib.set_obj_text(pos, text)
|
||||||
local meta = minetest.get_meta(pos)
|
print("set_obj_text()")
|
||||||
meta:set_string(
|
local split = signs_lib.split_lines_and_words
|
||||||
"formspec",
|
local text_ansi = Utf8ToAnsi(text)
|
||||||
"size[6,4]"..
|
local n = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||||
|
signs_lib.delete_objects(pos)
|
||||||
|
signs_lib.spawn_entity(pos, make_sign_texture(split(text_ansi), pos))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function make_widefont_nodename(name)
|
||||||
|
if string.find(name, "_widefont") then return name end
|
||||||
|
if string.find(name, "_onpole") then
|
||||||
|
return string.gsub(name, "_onpole", "_widefont_onpole")
|
||||||
|
elseif string.find(name, "_hanging") then
|
||||||
|
return string.gsub(name, "_hanging", "_widefont_hanging")
|
||||||
|
else
|
||||||
|
return name.."_widefont"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function signs_lib.construct_sign(pos)
|
||||||
|
local form = "size[6,4]"..
|
||||||
"textarea[0,-0.3;6.5,3;text;;${text}]"..
|
"textarea[0,-0.3;6.5,3;text;;${text}]"..
|
||||||
"button_exit[2,3.4;2,1;ok;"..S("Write").."]"..
|
"background[-0.5,-0.5;7,5;signs_lib_sign_bg.jpg]"
|
||||||
"background[-0.5,-0.5;7,5;signs_lib_sign_bg.jpg]")
|
local node = minetest.get_node(pos)
|
||||||
|
local wname = make_widefont_nodename(node.name)
|
||||||
|
|
||||||
|
if minetest.registered_items[wname] then
|
||||||
|
local state = "off"
|
||||||
|
if string.find(node.name, "widefont") then state = "on" end
|
||||||
|
form = form.."label[1,3.4;Use wide font]"..
|
||||||
|
"image_button[1.1,3.7;1,0.6;signs_lib_switch_"..
|
||||||
|
state..".png;"..
|
||||||
|
state..";;;false;signs_lib_switch_interm.png]"..
|
||||||
|
"button_exit[3,3.4;2,1;ok;"..S("Write").."]"
|
||||||
|
else
|
||||||
|
form = form.."button_exit[2,3.4;2,1;ok;"..S("Write").."]"
|
||||||
|
end
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", form)
|
||||||
local i = meta:get_string("infotext")
|
local i = meta:get_string("infotext")
|
||||||
if i == "" then -- it wasn't even set, so set it.
|
if i == "" then -- it wasn't even set, so set it.
|
||||||
meta:set_string("infotext", "")
|
meta:set_string("infotext", "")
|
||||||
@ -449,18 +512,12 @@ signs_lib.construct_sign = function(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function signs_lib.destruct_sign(pos)
|
function signs_lib.destruct_sign(pos)
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
signs_lib.delete_objects(pos)
|
||||||
for _, v in ipairs(objects) do
|
|
||||||
local e = v:get_luaentity()
|
|
||||||
if e and e.name == "signs_lib:text" then
|
|
||||||
v:remove()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function make_infotext(text)
|
local function make_infotext(text)
|
||||||
text = trim_input(text)
|
text = trim_input(text)
|
||||||
local lines = split_lines_and_words(text) or {}
|
local lines = signs_lib.split_lines_and_words(text) or {}
|
||||||
local lines2 = { }
|
local lines2 = { }
|
||||||
for _, line in ipairs(lines) do
|
for _, line in ipairs(lines) do
|
||||||
table.insert(lines2, (table.concat(line, " "):gsub("#[0-9a-fA-F]", ""):gsub("##", "#")))
|
table.insert(lines2, (table.concat(line, " "):gsub("#[0-9a-fA-F]", ""):gsub("##", "#")))
|
||||||
@ -475,50 +532,45 @@ function signs_lib.update_sign(pos, fields)
|
|||||||
text = trim_input(text)
|
text = trim_input(text)
|
||||||
|
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
ownstr = ""
|
local ownstr = ""
|
||||||
if owner ~= "" then ownstr = S("Locked sign, owned by @1\n", owner) end
|
if owner ~= "" then ownstr = S("Locked sign, owned by @1\n", owner) end
|
||||||
|
|
||||||
meta:set_string("text", text)
|
meta:set_string("text", text)
|
||||||
meta:set_string("infotext", ownstr..make_infotext(text).." ")
|
meta:set_string("infotext", ownstr..make_infotext(text).." ")
|
||||||
|
signs_lib.set_obj_text(pos, text)
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
|
||||||
local found
|
|
||||||
for _, v in ipairs(objects) do
|
|
||||||
local e = v:get_luaentity()
|
|
||||||
if e and e.name == "signs_lib:text" then
|
|
||||||
if found then
|
|
||||||
v:remove()
|
|
||||||
else
|
|
||||||
set_obj_text(v, text, nil, pos)
|
|
||||||
found = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if found then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if there is no entity
|
|
||||||
local signnode = minetest.get_node(pos)
|
|
||||||
local signname = signnode.name
|
|
||||||
local def = minetest.registered_items[signname]
|
|
||||||
if not def.entity_info or not def.entity_info.yaw[signnode.param2 + 1] then return end
|
|
||||||
local obj = minetest.add_entity(pos, "signs_lib:text")
|
|
||||||
|
|
||||||
obj:setyaw(def.entity_info.yaw[signnode.param2 + 1])
|
|
||||||
obj:set_properties({
|
|
||||||
mesh = def.entity_info.mesh,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function signs_lib.receive_fields(pos, formname, fields, sender)
|
function signs_lib.receive_fields(pos, formname, fields, sender)
|
||||||
if fields and fields.text and fields.ok and signs_lib.can_modify(pos, sender) then
|
|
||||||
|
if not fields or not signs_lib.can_modify(pos, sender) then return end
|
||||||
|
|
||||||
|
if fields.text and fields.ok then
|
||||||
minetest.log("action", S("@1 wrote \"@2\" to sign at @3",
|
minetest.log("action", S("@1 wrote \"@2\" to sign at @3",
|
||||||
(sender:get_player_name() or ""),
|
(sender:get_player_name() or ""),
|
||||||
fields.text:gsub('\\', '\\\\'):gsub("\n", "\\n"),
|
fields.text:gsub('\\', '\\\\'):gsub("\n", "\\n"),
|
||||||
minetest.pos_to_string(pos)
|
minetest.pos_to_string(pos)
|
||||||
))
|
))
|
||||||
signs_lib.update_sign(pos, fields)
|
signs_lib.update_sign(pos, fields)
|
||||||
|
elseif fields.on or fields.off then
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local newname
|
||||||
|
|
||||||
|
if fields.on and string.find(node.name, "widefont") then
|
||||||
|
newname = string.gsub(node.name, "_widefont", "")
|
||||||
|
elseif fields.off and not string.find(node.name, "widefont") then
|
||||||
|
newname = make_widefont_nodename(node.name)
|
||||||
|
end
|
||||||
|
if newname then
|
||||||
|
minetest.log("action", S("@1 flipped the wide-font switch to \"@2\" at @3",
|
||||||
|
(sender:get_player_name() or ""),
|
||||||
|
(fields.on and "off" or "on"),
|
||||||
|
minetest.pos_to_string(pos)
|
||||||
|
))
|
||||||
|
|
||||||
|
minetest.swap_node(pos, {name = newname, param2 = node.param2})
|
||||||
|
signs_lib.construct_sign(pos)
|
||||||
|
signs_lib.update_sign(pos, fields)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -542,30 +594,6 @@ function signs_lib.can_modify(pos, player)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local signs_text_on_activate = function(self)
|
|
||||||
local pos = self.object:getpos()
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local signnode = minetest.get_node(pos)
|
|
||||||
local signname = signnode.name
|
|
||||||
local def = minetest.registered_items[signname]
|
|
||||||
local text = meta:get_string("text")
|
|
||||||
if text and def and def.entity_info then
|
|
||||||
text = trim_input(text)
|
|
||||||
set_obj_text(self.object, text, nil, pos)
|
|
||||||
self.object:set_properties({
|
|
||||||
mesh = def.entity_info.mesh,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_entity("signs_lib:text", {
|
|
||||||
collisionbox = { 0, 0, 0, 0, 0, 0 },
|
|
||||||
visual = "mesh",
|
|
||||||
mesh = "signs_lib_standard_wall_sign_entity.obj",
|
|
||||||
textures = {},
|
|
||||||
on_activate = signs_text_on_activate,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- make selection boxes
|
-- make selection boxes
|
||||||
-- sizex/sizey specified in inches because that's what MUTCD uses.
|
-- sizex/sizey specified in inches because that's what MUTCD uses.
|
||||||
|
|
||||||
@ -602,6 +630,7 @@ function signs_lib.check_for_pole(pos, pointed_thing)
|
|||||||
or string.find(pnode.name, "default:fence_")
|
or string.find(pnode.name, "default:fence_")
|
||||||
or string.find(pnode.name, "_post")
|
or string.find(pnode.name, "_post")
|
||||||
or string.find(pnode.name, "fencepost")
|
or string.find(pnode.name, "fencepost")
|
||||||
|
or string.find(pnode.name, "streets:streetlamp_basic_top")
|
||||||
or (pnode.name == "streets:bigpole" and pnode.param2 < 4)
|
or (pnode.name == "streets:bigpole" and pnode.param2 < 4)
|
||||||
or (pnode.name == "streets:bigpole" and pnode.param2 > 19 and pnode.param2 < 24)
|
or (pnode.name == "streets:bigpole" and pnode.param2 > 19 and pnode.param2 < 24)
|
||||||
)
|
)
|
||||||
@ -620,6 +649,7 @@ function signs_lib.check_for_ceiling(pointed_thing)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locked)
|
function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locked)
|
||||||
|
print("after_place_node")
|
||||||
local playername = placer:get_player_name()
|
local playername = placer:get_player_name()
|
||||||
local def = minetest.registered_items[itemstack:get_name()]
|
local def = minetest.registered_items[itemstack:get_name()]
|
||||||
|
|
||||||
@ -646,47 +676,7 @@ function signs_lib.register_fence_with_sign()
|
|||||||
minetest.log("warning", "[signs_lib] ".."Attempt to call no longer used function signs_lib.register_fence_with_sign()")
|
minetest.log("warning", "[signs_lib] ".."Attempt to call no longer used function signs_lib.register_fence_with_sign()")
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
local function register_sign(name, rdef)
|
||||||
The main sign registration function
|
|
||||||
===================================
|
|
||||||
|
|
||||||
Example minimal recommended def for writable signs:
|
|
||||||
|
|
||||||
signs_lib.register_sign("foo:my_cool_sign", {
|
|
||||||
description = "Wooden cool sign",
|
|
||||||
inventory_image = "signs_lib_sign_cool_inv.png",
|
|
||||||
tiles = {
|
|
||||||
"signs_lib_sign_cool.png",
|
|
||||||
"signs_lib_sign_cool_edges.png"
|
|
||||||
},
|
|
||||||
number_of_lines = 2,
|
|
||||||
horiz_scaling = 0.8,
|
|
||||||
vert_scaling = 1,
|
|
||||||
line_spacing = 9,
|
|
||||||
font_size = 31,
|
|
||||||
x_offset = 7,
|
|
||||||
y_offset = 4,
|
|
||||||
chars_per_line = 40,
|
|
||||||
entity_info = "standard"
|
|
||||||
})
|
|
||||||
|
|
||||||
* default def assumes a wallmounted sign with on-pole being allowed.
|
|
||||||
|
|
||||||
*For signs that can't support onpole, include in the def:
|
|
||||||
allow_onpole = false,
|
|
||||||
|
|
||||||
* "standard" entity info implies the standard wood/steel sign model, in
|
|
||||||
wallmounted mode. For facedir signs using the standard model, use:
|
|
||||||
|
|
||||||
entity_info = {
|
|
||||||
mesh = "signs_lib_standard_wall_sign_entity.obj",
|
|
||||||
yaw = signs_lib.standard_yaw
|
|
||||||
},
|
|
||||||
|
|
||||||
]]--
|
|
||||||
|
|
||||||
function signs_lib.register_sign(name, rdef)
|
|
||||||
|
|
||||||
local def = table.copy(rdef)
|
local def = table.copy(rdef)
|
||||||
|
|
||||||
if rdef.entity_info == "standard" then
|
if rdef.entity_info == "standard" then
|
||||||
@ -698,6 +688,8 @@ function signs_lib.register_sign(name, rdef)
|
|||||||
def.entity_info = rdef.entity_info
|
def.entity_info = rdef.entity_info
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def.after_place_node = rdef.after_place_node or signs_lib.after_place_node
|
||||||
|
|
||||||
if rdef.entity_info then
|
if rdef.entity_info then
|
||||||
def.on_rightclick = rdef.on_rightclick or signs_lib.construct_sign
|
def.on_rightclick = rdef.on_rightclick or signs_lib.construct_sign
|
||||||
def.on_construct = rdef.on_construct or signs_lib.construct_sign
|
def.on_construct = rdef.on_construct or signs_lib.construct_sign
|
||||||
@ -717,8 +709,6 @@ function signs_lib.register_sign(name, rdef)
|
|||||||
def.after_place_node = function(pos, placer, itemstack, pointed_thing)
|
def.after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, true)
|
signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, true)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
def.after_place_node = rdef.after_place_node or signs_lib.after_place_node
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -819,7 +809,58 @@ function signs_lib.register_sign(name, rdef)
|
|||||||
minetest.register_node(":"..name.."_hanging", hdef)
|
minetest.register_node(":"..name.."_hanging", hdef)
|
||||||
table.insert(signs_lib.lbm_restore_nodes, name.."_hanging")
|
table.insert(signs_lib.lbm_restore_nodes, name.."_hanging")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
The main sign registration function
|
||||||
|
===================================
|
||||||
|
|
||||||
|
Example minimal recommended def for writable signs:
|
||||||
|
|
||||||
|
signs_lib.register_sign("foo:my_cool_sign", {
|
||||||
|
description = "Wooden cool sign",
|
||||||
|
inventory_image = "signs_lib_sign_cool_inv.png",
|
||||||
|
tiles = {
|
||||||
|
"signs_lib_sign_cool.png",
|
||||||
|
"signs_lib_sign_cool_edges.png"
|
||||||
|
},
|
||||||
|
number_of_lines = 2,
|
||||||
|
horiz_scaling = 0.8,
|
||||||
|
vert_scaling = 1,
|
||||||
|
line_spacing = 9,
|
||||||
|
font_size = 31,
|
||||||
|
x_offset = 7,
|
||||||
|
y_offset = 4,
|
||||||
|
chars_per_line = 40,
|
||||||
|
entity_info = "standard"
|
||||||
|
})
|
||||||
|
|
||||||
|
* default def assumes a wallmounted sign with on-pole being allowed.
|
||||||
|
|
||||||
|
*For signs that can't support onpole, include in the def:
|
||||||
|
allow_onpole = false,
|
||||||
|
|
||||||
|
* "standard" entity info implies the standard wood/steel sign model, in
|
||||||
|
wallmounted mode. For facedir signs using the standard model, use:
|
||||||
|
|
||||||
|
entity_info = {
|
||||||
|
mesh = "signs_lib_standard_wall_sign_entity.obj",
|
||||||
|
yaw = signs_lib.standard_yaw
|
||||||
|
},
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
function signs_lib.register_sign(name, rdef)
|
||||||
|
register_sign(name, rdef)
|
||||||
|
|
||||||
|
if rdef.allow_widefont then
|
||||||
|
|
||||||
|
wdef = table.copy(minetest.registered_items[name])
|
||||||
|
wdef.groups.not_in_creative_inventory = 1
|
||||||
|
wdef.horiz_scaling = wdef.horiz_scaling / 2
|
||||||
|
|
||||||
|
register_sign(name.."_widefont", wdef)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- restore signs' text after /clearobjects and the like, the next time
|
-- restore signs' text after /clearobjects and the like, the next time
|
||||||
@ -856,12 +897,7 @@ minetest.register_lbm({
|
|||||||
local oldfence = signs_lib.old_fenceposts[node.name]
|
local oldfence = signs_lib.old_fenceposts[node.name]
|
||||||
local newsign = signs_lib.old_fenceposts_replacement_signs[node.name]
|
local newsign = signs_lib.old_fenceposts_replacement_signs[node.name]
|
||||||
|
|
||||||
for _, v in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do
|
signs_lib.delete_objects(pos)
|
||||||
local e = v:get_luaentity()
|
|
||||||
if e and e.name == "signs_lib:text" then
|
|
||||||
v:remove()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local oldmeta = minetest.get_meta(pos):to_table()
|
local oldmeta = minetest.get_meta(pos):to_table()
|
||||||
minetest.set_node(pos, {name = oldfence})
|
minetest.set_node(pos, {name = oldfence})
|
||||||
@ -924,12 +960,7 @@ minetest.register_chatcommand("regen_signs", {
|
|||||||
|
|
||||||
for _, b in pairs(allsigns) do
|
for _, b in pairs(allsigns) do
|
||||||
for _, pos in ipairs(b) do
|
for _, pos in ipairs(b) do
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
signs_lib.delete_objects(pos)
|
||||||
if #objects > 0 then
|
|
||||||
for _, v in ipairs(objects) do
|
|
||||||
v:remove()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local def = minetest.registered_items[node.name]
|
local def = minetest.registered_items[node.name]
|
||||||
if def and def.entity_info then
|
if def and def.entity_info then
|
||||||
|
@ -9,6 +9,7 @@ signs_lib.register_sign("default:sign_wall_wood", {
|
|||||||
},
|
},
|
||||||
entity_info = "standard",
|
entity_info = "standard",
|
||||||
allow_hanging = true,
|
allow_hanging = true,
|
||||||
|
allow_widefont = true
|
||||||
})
|
})
|
||||||
|
|
||||||
signs_lib.register_sign("default:sign_wall_steel", {
|
signs_lib.register_sign("default:sign_wall_steel", {
|
||||||
@ -23,6 +24,7 @@ signs_lib.register_sign("default:sign_wall_steel", {
|
|||||||
locked = true,
|
locked = true,
|
||||||
entity_info = "standard",
|
entity_info = "standard",
|
||||||
allow_hanging = true,
|
allow_hanging = true,
|
||||||
|
allow_widefont = true
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_alias("signs:sign_hanging", "default:sign_wall_wood_hanging")
|
minetest.register_alias("signs:sign_hanging", "default:sign_wall_wood_hanging")
|
||||||
|
BIN
textures/signs_lib_switch_interm.png
Normal file
BIN
textures/signs_lib_switch_interm.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
BIN
textures/signs_lib_switch_off.png
Normal file
BIN
textures/signs_lib_switch_off.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
BIN
textures/signs_lib_switch_on.png
Normal file
BIN
textures/signs_lib_switch_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
Reference in New Issue
Block a user