Compare commits
44 Commits
2019-10-12
...
60d67afab3
Author | SHA1 | Date | |
---|---|---|---|
60d67afab3 | |||
4dbfbec96e | |||
14efa6eeb7 | |||
b0808a376a | |||
aa5f865131 | |||
30d0af57be | |||
fe5cbb0a66 | |||
1327cb2112 | |||
c08eb3452f | |||
3ee06f9ba2 | |||
02c19e89d9 | |||
8b6f5e23a6 | |||
85dd92fb25 | |||
16b9251511 | |||
b0fac5ef9f | |||
34689b5b04 | |||
8b6e41c3fe | |||
d077d23f1a | |||
d71dcf4874 | |||
ac8b00f826 | |||
707f633f0d | |||
8527f1d5b2 | |||
3c824aedf8 | |||
fe72e32396 | |||
f7a4fefd34 | |||
664e99d34a | |||
e3c5fd2736 | |||
e7ab3e66a7 | |||
c82952befb | |||
26c3935c9b | |||
3ef11a995b | |||
22af21aeaf | |||
af45e591e3 | |||
b174cea893 | |||
4a196211ee | |||
942e91e00e | |||
4b2d4db848 | |||
4b432eec08 | |||
d956c87dbc | |||
1a6b9f38ff | |||
8b975d7fa1 | |||
b633a4bf8c | |||
bd20f9b776 | |||
7c6a1c7611 |
13
.github/workflows/luacheck.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
name: luacheck
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: apt
|
||||
run: sudo apt-get install -y luarocks
|
||||
- name: luacheck install
|
||||
run: luarocks install --local luacheck
|
||||
- name: luacheck run
|
||||
run: $HOME/.luarocks/bin/luacheck ./
|
7
.gitignore
vendored
@ -1,7 +0,0 @@
|
||||
# temporary files
|
||||
*~
|
||||
|
||||
# eclipse project files
|
||||
.project
|
||||
.settings
|
||||
.buildpath
|
17
.luacheckrc
Normal file
@ -0,0 +1,17 @@
|
||||
unused_args = false
|
||||
max_line_length = 180
|
||||
|
||||
globals = {
|
||||
"minetest",
|
||||
"signs_lib",
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
-- Builtin
|
||||
table = {fields = {"copy"}},
|
||||
"ItemStack", "vector", "default",
|
||||
|
||||
-- Mod deps
|
||||
"intllib",
|
||||
"screwdriver",
|
||||
}
|
30
API.md
@ -78,17 +78,11 @@ In this text, common terms such as `pos`, `node`, or `placer`/`digger` will not
|
||||
|
||||
Default: `signs_lib.after_place_node`
|
||||
|
||||
* `on_rightclick = function(pos)`
|
||||
* `on_rightclick = function(pos, node, player, itemstack, pointed_thing)`
|
||||
|
||||
See below under "Main functions".
|
||||
|
||||
Default: `signs_lib.construct_sign`
|
||||
|
||||
* `on_construct = function(pos)`
|
||||
|
||||
See below under "Main functions".
|
||||
|
||||
Default: `signs_lib.construct_sign`
|
||||
Default: `signs_lib.rightclick_sign`
|
||||
|
||||
* `on_destruct = function(pos)`
|
||||
|
||||
@ -96,12 +90,6 @@ In this text, common terms such as `pos`, `node`, or `placer`/`digger` will not
|
||||
|
||||
Default: `signs_lib.destruct_sign`
|
||||
|
||||
* `on_receive_fields = function(pos, formname, fields, sender)`
|
||||
|
||||
See below under "Main functions".
|
||||
|
||||
Default: `signs_lib.receive_fields`
|
||||
|
||||
* `on_punch = function(pos)`
|
||||
|
||||
See below under "Main functions".
|
||||
@ -161,9 +149,11 @@ In this text, common terms such as `pos`, `node`, or `placer`/`digger` will not
|
||||
|
||||
* `font_size = int`
|
||||
|
||||
Selects which font to use, either 15 or 31 (pixel height). This setting directly affects the sign's vertical resolution.
|
||||
Selects which font to use, either 16 or 32 (pixel height). This setting directly affects the sign's vertical resolution.
|
||||
|
||||
Default: 15
|
||||
Default: 16
|
||||
|
||||
Note: Valid values were formerly 15 and 31, these are now aliases of 16 and 32 respectively.
|
||||
|
||||
* `x_offset = int`
|
||||
* `y_offset = int`
|
||||
@ -258,18 +248,14 @@ signs_lib.register_sign("basic_signs:sign_wall_glass", {
|
||||
|
||||
* `locked`: if set to **true**, the sign's meta will be tweaked to indicate its ownership by the `placer`.
|
||||
|
||||
* `signs_lib.construct_sign(pos)`
|
||||
* `signs_lib.rightclick_sign(pos, node, player, itemstack, pointed_thing)`
|
||||
|
||||
Sets up the sign's formspec and infotext overlay.
|
||||
Open the default sign formspec, if the player has the `signslib_edit` privilege.
|
||||
|
||||
* `signs_lib.destruct_sign(pos)`
|
||||
|
||||
Deletes the sign's entity, if any, when the sign is dug.
|
||||
|
||||
* `signs_lib.receive_fields(pos, formname, fields, sender)`
|
||||
|
||||
This handles the text input and wide font on/off switch, logging any actions the user takes. Bails-out silently if the user is not allowed to edit the sign. See the standard Minetest lua_api.txt for details.
|
||||
|
||||
* `signs_lib.update_sign(pos, fields)`
|
||||
|
||||
If the sign's writable, this deletes any sign-related entities in the sign's node space, spawns a new one, and renders whatever text is in the sign's meta.
|
||||
|
12
README.md
@ -22,10 +22,16 @@ That said, there are some basic text formatting options:
|
||||
|
||||
Writing "^" followed by a letter "a" through "h" will produce double-wide versions of these arrows, in the same order. These wide arrows occupy 0x89 to 0x91 in the character set.
|
||||
|
||||
To write a "^" on a sign, wirte "#^"
|
||||
|
||||
* A color may be specified in the sign text by using "#" followed by a single hexadcimal digit (0-9 or a-f). These colors come from the standard Linux/IRC/CGA color set, and are shown in the sign's formspec. Any color change will remain in effect until changed again, or until the next line break. Any number of color changes in any arbitrary arrangement is allowed.
|
||||
|
||||
To write "#" on a sign, write "##".
|
||||
|
||||
* Most writable signs can display double-wide text by flipping a switch in the sign's formspec.
|
||||
|
||||
* Support full Unicode Plane 0 charset (63000+ characters). The "Unicode font" switch on each sign can be turned on for a more consistent letter style in multilingual text.
|
||||
|
||||
## Sign placement and rotation notes
|
||||
|
||||
* Pointing at a wall while placing will, of course, place the sign on the wall.
|
||||
@ -55,3 +61,9 @@ At present, only one command is defined:
|
||||
This will read through the list of currently-loaded blocks known to contain one or more signs, delete all entities found in each sign's node space, and respawn and re-render each from scratch.
|
||||
|
||||
The list of loaded, sign-bearing blocks is created/populated by an LBM (and trimmed by this command if any listed blocks are found to have been unloaded).
|
||||
|
||||
## Privileges
|
||||
|
||||
* `signslib_edit`
|
||||
|
||||
Allows to rotate signs and to open (and consequently edit) any default sign formspec.
|
||||
|
490
api.lua
@ -2,6 +2,10 @@
|
||||
|
||||
local S = signs_lib.gettext
|
||||
|
||||
local function get_sign_formspec() end
|
||||
|
||||
signs_lib.glow_item = "basic_materials:energy_crystal_simple"
|
||||
|
||||
signs_lib.lbm_restore_nodes = {}
|
||||
signs_lib.old_fenceposts = {}
|
||||
signs_lib.old_fenceposts_replacement_signs = {}
|
||||
@ -12,21 +16,19 @@ signs_lib.standard_lines = 6
|
||||
signs_lib.standard_hscale = 1
|
||||
signs_lib.standard_vscale = 1
|
||||
signs_lib.standard_lspace = 1
|
||||
signs_lib.standard_fsize = 15
|
||||
signs_lib.standard_fsize = 16
|
||||
signs_lib.standard_xoffs = 4
|
||||
signs_lib.standard_yoffs = 0
|
||||
signs_lib.standard_cpl = 35
|
||||
|
||||
signs_lib.standard_wood_groups = table.copy(minetest.registered_items["default:sign_wall_wood"].groups)
|
||||
signs_lib.standard_wood_groups.sign = 1
|
||||
signs_lib.standard_wood_groups = table.copy(default and minetest.registered_items["default:sign_wall_wood"].groups or {})
|
||||
signs_lib.standard_wood_groups.attached_node = nil
|
||||
|
||||
signs_lib.standard_steel_groups = table.copy(minetest.registered_items["default:sign_wall_steel"].groups)
|
||||
signs_lib.standard_steel_groups.sign = 1
|
||||
signs_lib.standard_steel_groups = table.copy(default and minetest.registered_items["default:sign_wall_steel"].groups or {})
|
||||
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_steel_sign_sounds = table.copy(minetest.registered_items["default:sign_wall_steel"].sounds)
|
||||
signs_lib.standard_wood_sign_sounds = table.copy(default and minetest.registered_items["default:sign_wall_wood"].sounds or {})
|
||||
signs_lib.standard_steel_sign_sounds = table.copy(default and minetest.registered_items["default:sign_wall_steel"].sounds or {})
|
||||
|
||||
signs_lib.default_text_scale = {x=10, y=10}
|
||||
|
||||
@ -153,16 +155,23 @@ signs_lib.flip_walldir = {
|
||||
|
||||
-- Initialize character texture cache
|
||||
local ctexcache = {}
|
||||
local ctexcache_wide = {}
|
||||
|
||||
-- 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",
|
||||
mesh = "signs_lib_standard_sign_entity_wall.obj",
|
||||
textures = {},
|
||||
static_save = false,
|
||||
backface_culling = false
|
||||
static_save = true,
|
||||
backface_culling = false,
|
||||
on_activate = function(self)
|
||||
local node = minetest.get_node(self.object:get_pos())
|
||||
if minetest.get_item_group(node.name, "sign") == 0 then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
function signs_lib.delete_objects(pos)
|
||||
@ -177,7 +186,7 @@ function signs_lib.delete_objects(pos)
|
||||
end
|
||||
end
|
||||
|
||||
function signs_lib.spawn_entity(pos, texture)
|
||||
function signs_lib.spawn_entity(pos, texture, glow)
|
||||
local node = minetest.get_node(pos)
|
||||
local def = minetest.registered_items[node.name]
|
||||
if not def or not def.entity_info then return end
|
||||
@ -226,6 +235,10 @@ function signs_lib.spawn_entity(pos, texture)
|
||||
end
|
||||
end
|
||||
|
||||
if glow ~= "" then
|
||||
obj:set_properties( {glow = tonumber(glow * 5)} )
|
||||
end
|
||||
|
||||
if yaw then
|
||||
obj:set_rotation({x = pitch, y = yaw, z=0})
|
||||
|
||||
@ -244,12 +257,15 @@ function signs_lib.spawn_entity(pos, texture)
|
||||
end
|
||||
end
|
||||
|
||||
function signs_lib.set_obj_text(pos, text)
|
||||
function signs_lib.set_obj_text(pos, text, glow)
|
||||
local split = signs_lib.split_lines_and_words
|
||||
local text_ansi = Utf8ToAnsi(text)
|
||||
local n = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
local text_ansi = signs_lib.Utf8ToAnsi(text)
|
||||
signs_lib.delete_objects(pos)
|
||||
signs_lib.spawn_entity(pos, signs_lib.make_sign_texture(split(text_ansi), pos) )
|
||||
-- only create sign entity for actual text
|
||||
if text_ansi and text_ansi ~= "" then
|
||||
signs_lib.spawn_entity(pos,
|
||||
signs_lib.make_sign_texture(split(text_ansi), pos), glow)
|
||||
end
|
||||
end
|
||||
|
||||
-- rotation
|
||||
@ -328,8 +344,11 @@ end
|
||||
local TP = signs_lib.path .. "/textures"
|
||||
-- Font file formatter
|
||||
local CHAR_FILE = "%s_%02x.png"
|
||||
local CHAR_FILE_WIDE = "%s_%s.png"
|
||||
local UNIFONT_TEX = "signs_lib_uni%02x.png\\^[sheet\\:16x16\\:%d,%d"
|
||||
-- Fonts path
|
||||
local CHAR_PATH = TP .. "/" .. CHAR_FILE
|
||||
local CHAR_PATH_WIDE = TP .. "/" .. CHAR_FILE_WIDE
|
||||
|
||||
-- Lots of overkill here. KISS advocates, go away, shoo! ;) -- kaeza
|
||||
|
||||
@ -389,6 +408,7 @@ end
|
||||
local function build_char_db(font_size)
|
||||
|
||||
local cw = {}
|
||||
local cw_wide = {}
|
||||
|
||||
-- To calculate average char width.
|
||||
local total_width = 0
|
||||
@ -404,23 +424,33 @@ local function build_char_db(font_size)
|
||||
end
|
||||
end
|
||||
|
||||
local cbw, cbh = signs_lib.read_image_size(TP.."/signs_lib_color_"..font_size.."px_n.png")
|
||||
assert(cbw and cbh, "error reading bg dimensions")
|
||||
return cw, cbw, cbh, (total_width / char_count)
|
||||
for i = 1, #signs_lib.wide_character_codes do
|
||||
local ch = signs_lib.wide_character_codes[i]
|
||||
local w, h = signs_lib.read_image_size(CHAR_PATH_WIDE:format("signs_lib_font_"..font_size.."px", ch))
|
||||
if w and h then
|
||||
cw_wide[ch] = w
|
||||
total_width = total_width + w
|
||||
char_count = char_count + 1
|
||||
end
|
||||
end
|
||||
|
||||
signs_lib.charwidth15,
|
||||
signs_lib.colorbgw15,
|
||||
signs_lib.lineheight15,
|
||||
signs_lib.avgwidth15 = build_char_db(15)
|
||||
local cbw, cbh = signs_lib.read_image_size(TP.."/signs_lib_color_"..font_size.."px_n.png")
|
||||
assert(cbw and cbh, "error reading bg dimensions")
|
||||
return cw, cbw, cbh, (total_width / char_count), cw_wide
|
||||
end
|
||||
|
||||
signs_lib.charwidth31,
|
||||
signs_lib.colorbgw31,
|
||||
signs_lib.lineheight31,
|
||||
signs_lib.avgwidth31 = build_char_db(31)
|
||||
signs_lib.charwidth16,
|
||||
signs_lib.colorbgw16,
|
||||
signs_lib.lineheight16,
|
||||
signs_lib.avgwidth16,
|
||||
signs_lib.charwidth_wide16 = build_char_db(16)
|
||||
|
||||
signs_lib.charwidth32,
|
||||
signs_lib.colorbgw32,
|
||||
signs_lib.lineheight32,
|
||||
signs_lib.avgwidth32,
|
||||
signs_lib.charwidth_wide32 = build_char_db(32)
|
||||
|
||||
local sign_groups = {choppy=2, dig_immediate=2}
|
||||
local fences_with_sign = { }
|
||||
|
||||
-- some local helper functions
|
||||
|
||||
@ -442,7 +472,8 @@ local function char_tex(font_name, ch)
|
||||
return ctexcache[font_name..ch], true
|
||||
else
|
||||
local c = ch:byte()
|
||||
local exists, tex = file_exists(CHAR_PATH:format(font_name, c))
|
||||
local exists = file_exists(CHAR_PATH:format(font_name, c))
|
||||
local tex
|
||||
if exists and c ~= 14 then
|
||||
tex = CHAR_FILE:format(font_name, c)
|
||||
else
|
||||
@ -453,7 +484,23 @@ local function char_tex(font_name, ch)
|
||||
end
|
||||
end
|
||||
|
||||
local function make_line_texture(line, lineno, pos, line_width, line_height, cwidth_tab, font_size, colorbgw)
|
||||
local function char_tex_wide(font_name, ch)
|
||||
if ctexcache_wide[font_name..ch] then
|
||||
return ctexcache_wide[font_name..ch], true
|
||||
else
|
||||
local exists = file_exists(CHAR_PATH_WIDE:format(font_name, ch))
|
||||
local tex
|
||||
if exists then
|
||||
tex = CHAR_FILE_WIDE:format(font_name, ch)
|
||||
else
|
||||
tex = CHAR_FILE:format(font_name, 0x5f)
|
||||
end
|
||||
ctexcache_wide[font_name..ch] = tex
|
||||
return tex, exists
|
||||
end
|
||||
end
|
||||
|
||||
local function make_line_texture(line, lineno, pos, line_width, line_height, cwidth_tab, font_size, colorbgw, cwidth_tab_wide, force_unicode_font)
|
||||
local width = 0
|
||||
local maxw = 0
|
||||
local font_name = "signs_lib_font_"..font_size.."px"
|
||||
@ -469,34 +516,91 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||
for word_i, word in ipairs(line) do
|
||||
local chars = { }
|
||||
local ch_offs = 0
|
||||
word = string.gsub(word, "%^[12345678abcdefgh]", {
|
||||
["^1"] = string.char(0x81),
|
||||
["^2"] = string.char(0x82),
|
||||
["^3"] = string.char(0x83),
|
||||
["^4"] = string.char(0x84),
|
||||
["^5"] = string.char(0x85),
|
||||
["^6"] = string.char(0x86),
|
||||
["^7"] = string.char(0x87),
|
||||
["^8"] = string.char(0x88),
|
||||
["^a"] = string.char(0x8a),
|
||||
["^b"] = string.char(0x8b),
|
||||
["^c"] = string.char(0x8c),
|
||||
["^d"] = string.char(0x8d),
|
||||
["^e"] = string.char(0x8e),
|
||||
["^f"] = string.char(0x8f),
|
||||
["^g"] = string.char(0x90),
|
||||
["^h"] = string.char(0x91)
|
||||
})
|
||||
local word_l = #word
|
||||
local i = 1
|
||||
local escape = 0
|
||||
while i <= word_l do
|
||||
local wide_type, wide_c = string.match(word:sub(i), "^&#([xu])(%x+);")
|
||||
local c = word:sub(i, i)
|
||||
if c == "#" then
|
||||
local cc = tonumber(word:sub(i+1, i+1), 16)
|
||||
if cc then
|
||||
local c2 = word:sub(i+1, i+1)
|
||||
|
||||
if escape > 0 then escape = escape - 1 end
|
||||
if c == "^" and escape == 0 and c2:find("[1-8a-h]") then
|
||||
c = string.char(tonumber(c2,18)+0x80)
|
||||
i = i + 1
|
||||
cur_color = cc
|
||||
end
|
||||
|
||||
local wide_skip = 0
|
||||
if force_unicode_font then
|
||||
if wide_c then
|
||||
wide_skip = #wide_c + 3
|
||||
wide_type = "u"
|
||||
elseif c:byte() < 0x80 or c:byte() >= 0xa0 then
|
||||
wide_type = "u"
|
||||
local uchar = signs_lib.AnsiToUtf8(c)
|
||||
local code
|
||||
if #uchar == 1 then
|
||||
code = uchar:byte()
|
||||
else
|
||||
code = uchar:byte() % (2 ^ (7 - #uchar))
|
||||
for j = 1, #uchar do
|
||||
code = code * (2 ^ 6) + uchar:byte(j) - 0x80
|
||||
end
|
||||
end
|
||||
wide_c = string.format("%04x", code)
|
||||
end
|
||||
elseif wide_c then
|
||||
wide_skip = #wide_c + 3
|
||||
end
|
||||
|
||||
if c == "#" and escape == 0 and c2:find("[0-9A-Fa-f#^]") then
|
||||
if c2 == "#" or c2 == "^" then
|
||||
escape = 2
|
||||
else
|
||||
i = i + 1
|
||||
cur_color = tonumber(c2, 16)
|
||||
end
|
||||
elseif wide_c then
|
||||
local w, code
|
||||
if wide_type == "x" then
|
||||
w = cwidth_tab_wide[wide_c]
|
||||
elseif wide_type == "u" and #wide_c <= 4 then
|
||||
w = font_size
|
||||
code = tonumber(wide_c, 16)
|
||||
if signs_lib.unifont_halfwidth[code] then
|
||||
w = math.floor(w / 2)
|
||||
end
|
||||
end
|
||||
if w then
|
||||
width = width + w + 1
|
||||
if width >= (line_width - cwidth_tab[" "]) then
|
||||
width = 0
|
||||
else
|
||||
maxw = math_max(width, maxw)
|
||||
end
|
||||
if #chars < MAX_INPUT_CHARS then
|
||||
local tex
|
||||
if wide_type == "u" then
|
||||
local page = math.floor(code / 256)
|
||||
local idx = code % 256
|
||||
local x = idx % 16
|
||||
local y = math.floor(idx / 16)
|
||||
tex = UNIFONT_TEX:format(page, x, y)
|
||||
if font_size == 32 then
|
||||
tex = tex .. "\\^[resize\\:32x32"
|
||||
end
|
||||
else
|
||||
tex = char_tex_wide(font_name, wide_c)
|
||||
end
|
||||
table.insert(chars, {
|
||||
off = ch_offs,
|
||||
tex = tex,
|
||||
col = ("%X"):format(cur_color),
|
||||
})
|
||||
end
|
||||
ch_offs = ch_offs + w
|
||||
end
|
||||
i = i + wide_skip
|
||||
else
|
||||
local w = cwidth_tab[c]
|
||||
if w then
|
||||
@ -576,25 +680,25 @@ function signs_lib.make_sign_texture(lines, pos)
|
||||
local line_width
|
||||
local line_height
|
||||
local char_width
|
||||
local char_width_wide
|
||||
local colorbgw
|
||||
local widemult = 1
|
||||
local widemult = meta:get_int("widefont") == 1 and 0.5 or 1
|
||||
local force_unicode_font = meta:get_int("unifont") == 1
|
||||
|
||||
if meta:get_int("widefont") == 1 then
|
||||
widemult = 0.5
|
||||
end
|
||||
|
||||
if def.font_size and def.font_size == 31 then
|
||||
font_size = 31
|
||||
line_width = math.floor(signs_lib.avgwidth31 * def.chars_per_line) * (def.horiz_scaling * widemult)
|
||||
line_height = signs_lib.lineheight31
|
||||
char_width = signs_lib.charwidth31
|
||||
colorbgw = signs_lib.colorbgw31
|
||||
if def.font_size and (def.font_size == 32 or def.font_size == 31) then
|
||||
font_size = 32
|
||||
line_width = math.floor(signs_lib.avgwidth32 * def.chars_per_line) * (def.horiz_scaling * widemult)
|
||||
line_height = signs_lib.lineheight32
|
||||
char_width = signs_lib.charwidth32
|
||||
char_width_wide = signs_lib.charwidth_wide32
|
||||
colorbgw = signs_lib.colorbgw32
|
||||
else
|
||||
font_size = 15
|
||||
line_width = math.floor(signs_lib.avgwidth15 * def.chars_per_line) * (def.horiz_scaling * widemult)
|
||||
line_height = signs_lib.lineheight15
|
||||
char_width = signs_lib.charwidth15
|
||||
colorbgw = signs_lib.colorbgw15
|
||||
font_size = 16
|
||||
line_width = math.floor(signs_lib.avgwidth16 * def.chars_per_line) * (def.horiz_scaling * widemult)
|
||||
line_height = signs_lib.lineheight16
|
||||
char_width = signs_lib.charwidth16
|
||||
char_width_wide = signs_lib.charwidth_wide16
|
||||
colorbgw = signs_lib.colorbgw16
|
||||
end
|
||||
|
||||
local texture = { ("[combine:%dx%d"):format(line_width, (line_height + def.line_spacing) * def.number_of_lines * def.vert_scaling) }
|
||||
@ -602,7 +706,7 @@ function signs_lib.make_sign_texture(lines, pos)
|
||||
local lineno = 0
|
||||
for i = 1, #lines do
|
||||
if lineno >= def.number_of_lines then break end
|
||||
local linetex, ln = make_line_texture(lines[i], lineno, pos, line_width, line_height, char_width, font_size, colorbgw)
|
||||
local linetex, ln = make_line_texture(lines[i], lineno, pos, line_width, line_height, char_width, font_size, colorbgw, char_width_wide, force_unicode_font)
|
||||
table.insert(texture, linetex)
|
||||
lineno = ln + 1
|
||||
end
|
||||
@ -619,34 +723,22 @@ function signs_lib.split_lines_and_words(text)
|
||||
return lines
|
||||
end
|
||||
|
||||
function signs_lib.construct_sign(pos)
|
||||
local form = "size[6,4]"..
|
||||
"textarea[0,-0.3;6.5,3;text;;${text}]"..
|
||||
"background[-0.5,-0.5;7,5;signs_lib_sign_bg.jpg]"
|
||||
local node = minetest.get_node(pos)
|
||||
local def = minetest.registered_items[node.name]
|
||||
local meta = minetest.get_meta(pos)
|
||||
function signs_lib.rightclick_sign(pos, node, player, itemstack, pointed_thing)
|
||||
|
||||
if def.allow_widefont then
|
||||
local state = "off"
|
||||
if meta:get_int("widefont") == 1 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
|
||||
if not player or not signs_lib.can_modify(pos, player) then return end
|
||||
if not player.get_meta then return end
|
||||
|
||||
meta:set_string("formspec", form)
|
||||
local i = meta:get_string("infotext")
|
||||
if i == "" then -- it wasn't even set, so set it.
|
||||
meta:set_string("infotext", "")
|
||||
end
|
||||
player:get_meta():set_string("signslib:pos", minetest.pos_to_string(pos))
|
||||
minetest.show_formspec(player:get_player_name(), "signs_lib:sign", get_sign_formspec(pos, node.name))
|
||||
end
|
||||
|
||||
function signs_lib.destruct_sign(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local glow = meta:get_string("glow")
|
||||
if glow ~= "" and not minetest.is_creative_enabled("") then
|
||||
local num = tonumber(glow)
|
||||
minetest.add_item(pos, ItemStack(signs_lib.glow_item .. " " .. num))
|
||||
end
|
||||
signs_lib.delete_objects(pos)
|
||||
end
|
||||
|
||||
@ -655,14 +747,45 @@ local function make_infotext(text)
|
||||
local lines = signs_lib.split_lines_and_words(text) or {}
|
||||
local lines2 = { }
|
||||
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#^]", function (s)
|
||||
return s:sub(2):find("[#^]") and s:sub(2) or ""
|
||||
end)))
|
||||
end
|
||||
return table.concat(lines2, "\n")
|
||||
end
|
||||
|
||||
function signs_lib.glow(pos, node, puncher)
|
||||
local name = puncher:get_player_name()
|
||||
if minetest.is_protected(pos, name) then
|
||||
return
|
||||
end
|
||||
local tool = puncher:get_wielded_item()
|
||||
if tool:get_name() == signs_lib.glow_item then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local glow = tonumber(meta:get_string("glow"))
|
||||
if not glow then
|
||||
glow = 1
|
||||
elseif glow < 3 then
|
||||
glow = glow + 1
|
||||
else
|
||||
return -- already at brightest level
|
||||
end
|
||||
if not minetest.is_creative_enabled(name) then
|
||||
tool:take_item()
|
||||
puncher:set_wielded_item(tool)
|
||||
end
|
||||
meta:set_string("glow", glow)
|
||||
end
|
||||
end
|
||||
|
||||
function signs_lib.update_sign(pos, fields)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
-- legacy udpate
|
||||
if meta:get_string("formspec") ~= "" then
|
||||
meta:set_string("formspec", "")
|
||||
end
|
||||
|
||||
local text = fields and fields.text or meta:get_string("text")
|
||||
text = trim_input(text)
|
||||
|
||||
@ -672,42 +795,9 @@ function signs_lib.update_sign(pos, fields)
|
||||
|
||||
meta:set_string("text", text)
|
||||
meta:set_string("infotext", ownstr..make_infotext(text).." ")
|
||||
signs_lib.set_obj_text(pos, text)
|
||||
end
|
||||
|
||||
function signs_lib.receive_fields(pos, formname, fields, sender)
|
||||
|
||||
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",
|
||||
(sender:get_player_name() or ""),
|
||||
fields.text:gsub('\\', '\\\\'):gsub("\n", "\\n"),
|
||||
minetest.pos_to_string(pos)
|
||||
))
|
||||
signs_lib.update_sign(pos, fields)
|
||||
elseif fields.on or fields.off then
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local change
|
||||
|
||||
if fields.on and meta:get_int("widefont") == 1 then
|
||||
meta:set_int("widefont", 0)
|
||||
change = true
|
||||
elseif fields.off and meta:get_int("widefont") == 0 then
|
||||
meta:set_int("widefont", 1)
|
||||
change = true
|
||||
end
|
||||
if change 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)
|
||||
))
|
||||
signs_lib.construct_sign(pos)
|
||||
signs_lib.update_sign(pos, fields)
|
||||
end
|
||||
end
|
||||
local glow = meta:get_string("glow")
|
||||
signs_lib.set_obj_text(pos, text, glow)
|
||||
end
|
||||
|
||||
function signs_lib.can_modify(pos, player)
|
||||
@ -722,7 +812,7 @@ function signs_lib.can_modify(pos, player)
|
||||
|
||||
if owner == ""
|
||||
or playername == owner
|
||||
or (minetest.check_player_privs(playername, {sign_editor=true}))
|
||||
or (minetest.check_player_privs(playername, {signslib_edit=true}))
|
||||
or (playername == minetest.settings:get("name")) then
|
||||
return true
|
||||
end
|
||||
@ -823,10 +913,6 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
|
||||
|
||||
local def = minetest.registered_items[signname]
|
||||
|
||||
local ppos = minetest.get_pointed_thing_position(pointed_thing)
|
||||
local pnode = minetest.get_node(ppos)
|
||||
local pdef = minetest.registered_items[pnode.name]
|
||||
|
||||
if def.allow_onpole and signs_lib.check_for_pole(pos, pointed_thing) and not controls.sneak then
|
||||
local newparam2
|
||||
local lookdir = minetest.yaw_to_dir(placer:get_look_horizontal())
|
||||
@ -835,7 +921,6 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
|
||||
else
|
||||
newparam2 = minetest.dir_to_facedir(lookdir)
|
||||
end
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.swap_node(pos, {name = no_wall_name.."_onpole", param2 = newparam2})
|
||||
elseif def.allow_onpole_horizontal and signs_lib.check_for_horizontal_pole(pos, pointed_thing) and not controls.sneak then
|
||||
local newparam2
|
||||
@ -845,15 +930,12 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
|
||||
else
|
||||
newparam2 = minetest.dir_to_facedir(lookdir)
|
||||
end
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.swap_node(pos, {name = no_wall_name.."_onpole_horiz", param2 = newparam2})
|
||||
elseif def.allow_hanging and signs_lib.check_for_ceiling(pointed_thing) and not controls.sneak then
|
||||
local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.swap_node(pos, {name = no_wall_name.."_hanging", param2 = newparam2})
|
||||
elseif def.allow_yard and signs_lib.check_for_floor(pointed_thing) and not controls.sneak then
|
||||
local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.swap_node(pos, {name = no_wall_name.."_yard", param2 = newparam2})
|
||||
elseif def.paramtype2 == "facedir" and signs_lib.check_for_ceiling(pointed_thing) then
|
||||
minetest.swap_node(pos, {name = signname, param2 = 6})
|
||||
@ -872,6 +954,23 @@ 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
|
||||
|
||||
local use_glow = function(pos, node, puncher, pointed_thing)
|
||||
if puncher then -- if e.g. a machine tries to punch; only a real person should change the lighting
|
||||
signs_lib.glow(pos, node, puncher)
|
||||
end
|
||||
return signs_lib.update_sign(pos)
|
||||
end
|
||||
|
||||
local glow_drops = function(pos, oldnode, oldmetadata, digger)
|
||||
if digger and minetest.is_creative_enabled(digger:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local glow = oldmetadata and oldmetadata.fields and oldmetadata.fields.glow
|
||||
if glow then
|
||||
minetest.add_item(pos, ItemStack(signs_lib.glow_item .. " " .. glow))
|
||||
end
|
||||
end
|
||||
|
||||
function signs_lib.register_sign(name, raw_def)
|
||||
local def = table.copy(raw_def)
|
||||
|
||||
@ -887,11 +986,16 @@ function signs_lib.register_sign(name, raw_def)
|
||||
def.after_place_node = raw_def.after_place_node or signs_lib.after_place_node
|
||||
|
||||
if raw_def.entity_info then
|
||||
def.on_rightclick = raw_def.on_rightclick or signs_lib.construct_sign
|
||||
def.on_construct = raw_def.on_construct or signs_lib.construct_sign
|
||||
def.on_destruct = raw_def.on_destruct or signs_lib.destruct_sign
|
||||
def.on_receive_fields = raw_def.on_receive_fields or signs_lib.receive_fields
|
||||
|
||||
if def.allow_glow ~= false then
|
||||
def.on_punch = raw_def.on_punch or use_glow
|
||||
def.after_dig_node = raw_def.after_dig_node or glow_drops
|
||||
else
|
||||
def.on_punch = raw_def.on_punch or signs_lib.update_sign
|
||||
end
|
||||
|
||||
def.on_rightclick = raw_def.on_rightclick or signs_lib.rightclick_sign
|
||||
def.on_destruct = raw_def.on_destruct or signs_lib.destruct_sign
|
||||
def.number_of_lines = raw_def.number_of_lines or signs_lib.standard_lines
|
||||
def.horiz_scaling = raw_def.horiz_scaling or signs_lib.standard_hscale
|
||||
def.vert_scaling = raw_def.vert_scaling or signs_lib.standard_vscale
|
||||
@ -923,6 +1027,9 @@ function signs_lib.register_sign(name, raw_def)
|
||||
def.groups = signs_lib.standard_wood_groups
|
||||
end
|
||||
|
||||
-- force all signs into the sign group
|
||||
def.groups.sign = def.groups.sign or 1
|
||||
|
||||
local cbox = signs_lib.make_selection_boxes(35, 25)
|
||||
|
||||
def.selection_box = raw_def.selection_box or cbox
|
||||
@ -1133,7 +1240,7 @@ minetest.register_lbm({
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
-- yeah, yeah... I know I'm hashing a block pos, but it's still just a set of coords
|
||||
local hash = minetest.hash_node_position(vector.floor(vector.divide(pos, core.MAP_BLOCKSIZE)))
|
||||
local hash = minetest.hash_node_position(vector.floor(vector.divide(pos, minetest.MAP_BLOCKSIZE)))
|
||||
if not signs_lib.block_list[hash] then
|
||||
signs_lib.block_list[hash] = true
|
||||
signs_lib.totalblocks = signs_lib.totalblocks + 1
|
||||
@ -1150,9 +1257,9 @@ minetest.register_chatcommand("regen_signs", {
|
||||
local totalsigns = 0
|
||||
for b in pairs(signs_lib.block_list) do
|
||||
local blockpos = minetest.get_position_from_hash(b)
|
||||
local pos1 = vector.multiply(blockpos, core.MAP_BLOCKSIZE)
|
||||
local pos2 = vector.add(pos1, core.MAP_BLOCKSIZE - 1)
|
||||
if minetest.get_node_or_nil(vector.add(pos1, core.MAP_BLOCKSIZE/2)) then
|
||||
local pos1 = vector.multiply(blockpos, minetest.MAP_BLOCKSIZE)
|
||||
local pos2 = vector.add(pos1, minetest.MAP_BLOCKSIZE - 1)
|
||||
if minetest.get_node_or_nil(vector.add(pos1, minetest.MAP_BLOCKSIZE/2)) then
|
||||
local signs_in_block = minetest.find_nodes_in_area(pos1, pos2, {"group:sign"})
|
||||
allsigns[#allsigns + 1] = signs_in_block
|
||||
totalsigns = totalsigns + #signs_in_block
|
||||
@ -1184,3 +1291,96 @@ minetest.register_chatcommand("regen_signs", {
|
||||
minetest.chat_send_player(player_name, "Finished.")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_privilege("signslib_edit", {})
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- local functions
|
||||
--
|
||||
|
||||
function get_sign_formspec(pos, nodename)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local txt = meta:get_string("text")
|
||||
local state = meta:get_int("unifont") == 1 and "on" or "off"
|
||||
|
||||
local formspec = {
|
||||
"size[6,4]",
|
||||
"background[-0.5,-0.5;7,5;signs_lib_sign_bg.png]",
|
||||
"image[0.1,2.4;7,1;signs_lib_sign_color_palette.png]",
|
||||
"textarea[0.15,-0.2;6.3,2.8;text;;" .. minetest.formspec_escape(txt) .. "]",
|
||||
"button_exit[3.7,3.4;2,1;ok;" .. S("Write") .. "]",
|
||||
"label[0.3,3.4;Unicode font]",
|
||||
"image_button[0.6,3.7;1,0.6;signs_lib_switch_" .. state .. ".png;uni_"
|
||||
.. state .. ";;;false;signs_lib_switch_interm.png]",
|
||||
}
|
||||
|
||||
if minetest.registered_nodes[nodename].allow_widefont then
|
||||
state = meta:get_int("widefont") == 1 and "on" or "off"
|
||||
formspec[#formspec+1] = "label[2.1,3.4;Wide font]"
|
||||
formspec[#formspec+1] = "image_button[2.3,3.7;1,0.6;signs_lib_switch_" .. state .. ".png;wide_"
|
||||
.. state .. ";;;false;signs_lib_switch_interm.png]"
|
||||
end
|
||||
|
||||
return table.concat(formspec, "")
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
if formname ~= "signs_lib:sign" then return end
|
||||
|
||||
local pos_string = player:get_meta():get_string("signslib:pos")
|
||||
local pos = minetest.string_to_pos(pos_string)
|
||||
local playername = player:get_player_name()
|
||||
|
||||
if fields.text and fields.ok then
|
||||
minetest.log("action", S("@1 wrote \"@2\" to sign at @3",
|
||||
(playername or ""),
|
||||
fields.text:gsub('\\', '\\\\'):gsub("\n", "\\n"),
|
||||
pos_string
|
||||
))
|
||||
signs_lib.update_sign(pos, fields)
|
||||
elseif fields.wide_on or fields.wide_off or fields.uni_on or fields.uni_off then
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local change_wide
|
||||
local change_uni
|
||||
|
||||
if fields.wide_on and meta:get_int("widefont") == 1 then
|
||||
meta:set_int("widefont", 0)
|
||||
change_wide = true
|
||||
elseif fields.wide_off and meta:get_int("widefont") == 0 then
|
||||
meta:set_int("widefont", 1)
|
||||
change_wide = true
|
||||
end
|
||||
if fields.uni_on and meta:get_int("unifont") == 1 then
|
||||
meta:set_int("unifont", 0)
|
||||
change_uni = true
|
||||
elseif fields.uni_off and meta:get_int("unifont") == 0 then
|
||||
meta:set_int("unifont", 1)
|
||||
change_uni = true
|
||||
end
|
||||
|
||||
if change_wide then
|
||||
minetest.log("action", S("@1 flipped the wide-font switch to \"@2\" at @3",
|
||||
(playername or ""),
|
||||
(fields.wide_on and "off" or "on"),
|
||||
minetest.pos_to_string(pos)
|
||||
))
|
||||
signs_lib.update_sign(pos, fields)
|
||||
minetest.show_formspec(playername, "signs_lib:sign", get_sign_formspec(pos, node.name))
|
||||
end
|
||||
if change_uni then
|
||||
minetest.log("action", S("@1 flipped the unicode-font switch to \"@2\" at @3",
|
||||
(playername or ""),
|
||||
(fields.uni_on and "off" or "on"),
|
||||
minetest.pos_to_string(pos)
|
||||
))
|
||||
signs_lib.update_sign(pos, fields)
|
||||
minetest.show_formspec(playername, "signs_lib:sign", get_sign_formspec(pos, node.name))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
if minetest.get_modpath("default") then
|
||||
local default_fences = {
|
||||
"default:fence_wood",
|
||||
"default:fence_acacia_wood",
|
||||
@ -12,6 +12,7 @@ for _, n in ipairs(default_fences) do
|
||||
check_for_pole = true
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("cottages") then
|
||||
local cbox = table.copy(minetest.registered_items["cottages:table"].node_box)
|
||||
|
@ -1,6 +0,0 @@
|
||||
default
|
||||
intllib?
|
||||
screwdriver?
|
||||
streetspoles?
|
||||
streetlamps?
|
||||
cottages?
|
@ -1 +0,0 @@
|
||||
Adds signs with readable text.
|
113
encoding.lua
@ -1,5 +1,8 @@
|
||||
-- encoding borrowed from signs_lib fork at https://github.com/lord-server/lord
|
||||
|
||||
-- The "ANSI" encoding here actually refers to "windows-1251", which shows up as
|
||||
-- "ANSI" on Russian version of MS Windows
|
||||
|
||||
local ansi_decode = {
|
||||
[128] = "\208\130",
|
||||
[129] = "\208\131",
|
||||
@ -203,12 +206,38 @@ local utf8_decode = {
|
||||
[210] = {[144] = "\165", [145] = "\180"}
|
||||
}
|
||||
|
||||
local wide_character_codes = {
|
||||
}
|
||||
|
||||
signs_lib.unicode_install = function(
|
||||
numbers
|
||||
)
|
||||
local scope = utf8_decode
|
||||
for i = 1,#numbers-2 do
|
||||
if not scope[numbers[i]] then
|
||||
scope[numbers[i]] = {}
|
||||
end
|
||||
scope = scope[numbers[i]]
|
||||
end
|
||||
scope[numbers[#numbers-1]] = "&#x" .. numbers[#numbers] .. ";"
|
||||
table.insert(
|
||||
wide_character_codes,
|
||||
numbers[#numbers]
|
||||
)
|
||||
end
|
||||
|
||||
signs_lib.unicode_install({38,"26"})
|
||||
|
||||
dofile(signs_lib.path.."/nonascii-de.lua")
|
||||
dofile(signs_lib.path.."/nonascii-fr.lua")
|
||||
dofile(signs_lib.path.."/nonascii-pl.lua")
|
||||
|
||||
local nmdc = {
|
||||
[36] = "$",
|
||||
[124] = "|"
|
||||
}
|
||||
|
||||
function AnsiToUtf8(s)
|
||||
function signs_lib.AnsiToUtf8(s)
|
||||
local r, b = ""
|
||||
for i = 1, s and s:len() or 0 do
|
||||
b = s:byte(i)
|
||||
@ -229,37 +258,77 @@ function AnsiToUtf8(s)
|
||||
return r
|
||||
end
|
||||
|
||||
function Utf8ToAnsi(s)
|
||||
local a, j, r, b = 0, 0, ""
|
||||
function signs_lib.Utf8ToAnsi(s)
|
||||
local r, b = ""
|
||||
local scope
|
||||
local j, l, u
|
||||
for i = 1, s and s:len() or 0 do
|
||||
b = s:byte(i)
|
||||
if b < 128 then
|
||||
|
||||
-- legacy parser
|
||||
if b == 0x26 then
|
||||
r = r .. "&"
|
||||
elseif b < 128 then
|
||||
if nmdc[b] then
|
||||
r = r .. nmdc[b]
|
||||
else
|
||||
r = r .. string.char(b)
|
||||
end
|
||||
elseif a == 2 then
|
||||
a, j = a - 1, b
|
||||
elseif a == 1 then
|
||||
--if j == nil or b == nil then return r end
|
||||
--print(j)
|
||||
--print(b)
|
||||
--local ansi = utf8_decode[j]
|
||||
--if ansi == nil then return r end
|
||||
--if ansi[b] == nil then return r end
|
||||
if utf8_decode[j] then
|
||||
if utf8_decode[j][b] then
|
||||
a, r = a - 1, r .. utf8_decode[j][b]
|
||||
elseif scope then
|
||||
if scope[b] then
|
||||
scope = scope[b]
|
||||
if "string" == type(scope) then
|
||||
r, scope = r .. scope, nil
|
||||
j = -1 -- supress general UTF-8 parser
|
||||
end
|
||||
end
|
||||
elseif b == 226 then
|
||||
a = 2
|
||||
elseif b == 194 or b == 208 or b == 209 or b == 210 then
|
||||
j, a = b, 1
|
||||
else
|
||||
r = r .. "_"
|
||||
scope = nil
|
||||
end
|
||||
elseif utf8_decode[b] then
|
||||
scope = utf8_decode[b]
|
||||
end
|
||||
|
||||
-- general UTF-8 parser
|
||||
if j == -1 then -- supressed by legacy parser
|
||||
j = nil
|
||||
elseif b < 0x80 then
|
||||
if j then
|
||||
r = r .. "&#ufffd;"
|
||||
j = nil
|
||||
end
|
||||
-- ASCII handled by legacy parser
|
||||
elseif b >= 0xc0 then
|
||||
if j then
|
||||
r = r .. "&#ufffd;"
|
||||
end
|
||||
j = i
|
||||
if b >= 0xf8 then
|
||||
r = r .. "&#ufffd;"
|
||||
j = nil
|
||||
elseif b >= 0xf0 then
|
||||
l, u = 4, b % (2 ^ 3)
|
||||
elseif b >= 0xe0 then
|
||||
l, u = 3, b % (2 ^ 4)
|
||||
else
|
||||
l, u = 2, b % (2 ^ 5)
|
||||
end
|
||||
else
|
||||
if j then
|
||||
u = u * (2 ^ 6) + b % (2 ^ 6)
|
||||
if i == j + l - 1 then
|
||||
r = r .. string.format("&#u%x;", u)
|
||||
j = nil
|
||||
end
|
||||
else
|
||||
r = r .. "&#ufffd;"
|
||||
end
|
||||
end
|
||||
end
|
||||
if j then
|
||||
r = r .. "&#ufffd;"
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
signs_lib.wide_character_codes = wide_character_codes
|
||||
signs_lib.unifont_halfwidth = dofile(signs_lib.path.."/unifont-halfwidth.lua")
|
||||
|
4
init.lua
@ -7,10 +7,10 @@ signs_lib = {}
|
||||
|
||||
signs_lib.path = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
local S, NS = dofile(signs_lib.path .. "/intllib.lua")
|
||||
local S = dofile(signs_lib.path .. "/intllib.lua")
|
||||
signs_lib.gettext = S
|
||||
|
||||
dofile(signs_lib.path.."/api.lua")
|
||||
dofile(signs_lib.path.."/encoding.lua")
|
||||
dofile(signs_lib.path.."/api.lua")
|
||||
dofile(signs_lib.path.."/standard_signs.lua")
|
||||
dofile(signs_lib.path.."/compat.lua")
|
||||
|
4
mod.conf
@ -1 +1,5 @@
|
||||
name = signs_lib
|
||||
author = VanessaE
|
||||
optional_depends = intllib, screwdriver, streetspoles, streetlamps, cottages, prefab_redo, default
|
||||
description = Adds signs with readable text.
|
||||
min_minetest_version = 5.4.0
|
||||
|
7
nonascii-de.lua
Normal file
@ -0,0 +1,7 @@
|
||||
signs_lib.unicode_install({195,132,"00c4"})
|
||||
signs_lib.unicode_install({195,150,"00d6"})
|
||||
signs_lib.unicode_install({195,156,"00dc"})
|
||||
signs_lib.unicode_install({195,159,"00df"})
|
||||
signs_lib.unicode_install({195,164,"00e4"})
|
||||
signs_lib.unicode_install({195,182,"00f6"})
|
||||
signs_lib.unicode_install({195,188,"00fc"})
|
16
nonascii-fr.lua
Normal file
@ -0,0 +1,16 @@
|
||||
signs_lib.unicode_install({195,128,"00c0"})
|
||||
signs_lib.unicode_install({195,134,"00c6"})
|
||||
signs_lib.unicode_install({195,135,"00c7"})
|
||||
signs_lib.unicode_install({195,136,"00c8"})
|
||||
signs_lib.unicode_install({195,137,"00c9"})
|
||||
signs_lib.unicode_install({195,138,"00ca"})
|
||||
signs_lib.unicode_install({195,148,"00d4"})
|
||||
signs_lib.unicode_install({195,153,"00d9"})
|
||||
signs_lib.unicode_install({195,160,"00e0"})
|
||||
signs_lib.unicode_install({195,166,"00e6"})
|
||||
signs_lib.unicode_install({195,167,"00e7"})
|
||||
signs_lib.unicode_install({195,168,"00e8"})
|
||||
signs_lib.unicode_install({195,169,"00e9"})
|
||||
signs_lib.unicode_install({195,170,"00ea"})
|
||||
signs_lib.unicode_install({195,180,"00f4"})
|
||||
signs_lib.unicode_install({195,185,"00f9"})
|
16
nonascii-pl.lua
Normal file
@ -0,0 +1,16 @@
|
||||
signs_lib.unicode_install({195,147,"00d3"})
|
||||
signs_lib.unicode_install({195,179,"00f3"})
|
||||
signs_lib.unicode_install({196,132,"0104"})
|
||||
signs_lib.unicode_install({196,133,"0105"})
|
||||
signs_lib.unicode_install({196,134,"0106"})
|
||||
signs_lib.unicode_install({196,135,"0107"})
|
||||
signs_lib.unicode_install({196,152,"0118"})
|
||||
signs_lib.unicode_install({196,153,"0119"})
|
||||
signs_lib.unicode_install({197,129,"0141"})
|
||||
signs_lib.unicode_install({197,130,"0142"})
|
||||
signs_lib.unicode_install({197,154,"015a"})
|
||||
signs_lib.unicode_install({197,155,"015b"})
|
||||
signs_lib.unicode_install({197,185,"0179"})
|
||||
signs_lib.unicode_install({197,186,"017a"})
|
||||
signs_lib.unicode_install({197,187,"017b"})
|
||||
signs_lib.unicode_install({197,188,"017c"})
|
@ -1,5 +1,6 @@
|
||||
-- Definitions for standard minetest_game wooden and steel wall signs
|
||||
|
||||
if minetest.get_modpath("default") then
|
||||
signs_lib.register_sign("default:sign_wall_wood", {
|
||||
description = "Wooden wall sign",
|
||||
inventory_image = "signs_lib_sign_wall_wooden_inv.png",
|
||||
@ -14,7 +15,8 @@ signs_lib.register_sign("default:sign_wall_wood", {
|
||||
allow_widefont = true,
|
||||
allow_onpole = true,
|
||||
allow_onpole_horizontal = true,
|
||||
allow_yard = true
|
||||
allow_yard = true,
|
||||
use_texture_alpha = "clip",
|
||||
})
|
||||
|
||||
signs_lib.register_sign("default:sign_wall_steel", {
|
||||
@ -35,20 +37,26 @@ signs_lib.register_sign("default:sign_wall_steel", {
|
||||
allow_widefont = true,
|
||||
allow_onpole = true,
|
||||
allow_onpole_horizontal = true,
|
||||
allow_yard = true
|
||||
allow_yard = true,
|
||||
use_texture_alpha = "clip",
|
||||
})
|
||||
|
||||
|
||||
minetest.register_alias("default:sign_wall_wood_onpole", "default:sign_wood_onpole")
|
||||
|
||||
minetest.register_alias("default:sign_wall_wood_hanging", "default:sign_wood_hanging")
|
||||
minetest.register_alias("signs:sign_hanging", "default:sign_wood_hanging")
|
||||
minetest.register_alias("basic_signs:hanging_sign", "default:sign_wood_hanging")
|
||||
|
||||
minetest.register_alias("default:sign_wall_wood_yard", "default:sign_wood_yard")
|
||||
minetest.register_alias("signs:sign_yard", "default:sign_wood_yard")
|
||||
minetest.register_alias("basic_signs:yard_sign", "default:sign_wood_yard")
|
||||
|
||||
minetest.register_alias("default:sign_wall_wood_onpole", "default:sign_wood_onpole")
|
||||
minetest.register_alias("default:sign_wall_wood_onpole_horiz", "default:sign_wood_onpole_horiz")
|
||||
minetest.register_alias("default:sign_wall_wood_hanging", "default:sign_wood_hanging")
|
||||
minetest.register_alias("default:sign_wall_wood_yard", "default:sign_wood_yard")
|
||||
|
||||
minetest.register_alias("default:sign_wall_steel_onpole", "default:sign_steel_onpole")
|
||||
minetest.register_alias("default:sign_wall_steel_onpole_horiz", "default:sign_steel_onpole_horiz")
|
||||
minetest.register_alias("default:sign_wall_steel_hanging", "default:sign_steel_hanging")
|
||||
minetest.register_alias("default:sign_wall_steel_yard", "default:sign_steel_yard")
|
||||
end
|
||||
|
||||
table.insert(signs_lib.lbm_restore_nodes, "signs:sign_hanging")
|
||||
table.insert(signs_lib.lbm_restore_nodes, "basic_signs:hanging_sign")
|
||||
table.insert(signs_lib.lbm_restore_nodes, "signs:sign_yard")
|
||||
|
Before Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 112 B |
Before Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 109 B |
BIN
textures/signs_lib_color_16px_0.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
textures/signs_lib_color_16px_1.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_2.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_3.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_4.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_5.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_6.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_7.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
textures/signs_lib_color_16px_8.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
textures/signs_lib_color_16px_9.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_A.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_B.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_C.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_D.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_E.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_F.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
textures/signs_lib_color_16px_n.png
Normal file
After Width: | Height: | Size: 80 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 355 B |
Before Width: | Height: | Size: 355 B |
BIN
textures/signs_lib_color_32px_0.png
Normal file
After Width: | Height: | Size: 99 B |
BIN
textures/signs_lib_color_32px_1.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_2.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_3.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_4.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_5.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_6.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_7.png
Normal file
After Width: | Height: | Size: 99 B |
BIN
textures/signs_lib_color_32px_8.png
Normal file
After Width: | Height: | Size: 99 B |
BIN
textures/signs_lib_color_32px_9.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_A.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_B.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_C.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_D.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_E.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_F.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
textures/signs_lib_color_32px_n.png
Normal file
After Width: | Height: | Size: 83 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 67 B |
Before Width: | Height: | Size: 83 B |
Before Width: | Height: | Size: 83 B |
Before Width: | Height: | Size: 97 B |
Before Width: | Height: | Size: 112 B |
Before Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 120 B |
Before Width: | Height: | Size: 78 B |
Before Width: | Height: | Size: 88 B |
Before Width: | Height: | Size: 88 B |
Before Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 84 B |
Before Width: | Height: | Size: 79 B |
Before Width: | Height: | Size: 77 B |
Before Width: | Height: | Size: 77 B |