signs_lib.modpath = minetest.get_modpath("signs_lib")
+local DEFAULT_TEXT_SCALE = {x=0.8, y=0.5}
+
signs_lib.regular_wall_sign_model = {
nodebox = {
type = "wallmounted",
-- the list of standard sign nodes
signs_lib.sign_node_list = {
- "default:sign_wall_wood",
- "signs:sign_yard",
- "signs:sign_hanging",
- "signs:sign_wall_green",
- "signs:sign_wall_yellow",
- "signs:sign_wall_red",
- "signs:sign_wall_white_red",
- "signs:sign_wall_white_black",
- "signs:sign_wall_orange",
- "signs:sign_wall_blue",
- "signs:sign_wall_brown",
- "locked_sign:sign_wall_locked"
+ "default:sign_wall_wood",
+ "default:sign_wall_steel",
+ "signs:sign_yard",
+ "signs:sign_hanging",
+ "signs:sign_wall_green",
+ "signs:sign_wall_yellow",
+ "signs:sign_wall_red",
+ "signs:sign_wall_white_red",
+ "signs:sign_wall_white_black",
+ "signs:sign_wall_orange",
+ "signs:sign_wall_blue",
+ "signs:sign_wall_brown",
+ "locked_sign:sign_wall_locked"
}
local default_sign, default_sign_image
-- infinite stacks
-if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
+if not minetest.setting_getbool("creative_mode") then
signs_lib.expect_infinite_stacks = false
else
signs_lib.expect_infinite_stacks = true
-- Path to the textures.
local TP = MP.."/textures"
-local TEXT_SCALE = {x=0.8, y=0.5}
-
-- Lots of overkill here. KISS advocates, go away, shoo! ;) -- kaeza
local PNG_HDR = string.char(0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A)
return table.concat(tex)
end
-local function make_line_texture(line, lineno)
+local function make_line_texture(line, lineno, pos)
local width = 0
local maxw = 0
local words = { }
+ local n = minetest.registered_nodes[minetest.get_node(pos).name]
+ local defaultcolor = n.defaultcolor or 0
- local cur_color = 0
+ local cur_color = tonumber(defaultcolor, 16)
-- We check which chars are available here.
for word_i, word in ipairs(line) do
return table.concat(texture), lineno
end
-local function make_sign_texture(lines)
+local function make_sign_texture(lines, pos)
local texture = { ("[combine:%dx%d"):format(SIGN_WIDTH, LINE_HEIGHT * NUMBER_OF_LINES) }
local lineno = 0
for i = 1, #lines do
if lineno >= NUMBER_OF_LINES then break end
- local linetex, ln = make_line_texture(lines[i], lineno)
+ local linetex, ln = make_line_texture(lines[i], lineno, pos)
table.insert(texture, linetex)
lineno = ln + 1
end
return table.concat(texture, "")
end
-local function set_obj_text(obj, text, new)
+local function set_obj_text(obj, text, new, pos)
local split = new and split_lines_and_words or split_lines_and_words_old
+ local n = minetest.registered_nodes[minetest.get_node(pos).name]
+ local text_scale = n.text_scale or DEFAULT_TEXT_SCALE
obj:set_properties({
- textures={make_sign_texture(split(text))},
- visual_size = TEXT_SCALE,
+ textures={make_sign_texture(split(text), pos)},
+ visual_size = text_scale,
})
end
if found then
v:remove()
else
- set_obj_text(v, text, new)
+ set_obj_text(v, text, new, pos)
found = true
end
end
-- metal, colored signs
local sign_colors = { "green", "yellow", "red", "white_red", "white_black", "orange", "blue", "brown" }
+local sign_default_text_colors = { "f", "0", "f", "4", "0", "0", "f", "f" }
-for _, color in ipairs(sign_colors) do
+for i, color in ipairs(sign_colors) do
minetest.register_node(":signs:sign_wall_"..color, {
description = S("Sign ("..color..", metal)"),
inventory_image = "signs_"..color.."_inv.png",
"signs_metal_back.png",
"signs_"..color.."_front.png"
},
+ defaultcolor = sign_default_text_colors[i],
groups = sign_groups,
on_place = function(itemstack, placer, pointed_thing)
return signs_lib.determine_sign_type(itemstack, placer, pointed_thing)
local signs_text_on_activate
signs_text_on_activate = function(self)
- local meta = minetest.get_meta(self.object:getpos())
+ local pos = self.object:getpos()
+ local meta = minetest.get_meta(pos)
local text = meta:get_string("text")
local new = (meta:get_int("__signslib_new_format") ~= 0)
if text then
text = trim_input(text)
- set_obj_text(self.object, text, new)
+ set_obj_text(self.object, text, new, pos)
end
end
}
})
---Alternate recipes.
+--Alternate recipe
minetest.register_craft({
output = "locked_sign:sign_wall_locked",
},
})
-minetest.register_craft({
- output = "locked_sign:sign_wall_locked",
- recipe = {
- {default_sign_metal},
- {"default:steel_ingot"},
- },
-})
-
-- craft recipes for the metal signs
minetest.register_craft( {