summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2017-10-19 14:18:07 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2017-10-19 14:18:07 +0200
commit43b7ce7fec111a8d9424c5def4ebe965a36eab31 (patch)
treeee627f2c75c8469318320f9b6bdde8900de3fd2f
parent6ae47a6dac7bd4698265eca815a30313105f6026 (diff)
parenta06627f23b052207d3fc23d786c525f2cd26096c (diff)
downloadsigns_lib-master.zip
signs_lib-master.tar.gz
signs_lib-master.tar.bz2
Merged macro functionsHEADmaster
-rw-r--r--depends.txt1
-rw-r--r--init.lua484
-rw-r--r--intllib.lua45
-rw-r--r--locale/de.po92
-rw-r--r--locale/de.txt9
-rw-r--r--locale/es.po95
-rw-r--r--locale/fr.po91
-rw-r--r--locale/template.pot90
-rw-r--r--locale/template.txt9
-rw-r--r--macro.lua48
-rw-r--r--textures/signs_wall_sign_metal.pngbin0 -> 553 bytes
11 files changed, 747 insertions, 217 deletions
diff --git a/depends.txt b/depends.txt
index abb8bd5..7f4e061 100644
--- a/depends.txt
+++ b/depends.txt
@@ -2,3 +2,4 @@ default
intllib?
screwdriver?
keyword_interact?
+craft_guide?
diff --git a/init.lua b/init.lua
index e8ed065..5ca2a46 100644
--- a/init.lua
+++ b/init.lua
@@ -9,9 +9,13 @@
-- { delta = {entity position for 270° yaw}, exact yaw expression }
-- { delta = {entity position for 90° yaw}, exact yaw expression }
-- }
+-- Made colored metal signs optionals
+local enable_colored_metal_signs = true
-- CWz's keyword interact mod uses this setting.
-local current_keyword = minetest.setting_get("interact_keyword") or "iaccept"
+local current_keyword = minetest.settings:get("interact_keyword") or "iaccept"
+
+local replace_macros = dofile(minetest.get_modpath(minetest.get_current_modname())..DIR_DELIM.."macro.lua")
signs_lib = {}
screwdriver = screwdriver or {}
@@ -31,6 +35,8 @@ end
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",
@@ -41,10 +47,10 @@ signs_lib.regular_wall_sign_model = {
textpos = {
nil,
nil,
- {delta = {x = 0.43, y = 0.07, z = 0 }, yaw = math.pi / -2},
- {delta = {x = -0.43, y = 0.07, z = 0 }, yaw = math.pi / 2},
- {delta = {x = 0, y = 0.07, z = 0.43 }, yaw = 0},
- {delta = {x = 0, y = 0.07, z = -0.43 }, yaw = math.pi},
+ {delta = { x = 0.41, y = 0.07, z = 0 }, yaw = math.pi / -2},
+ {delta = { x = -0.41, y = 0.07, z = 0 }, yaw = math.pi / 2},
+ {delta = { x = 0, y = 0.07, z = 0.41 }, yaw = 0},
+ {delta = { x = 0, y = 0.07, z = -0.41 }, yaw = math.pi},
}
}
@@ -54,10 +60,10 @@ signs_lib.metal_wall_sign_model = {
fixed = {-0.4375, -0.25, 0.4375, 0.4375, 0.375, 0.5}
},
textpos = {
- {delta = {x = 0, y = 0.07, z = 0.43 }, yaw = 0},
- {delta = {x = 0.43, y = 0.07, z = 0 }, yaw = math.pi / -2},
- {delta = {x = 0, y = 0.07, z = -0.43 }, yaw = math.pi},
- {delta = {x = -0.43, y = 0.07, z = 0 }, yaw = math.pi / 2},
+ {delta = { x = 0, y = 0.07, z = 0.41 }, yaw = 0},
+ {delta = { x = 0.41, y = 0.07, z = 0 }, yaw = math.pi / -2},
+ {delta = { x = 0, y = 0.07, z = -0.41 }, yaw = math.pi},
+ {delta = { x = -0.41, y = 0.07, z = 0 }, yaw = math.pi / 2},
}
}
@@ -83,10 +89,10 @@ signs_lib.yard_sign_model = {
}
},
textpos = {
- {delta = {x = 0, y = 0.07, z = -0.068}, yaw = 0},
- {delta = {x = -0.068, y = 0.07, z = 0 }, yaw = math.pi / -2},
- {delta = {x = 0, y = 0.07, z = 0.068}, yaw = math.pi},
- {delta = {x = 0.068, y = 0.07, z = 0 }, yaw = math.pi / 2},
+ {delta = { x = 0, y = 0.07, z = -0.08 }, yaw = 0},
+ {delta = { x = -0.08, y = 0.07, z = 0 }, yaw = math.pi / -2},
+ {delta = { x = 0, y = 0.07, z = 0.08 }, yaw = math.pi},
+ {delta = { x = 0.08, y = 0.07, z = 0 }, yaw = math.pi / 2},
}
}
@@ -99,10 +105,10 @@ signs_lib.hanging_sign_model = {
}
},
textpos = {
- {delta = {x = 0, y = -0.02, z = -0.063}, yaw = 0},
- {delta = {x = -0.063, y = -0.02, z = 0 }, yaw = math.pi / -2},
- {delta = {x = 0, y = -0.02, z = 0.063}, yaw = math.pi},
- {delta = {x = 0.063, y = -0.02, z = 0 }, yaw = math.pi / 2},
+ {delta = { x = 0, y = -0.02, z = -0.08 }, yaw = 0},
+ {delta = { x = -0.08, y = -0.02, z = 0 }, yaw = math.pi / -2},
+ {delta = { x = 0, y = -0.02, z = 0.08 }, yaw = math.pi},
+ {delta = { x = 0.08, y = -0.02, z = 0 }, yaw = math.pi / 2},
}
}
@@ -115,32 +121,34 @@ signs_lib.sign_post_model = {
}
},
textpos = {
- {delta = {x = 0, y = 0.07, z = -0.188}, yaw = 0},
- {delta = {x = -0.188, y = 0.07, z = 0 }, yaw = math.pi / -2},
- {delta = {x = 0, y = 0.07, z = 0.188 }, yaw = math.pi},
- {delta = {x = 0.188, y = 0.07, z = 0 }, yaw = math.pi / 2},
+ {delta = { x = 0, y = 0.07, z = -0.2 }, yaw = 0},
+ {delta = { x = -0.2, y = 0.07, z = 0 }, yaw = math.pi / -2},
+ {delta = { x = 0, y = 0.07, z = 0.2 }, yaw = math.pi},
+ {delta = { x = 0.2, y = 0.07, z = 0 }, yaw = math.pi / 2},
}
}
--- Boilerplate to support localized strings if intllib mod is installed.
-local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
+-- Load support for intllib.
+local MP = minetest.get_modpath(minetest.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
signs_lib.gettext = S
-- 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
@@ -154,6 +162,9 @@ else
default_sign_image = "default_sign_wall.png"
end
+default_sign_metal = "default:sign_wall_steel"
+default_sign_metal_image = "default_sign_steel.png"
+
--table copy
function signs_lib.table_copy(t)
@@ -170,7 +181,7 @@ end
-- infinite stacks
-if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
+if not minetest.settings:get_bool("creative_mode") then
signs_lib.expect_infinite_stacks = false
else
signs_lib.expect_infinite_stacks = true
@@ -189,8 +200,6 @@ local FONT_FMT_SIMPLE = "hdf_%02x.png"
-- 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)
@@ -296,6 +305,7 @@ end
local function split_lines_and_words(text)
if not text then return end
text = string.gsub(text, "@KEYWORD", current_keyword)
+ text = replace_macros(text)
local lines = { }
for _, line in ipairs(text:split("\n")) do
table.insert(lines, line:split(" "))
@@ -314,14 +324,16 @@ local function fill_line(x, y, w, c)
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 default_color = n.default_color or 0
- local cur_color = 0
+ local cur_color = tonumber(default_color, 16)
-- We check which chars are available here.
for word_i, word in ipairs(line) do
@@ -402,12 +414,12 @@ local function make_line_texture(line, lineno)
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
@@ -415,11 +427,13 @@ local function make_sign_texture(lines)
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 and 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
@@ -476,7 +490,7 @@ signs_lib.update_sign = function(pos, fields, owner)
signs_lib.destruct_sign(pos)
meta:set_string("keyword", current_keyword)
local ownstr = ""
- if owner then ownstr = "Locked sign, owned by "..owner.."\n" end
+ if owner then ownstr = S("Locked sign, owned by @1\n", owner) end
meta:set_string("infotext", ownstr..string.gsub(make_infotext(stored_text), "@KEYWORD", current_keyword).." ")
end
end
@@ -488,7 +502,7 @@ signs_lib.update_sign = function(pos, fields, owner)
fields.text = trim_input(fields.text)
local ownstr = ""
- if owner then ownstr = "Locked sign, owned by "..owner.."\n" end
+ if owner then ownstr = S("Locked sign, owned by @1\n", owner) end
meta:set_string("infotext", ownstr..string.gsub(make_infotext(fields.text), "@KEYWORD", current_keyword).." ")
meta:set_string("text", fields.text)
@@ -508,7 +522,7 @@ signs_lib.update_sign = function(pos, fields, owner)
if found then
v:remove()
else
- set_obj_text(v, text, new)
+ set_obj_text(v, text, new, pos)
found = true
end
end
@@ -520,12 +534,17 @@ signs_lib.update_sign = function(pos, fields, owner)
-- if there is no entity
local sign_info
local signnode = minetest.get_node(pos)
- if signnode.name == "signs:sign_yard" then
+ local signname = signnode.name
+ local textpos = minetest.registered_nodes[signname].textpos
+ if textpos then
+ sign_info = textpos[minetest.get_node(pos).param2 + 1]
+ elseif signnode.name == "signs:sign_yard" then
sign_info = signs_lib.yard_sign_model.textpos[minetest.get_node(pos).param2 + 1]
elseif signnode.name == "signs:sign_hanging" then
sign_info = signs_lib.hanging_sign_model.textpos[minetest.get_node(pos).param2 + 1]
elseif string.find(signnode.name, "sign_wall") or string.find(signnode.name, "sign_subway") then
if signnode.name == default_sign
+ or signnode.name == default_sign_metal
or signnode.name == "locked_sign:sign_wall_locked" then
sign_info = signs_lib.regular_wall_sign_model.textpos[minetest.get_node(pos).param2 + 1]
else
@@ -569,8 +588,10 @@ function signs_lib.determine_sign_type(itemstack, placer, pointed_thing, locked)
local node=minetest.get_node(pointed_thing.under)
- if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
- return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
+ if minetest.registered_nodes[node.name] and
+ minetest.registered_nodes[node.name].on_rightclick and
+ not placer:get_player_control().sneak then
+ return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack, pointed_thing)
else
local above = pointed_thing.above
local under = pointed_thing.under
@@ -590,7 +611,6 @@ function signs_lib.determine_sign_type(itemstack, placer, pointed_thing, locked)
end
local fdir = minetest.dir_to_facedir(dir)
-
local pt_name = minetest.get_node(under).name
local signname = itemstack:get_name()
@@ -600,8 +620,11 @@ function signs_lib.determine_sign_type(itemstack, placer, pointed_thing, locked)
minetest.add_node(above, {name = "signs:sign_hanging", param2 = fdir})
elseif wdir == 1 and signname == default_sign then
minetest.add_node(above, {name = "signs:sign_yard", param2 = fdir})
+ elseif signname == default_sign_metal then
+ minetest.add_node(above, {name = signname, param2 = wdir })
elseif signname ~= default_sign
- and signname ~= "locked_sign:sign_wall_locked" then -- it's a metal wall sign.
+ and signname ~= default_sign_metal
+ and signname ~= "locked_sign:sign_wall_locked" then -- it's a signs_lib colored metal wall sign.
minetest.add_node(above, {name = signname, param2 = fdir})
else -- it must be a default or locked wooden wall sign
minetest.add_node(above, {name = signname, param2 = wdir }) -- note it's wallmounted here!
@@ -625,11 +648,12 @@ function signs_lib.receive_fields(pos, formname, fields, sender, lock)
sender:get_player_name())
return
end
- local lockstr = lock and "locked " or ""
+ local lockstr = lock and S("locked ") or ""
if fields and fields.text and fields.ok then
- minetest.log("action", S("%s wrote \"%s\" to "..lockstr.."sign at %s"):format(
+ minetest.log("action", S("@1 wrote \"@2\" to @3sign at @4",
(sender:get_player_name() or ""),
fields.text,
+ lockstr,
minetest.pos_to_string(pos)
))
if lock then
@@ -760,10 +784,10 @@ minetest.register_node(":signs:sign_post", {
-- Locked wall sign
-minetest.register_privilege("sign_editor", "Can edit all locked signs")
+minetest.register_privilege("sign_editor", S("Can edit all locked signs"))
minetest.register_node(":locked_sign:sign_wall_locked", {
- description = S("Sign"),
+ description = S("Locked Sign"),
inventory_image = "signs_locked_inv.png",
wield_image = "signs_locked_inv.png",
node_placement_prediction = "",
@@ -787,7 +811,7 @@ minetest.register_node(":locked_sign:sign_wall_locked", {
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local pname = sender:get_player_name() or ""
- if pname ~= owner and pname ~= minetest.setting_get("name")
+ if pname ~= owner and pname ~= minetest.settings:get("name")
and not minetest.check_player_privs(pname, {sign_editor=true}) then
return
end
@@ -800,38 +824,36 @@ minetest.register_node(":locked_sign:sign_wall_locked", {
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local pname = player:get_player_name()
- return pname == owner or pname == minetest.setting_get("name")
+ return pname == owner or pname == minetest.settings:get("name")
or minetest.check_player_privs(pname, {sign_editor=true})
end,
on_rotate = signs_lib.wallmounted_rotate
})
+
-- metal, colored signs
local sign_colors = { "green", "yellow", "red", "white_red",
"white_black", "orange", "blue", "brown" , "blue_ahead", "blue_left",
"blue_right", "blue_bidi"}
-for _, color in ipairs(sign_colors) do
- minetest.register_node(":signs:sign_wall_"..color, {
- description = S("Sign ("..color..", metal)"),
- inventory_image = "signs_"..color.."_inv.png",
- wield_image = "signs_"..color.."_inv.png",
+-- default metal sign, if defined
+
+
+if minetest.registered_nodes["default:sign_wall_steel"] then
+ minetest.register_node(":"..default_sign_metal, {
+ description = S("Sign"),
+ inventory_image = default_sign_metal_image,
+ wield_image = default_sign_metal_image,
node_placement_prediction = "",
- paramtype = "light",
sunlight_propagates = true,
- paramtype2 = "facedir",
+ paramtype = "light",
+ paramtype2 = "wallmounted",
drawtype = "nodebox",
- node_box = signs_lib.metal_wall_sign_model.nodebox,
- tiles = {
- "signs_metal_tb.png",
- "signs_metal_tb.png",
- "signs_metal_sides.png",
- "signs_metal_sides.png",
- "signs_metal_back.png",
- "signs_"..color.."_front.png"
- },
+ node_box = signs_lib.regular_wall_sign_model.nodebox,
+ tiles = {"signs_wall_sign_metal.png"},
groups = sign_groups,
+
on_place = function(itemstack, placer, pointed_thing)
return signs_lib.determine_sign_type(itemstack, placer, pointed_thing)
end,
@@ -847,6 +869,7 @@ for _, color in ipairs(sign_colors) do
on_punch = function(pos, node, puncher)
signs_lib.update_sign(pos)
end,
+ on_rotate = signs_lib.wallmounted_rotate
})
end
local line_cols = {"red","cyan","blue","green","violet","orange","yellow","gray"}
@@ -888,15 +911,74 @@ for _, color in ipairs(line_cols) do
})
end
+-- metal, colored signs
+if enable_colored_metal_signs then
+ -- array : color, translated color, default text color
+ local sign_colors = {
+ {"green", S("green"), "f"},
+ {"yellow", S("yellow"), "0"},
+ {"red", S("red"), "f"},
+ {"white_red", S("white_red"), "4"},
+ {"white_black", S("white_black"), "0"},
+ {"orange", S("orange"), "0"},
+ {"blue", S("blue"), "f"},
+ {"blue_ahead", S("blue, ahead"), "f"},
+ {"blue_bidi", S("blue, both directions"), "f"},
+ {"blue_left", S("blue, left"), "f"},
+ {"blue_right", S("blue, right"), "f"},
+ {"brown", S("brown"), "f"},
+ }
+
+ for i, color in ipairs(sign_colors) do
+ minetest.register_node(":signs:sign_wall_"..color[1], {
+ description = S("Sign (@1, metal)", color[2]),
+ inventory_image = "signs_"..color[1].."_inv.png",
+ wield_image = "signs_"..color[1].."_inv.png",
+ node_placement_prediction = "",
+ paramtype = "light",
+ sunlight_propagates = true,
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = signs_lib.metal_wall_sign_model.nodebox,
+ tiles = {
+ "signs_metal_tb.png",
+ "signs_metal_tb.png",
+ "signs_metal_sides.png",
+ "signs_metal_sides.png",
+ "signs_metal_back.png",
+ "signs_"..color[1].."_front.png"
+ },
+ default_color = color[3],
+ groups = sign_groups,
+ on_place = function(itemstack, placer, pointed_thing)
+ return signs_lib.determine_sign_type(itemstack, placer, pointed_thing)
+ end,
+ on_construct = function(pos)
+ signs_lib.construct_sign(pos)
+ end,
+ on_destruct = function(pos)
+ signs_lib.destruct_sign(pos)
+ end,
+ on_receive_fields = function(pos, formname, fields, sender)
+ signs_lib.receive_fields(pos, formname, fields, sender)
+ end,
+ on_punch = function(pos, node, puncher)
+ signs_lib.update_sign(pos)
+ end,
+ })
+ end
+end
+
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
@@ -914,7 +996,7 @@ function signs_lib.register_fence_with_sign(fencename, fencewithsignname)
local def = minetest.registered_nodes[fencename]
local def_sign = minetest.registered_nodes[fencewithsignname]
if not (def and def_sign) then
- minetest.log("warning", "[signs_lib] Attempt to register unknown node as fence")
+ minetest.log("warning", "[signs_lib] "..S("Attempt to register unknown node as fence"))
return
end
def = signs_lib.table_copy(def)
@@ -940,7 +1022,7 @@ function signs_lib.register_fence_with_sign(fencename, fencewithsignname)
end
if def_under and def_under.on_rightclick then
- return def_under.on_rightclick(pointed_thing.under, node_under, placer, itemstack) or itemstack
+ return def_under.on_rightclick(pointed_thing.under, node_under, placer, itemstack, pointed_thing) or itemstack
elseif def_under and def_under.buildable_to then
minetest.add_node(pointed_thing.under, {name = fencename, param2 = fdir})
if not signs_lib.expect_infinite_stacks then
@@ -977,7 +1059,7 @@ function signs_lib.register_fence_with_sign(fencename, fencewithsignname)
minetest.register_node(":"..fencename, def)
minetest.register_node(":"..fencewithsignname, def_sign)
table.insert(signs_lib.sign_node_list, fencewithsignname)
- minetest.log("verbose", S("Registered %s and %s"):format(fencename, fencewithsignname))
+ minetest.log("verbose", S("Registered @1 and @2", fencename, fencewithsignname))
end
build_char_db()
@@ -987,13 +1069,15 @@ minetest.register_alias("sign_wall_locked", "locked_sign:sign_wall_locked")
signs_lib.register_fence_with_sign("default:fence_wood", "signs:sign_post")
--- restore signs' text after /clearobjects and the like
+-- restore signs' text after /clearobjects and the like, the next time
+-- a block is reloaded by the server.
-minetest.register_abm({
+minetest.register_lbm({
nodenames = signs_lib.sign_node_list,
- interval = 15,
- chance = 1,
- action = function(pos, node, active_object_count, active_object_count_wider)
+ name = "signs_lib:restore_sign_text",
+ label = "Restore sign text",
+ run_at_every_load = true,
+ action = function(pos, node)
signs_lib.update_sign(pos)
end
})
@@ -1042,135 +1126,137 @@ minetest.register_craft({
})
-- craft recipes for the metal signs
+if enable_colored_metal_signs then
-minetest.register_craft( {
- output = "signs:sign_wall_green 4",
- recipe = {
- { "dye:dark_green", "dye:white", "dye:dark_green" },
- { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_green",
+ recipe = {
+ { "dye:dark_green", "dye:white", "dye:dark_green" },
+ { "", default_sign_metal, "" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_green 2",
- recipe = {
- { "dye:dark_green", "dye:white", "dye:dark_green" },
- { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_green 2",
+ recipe = {
+ { "dye:dark_green", "dye:white", "dye:dark_green" },
+ { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_yellow 4",
- recipe = {
- { "dye:yellow", "dye:black", "dye:yellow" },
- { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_yellow",
+ recipe = {
+ { "dye:yellow", "dye:black", "dye:yellow" },
+ { "", default_sign_metal, "" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_yellow 2",
- recipe = {
- { "dye:yellow", "dye:black", "dye:yellow" },
- { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_yellow 2",
+ recipe = {
+ { "dye:yellow", "dye:black", "dye:yellow" },
+ { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_red 4",
- recipe = {
- { "dye:red", "dye:white", "dye:red" },
- { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_red",
+ recipe = {
+ { "dye:red", "dye:white", "dye:red" },
+ { "", default_sign_metal, "" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_red 2",
- recipe = {
- { "dye:red", "dye:white", "dye:red" },
- { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_red 2",
+ recipe = {
+ { "dye:red", "dye:white", "dye:red" },
+ { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_white_red 4",
- recipe = {
- { "dye:white", "dye:red", "dye:white" },
- { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_white_red",
+ recipe = {
+ { "dye:white", "dye:red", "dye:white" },
+ { "", default_sign_metal, "" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_white_red 2",
- recipe = {
- { "dye:white", "dye:red", "dye:white" },
- { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_white_red 2",
+ recipe = {
+ { "dye:white", "dye:red", "dye:white" },
+ { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_white_black 4",
- recipe = {
- { "dye:white", "dye:black", "dye:white" },
- { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_white_black",
+ recipe = {
+ { "dye:white", "dye:black", "dye:white" },
+ { "", default_sign_metal, "" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_white_black 2",
- recipe = {
- { "dye:white", "dye:black", "dye:white" },
- { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_white_black 2",
+ recipe = {
+ { "dye:white", "dye:black", "dye:white" },
+ { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_orange 4",
- recipe = {
- { "dye:orange", "dye:black", "dye:orange" },
- { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_orange",
+ recipe = {
+ { "dye:orange", "dye:black", "dye:orange" },
+ { "", default_sign_metal, "" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_orange 2",
- recipe = {
- { "dye:orange", "dye:black", "dye:orange" },
- { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_orange 2",
+ recipe = {
+ { "dye:orange", "dye:black", "dye:orange" },
+ { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_blue 4",
- recipe = {
- { "dye:blue", "dye:white", "dye:blue" },
- { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_blue",
+ recipe = {
+ { "dye:blue", "dye:white", "dye:blue" },
+ { "", default_sign_metal, "" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_blue 2",
- recipe = {
- { "dye:blue", "dye:white", "dye:blue" },
- { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_blue 2",
+ recipe = {
+ { "dye:blue", "dye:white", "dye:blue" },
+ { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_brown 4",
- recipe = {
- { "dye:brown", "dye:white", "dye:brown" },
- { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_brown",
+ recipe = {
+ { "dye:brown", "dye:white", "dye:brown" },
+ { "", default_sign_metal, "" }
+ },
+ })
-minetest.register_craft( {
- output = "signs:sign_wall_brown 2",
- recipe = {
- { "dye:brown", "dye:white", "dye:brown" },
- { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
- },
-})
+ minetest.register_craft( {
+ output = "signs:sign_wall_brown 2",
+ recipe = {
+ { "dye:brown", "dye:white", "dye:brown" },
+ { "steel:sheet_metal", "steel:sheet_metal", "steel:sheet_metal" }
+ },
+ })
+end
-if minetest.setting_get("log_mods") then
- minetest.log("action", S("signs loaded"))
+if minetest.settings:get("log_mods") then
+ minetest.log("action", S("[MOD] signs loaded"))
end
diff --git a/intllib.lua b/intllib.lua
new file mode 100644
index 0000000..6669d72
--- /dev/null
+++ b/intllib.lua
@@ -0,0 +1,45 @@
+
+-- Fallback functions for when `intllib` is not installed.
+-- Code released under Unlicense <http://unlicense.org>.
+
+-- Get the latest version of this file at:
+-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
+
+local function format(str, ...)
+ local args = { ... }
+ local function repl(escape, open, num, close)
+ if escape == "" then
+ local replacement = tostring(args[tonumber(num)])
+ if open == "" then
+ replacement = replacement..close
+ end
+ return replacement
+ else
+ return "@"..open..num..close
+ end
+ end
+ return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
+end
+
+local gettext, ngettext
+if minetest.get_modpath("intllib") then
+ if intllib.make_gettext_pair then
+ -- New method using gettext.
+ gettext, ngettext = intllib.make_gettext_pair()
+ else
+ -- Old method using text files.
+ gettext = intllib.Getter()
+ end
+end
+
+-- Fill in missing functions.
+
+gettext = gettext or function(msgid, ...)
+ return format(msgid, ...)
+end
+
+ngettext = ngettext or function(msgid, msgid_plural, n, ...)
+ return format(n==1 and msgid or msgid_plural, ...)
+end
+
+return gettext, ngettext
diff --git a/locale/de.po b/locale/de.po
new file mode 100644
index 0000000..24f13a4
--- /dev/null
+++ b/locale/de.po
@@ -0,0 +1,92 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-07-31 18:31+0200\n"
+"PO-Revision-Date: 2017-07-31 18:35+0200\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.12\n"
+"Last-Translator: Xanthin\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"Language: de\n"
+
+#: init.lua
+msgid "Locked sign, owned by @1\n"
+msgstr ""
+
+#: init.lua
+msgid "locked "
+msgstr "eingesperrt "
+
+#: init.lua
+#, fuzzy
+msgid "@1 wrote \"@2\" to @3sign at @4"
+msgstr "@1 schrieb \"@2\" auf das @3Schild bei @4"
+
+#: init.lua
+msgid "Sign"
+msgstr "Schild"
+
+#: init.lua
+msgid "Can edit all locked signs"
+msgstr ""
+
+#: init.lua
+msgid "Locked Sign"
+msgstr ""
+
+#: init.lua
+msgid "green"
+msgstr ""
+
+#: init.lua
+msgid "yellow"
+msgstr ""
+
+#: init.lua
+msgid "red"
+msgstr ""
+
+#: init.lua
+msgid "white_red"
+msgstr ""
+
+#: init.lua
+msgid "white_black"
+msgstr ""
+
+#: init.lua
+msgid "orange"
+msgstr ""
+
+#: init.lua
+msgid "blue"
+msgstr ""
+
+#: init.lua
+msgid "brown"
+msgstr ""
+
+#: init.lua
+msgid "Sign (@1, metal)"
+msgstr "Schild (@1, Metall)"
+
+#: init.lua
+msgid "Attempt to register unknown node as fence"
+msgstr ""
+
+#: init.lua
+msgid "Registered @1 and @2"
+msgstr "Registrierte @1 und @2"
+
+#: init.lua
+msgid "[MOD] signs loaded"
+msgstr "[MOD] signs geladen"
diff --git a/locale/de.txt b/locale/de.txt
deleted file mode 100644
index 8d43f77..0000000
--- a/locale/de.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# Translation by Xanthin
-
-Reading cached character database. = Lese zwischengespeicherte Buchstabendatenbank.
-Font seems to have changed. Rebuilding cache. = Schriftart scheint sich geaendert zu haben. Wiederaufbau des Zwischenspeichers.
-Could not find font line height in cached DB. Trying brute force. = Konnte die Schriftzeilenhoehe nicht in der zwischengespeicherten DB finden. Versuche Brute-Force.
-Sign = Schild
-%s wrote "%s" to sign at %s = %s schrieb "%s" auf das Schild bei %s
-Registered %s and %s = Registrierte %s und %s
-signs loaded = signs geladen
diff --git a/locale/es.po b/locale/es.po
new file mode 100644
index 0000000..8579937
--- /dev/null
+++ b/locale/es.po
@@ -0,0 +1,95 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-07-31 18:22+0200\n"
+"PO-Revision-Date: 2017-07-31 18:30+0200\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.12\n"
+"Last-Translator: Carlos Barraza\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"Language: es\n"
+
+#: init.lua
+msgid "Locked sign, owned by @1\n"
+msgstr ""
+
+#: init.lua
+msgid "locked "
+msgstr "bloqueada "
+
+#: init.lua
+msgid "@1 wrote \"@2\" to @3sign at @4"
+msgstr "@1 escribio \"@2\" en el cartel @3en @4"
+
+#: init.lua
+msgid "Sign"
+msgstr "Letrero"
+
+#: init.lua
+msgid "Can edit all locked signs"
+msgstr ""
+
+#: init.lua
+#, fuzzy
+msgid "Locked Sign"
+msgstr "Letrero bloqueada"
+
+#: init.lua
+msgid "green"
+msgstr "verde"
+
+#: init.lua
+msgid "yellow"
+msgstr "amarillo"
+
+#: init.lua
+msgid "red"
+msgstr "rojo"
+
+#: init.lua
+#, fuzzy
+msgid "white_red"
+msgstr "rojo y blanco"
+
+#: init.lua
+#, fuzzy
+msgid "white_black"
+msgstr "negro y blanco"
+
+#: init.lua
+msgid "orange"
+msgstr "naranja"
+
+#: init.lua
+msgid "blue"
+msgstr "azul"
+
+#: init.lua
+msgid "brown"
+msgstr "marrón"
+
+#: init.lua
+#, fuzzy
+msgid "Sign (@1, metal)"
+msgstr "Letrero (@1, metal)"
+
+#: init.lua
+msgid "Attempt to register unknown node as fence"
+msgstr ""
+
+#: init.lua
+msgid "Registered @1 and @2"
+msgstr "Registrado @1 y @2"
+
+#: init.lua
+msgid "[MOD] signs loaded"
+msgstr "[MOD] signs cargados"
diff --git a/locale/fr.po b/locale/fr.po
new file mode 100644
index 0000000..a503574
--- /dev/null
+++ b/locale/fr.po
@@ -0,0 +1,91 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-07-31 18:13+0200\n"
+"PO-Revision-Date: 2017-07-31 18:22+0200\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.12\n"
+"Last-Translator: fat115 <fat115@framasoft.org>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: fr\n"
+
+#: init.lua
+msgid "Locked sign, owned by @1\n"
+msgstr "Panneau verrouillé, appartient à @1\n"
+
+#: init.lua
+msgid "locked "
+msgstr "verrouillé "
+
+#: init.lua
+msgid "@1 wrote \"@2\" to @3sign at @4"
+msgstr "@1 a écrit \"@2\" sur le panneau @3en @4"
+
+#: init.lua
+msgid "Sign"
+msgstr "Panneau"
+
+#: init.lua
+msgid "Can edit all locked signs"
+msgstr "Peut modifier les panneaux verrouillés"
+
+#: init.lua
+msgid "Locked Sign"
+msgstr "Panneau (verrouillé)"
+
+#: init.lua
+msgid "green"
+msgstr "vert"
+
+#: init.lua
+msgid "yellow"
+msgstr "jaune"
+
+#: init.lua
+msgid "red"
+msgstr "rouge"
+
+#: init.lua
+msgid "white_red"
+msgstr "rouge et blanc"
+
+#: init.lua
+msgid "white_black"
+msgstr "noir et blanc"
+
+#: init.lua
+msgid "orange"
+msgstr "orange"
+
+#: init.lua
+msgid "blue"
+msgstr "bleu"
+
+#: init.lua
+msgid "brown"
+msgstr "marron"
+
+#: init.lua
+msgid "Sign (@1, metal)"
+msgstr "Panneau (@1, métal)"
+
+#: init.lua
+msgid "Attempt to register unknown node as fence"
+msgstr "Tentative d'enregistrer un nœud inconnu comme barrière"
+
+#: init.lua
+msgid "Registered @1 and @2"
+msgstr "Enregistrement de @1 et @"
+
+#: init.lua
+msgid "[MOD] signs loaded"
+msgstr "[MOD] signs chargé"
diff --git a/locale/template.pot b/locale/template.pot
new file mode 100644
index 0000000..8a80e3c
--- /dev/null
+++ b/locale/template.pot
@@ -0,0 +1,90 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-07-31 18:00+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: init.lua
+msgid "Locked sign, owned by @1\n"
+msgstr ""
+
+#: init.lua
+msgid "locked "
+msgstr ""
+
+#: init.lua
+msgid "@1 wrote \"@2\" to @3sign at @4"
+msgstr ""
+
+#: init.lua
+msgid "Sign"
+msgstr ""
+
+#: init.lua
+msgid "Can edit all locked signs"
+msgstr ""
+
+#: init.lua
+msgid "Locked Sign"
+msgstr ""
+
+#: init.lua
+msgid "green"
+msgstr ""
+
+#: init.lua
+msgid "yellow"
+msgstr ""
+
+#: init.lua
+msgid "red"
+msgstr ""
+
+#: init.lua
+msgid "white_red"
+msgstr ""
+
+#: init.lua
+msgid "white_black"
+msgstr ""
+
+#: init.lua
+msgid "orange"
+msgstr ""
+
+#: init.lua
+msgid "blue"
+msgstr ""
+
+#: init.lua
+msgid "brown"
+msgstr ""
+
+#: init.lua
+msgid "Sign (@1, metal)"
+msgstr ""
+
+#: init.lua
+msgid "Attempt to register unknown node as fence"
+msgstr ""
+
+#: init.lua
+msgid "Registered @1 and @2"
+msgstr ""
+
+#: init.lua
+msgid "[MOD] signs loaded"
+msgstr ""
diff --git a/locale/template.txt b/locale/template.txt
deleted file mode 100644
index c1851a8..0000000
--- a/locale/template.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-#Template
-
-Reading cached character database. =
-Font seems to have changed. Rebuilding cache. =
-Could not find font line height in cached DB. Trying brute force. =
-Sign =
-%s wrote "%s" to sign at %s =
-Registered %s and %s =
-signs loaded =
diff --git a/macro.lua b/macro.lua
new file mode 100644
index 0000000..1a6bfa3
--- /dev/null
+++ b/macro.lua
@@ -0,0 +1,48 @@
+-- signs_lib text macros
+-- by orwell96
+
+local mstore=minetest.get_mod_storage()
+
+local macros = minetest.deserialize(mstore:get_string("macros")) or {}
+
+local function save_macros()
+ mstore:set_string("macros", minetest.serialize(macros))
+end
+
+minetest.register_privilege("signs_macro", { description = "May edit sign macros", give_to_singleplayer = true, default = false })
+
+minetest.register_chatcommand("signs_macro", {
+ params = "list | set <macro> <string> | clear <macro>",
+ description = "List or edit sign macros",
+ privs = {signs_macros},
+ func = function(name, param)
+ if param=="list" then
+ local c=0
+ for k,v in pairs(macros) do
+ minetest.chat_send_player(name, "@"..k.." -> "..v)
+ c=c+1
+ end
+ return true, "Listed "..c.." sign macros."
+ end
+ local macro, strg = string.match(param, "^set%s@?([^@%s]+)%s?(.*)$")
+ if macro and strg then
+ macros[macro]=strg
+ save_macros()
+ return true, "Set macro '@"..macro.."'."
+ end
+ macro = string.match(param, "^clear%s@?(%S+)$")
+ if macro then
+ macros[macro]=nil
+ save_macros()
+ return true, "Cleared macro '@"..macro.."'."
+ end
+ return false, "Incorrect usage! Syntax: list | set <macro> <string> | clear <macro>"
+ end
+ })
+-- replace_macros(text)
+return function(text)
+ for k, v in pairs(macros) do
+ text=string.gsub(text, "@"..k, v)
+ end
+ return text
+end
diff --git a/textures/signs_wall_sign_metal.png b/textures/signs_wall_sign_metal.png
new file mode 100644
index 0000000..7eff1a6
--- /dev/null
+++ b/textures/signs_wall_sign_metal.png
Binary files differ