First commit
|
@ -0,0 +1,9 @@
|
|||
This mod is modified by PilzAdam
|
||||
|
||||
Changes:
|
||||
- Remove shadows under signs
|
||||
- New input system: - There is just one text line that automatically will be splitted up to the lines on the sign
|
||||
- You can force a newline with " | "
|
||||
- It overrides the default signs
|
||||
|
||||
License of code: WTFPL
|
|
@ -0,0 +1,279 @@
|
|||
A
|
||||
_a_
|
||||
4
|
||||
B
|
||||
_b_
|
||||
4
|
||||
C
|
||||
_c_
|
||||
3
|
||||
D
|
||||
_d_
|
||||
4
|
||||
E
|
||||
_e_
|
||||
3
|
||||
F
|
||||
_f_
|
||||
3
|
||||
G
|
||||
_g_
|
||||
4
|
||||
H
|
||||
_h_
|
||||
4
|
||||
I
|
||||
_i_
|
||||
3
|
||||
J
|
||||
_j_
|
||||
4
|
||||
K
|
||||
_k_
|
||||
4
|
||||
L
|
||||
_l_
|
||||
3
|
||||
M
|
||||
_m_
|
||||
5
|
||||
N
|
||||
_n_
|
||||
4
|
||||
O
|
||||
_o_
|
||||
4
|
||||
P
|
||||
_p_
|
||||
4
|
||||
Q
|
||||
_q_
|
||||
4
|
||||
R
|
||||
_r_
|
||||
4
|
||||
S
|
||||
_s_
|
||||
4
|
||||
T
|
||||
_t_
|
||||
3
|
||||
U
|
||||
_u_
|
||||
4
|
||||
V
|
||||
_v_
|
||||
4
|
||||
W
|
||||
_w_
|
||||
5
|
||||
X
|
||||
_x_
|
||||
4
|
||||
Y
|
||||
_y_
|
||||
4
|
||||
Z
|
||||
_z_
|
||||
3
|
||||
a
|
||||
_a
|
||||
4
|
||||
b
|
||||
_b
|
||||
4
|
||||
c
|
||||
_c
|
||||
3
|
||||
d
|
||||
_d
|
||||
4
|
||||
e
|
||||
_e
|
||||
4
|
||||
f
|
||||
_f
|
||||
3
|
||||
g
|
||||
_g
|
||||
4
|
||||
h
|
||||
_h
|
||||
4
|
||||
i
|
||||
_i
|
||||
1
|
||||
j
|
||||
_j
|
||||
2
|
||||
k
|
||||
_k
|
||||
4
|
||||
l
|
||||
_l
|
||||
1
|
||||
m
|
||||
_m
|
||||
5
|
||||
n
|
||||
_n
|
||||
4
|
||||
o
|
||||
_o
|
||||
4
|
||||
p
|
||||
_p
|
||||
4
|
||||
q
|
||||
_q
|
||||
4
|
||||
r
|
||||
_r
|
||||
3
|
||||
s
|
||||
_s
|
||||
4
|
||||
t
|
||||
_t
|
||||
3
|
||||
u
|
||||
_u
|
||||
4
|
||||
v
|
||||
_v
|
||||
4
|
||||
w
|
||||
_w
|
||||
5
|
||||
x
|
||||
_x
|
||||
3
|
||||
y
|
||||
_y
|
||||
4
|
||||
z
|
||||
_z
|
||||
4
|
||||
|
||||
_sp
|
||||
2
|
||||
0
|
||||
_0
|
||||
4
|
||||
1
|
||||
_1
|
||||
2
|
||||
2
|
||||
_2
|
||||
4
|
||||
3
|
||||
_3
|
||||
4
|
||||
4
|
||||
_4
|
||||
4
|
||||
5
|
||||
_5
|
||||
4
|
||||
6
|
||||
_6
|
||||
4
|
||||
7
|
||||
_7
|
||||
4
|
||||
8
|
||||
_8
|
||||
4
|
||||
9
|
||||
_9
|
||||
4
|
||||
(
|
||||
_bl
|
||||
2
|
||||
)
|
||||
_br
|
||||
2
|
||||
{
|
||||
_cl
|
||||
3
|
||||
}
|
||||
_cr
|
||||
3
|
||||
[
|
||||
_sl
|
||||
2
|
||||
]
|
||||
_sr
|
||||
2
|
||||
'
|
||||
_ap
|
||||
1
|
||||
!
|
||||
_ex
|
||||
1
|
||||
?
|
||||
_qu
|
||||
4
|
||||
@
|
||||
_at
|
||||
5
|
||||
#
|
||||
_hs
|
||||
5
|
||||
$
|
||||
_dl
|
||||
4
|
||||
%
|
||||
_pr
|
||||
5
|
||||
^
|
||||
_ca
|
||||
3
|
||||
&
|
||||
_am
|
||||
5
|
||||
*
|
||||
_as
|
||||
3
|
||||
_
|
||||
_un
|
||||
3
|
||||
+
|
||||
_ps
|
||||
3
|
||||
-
|
||||
_mn
|
||||
3
|
||||
=
|
||||
_eq
|
||||
3
|
||||
;
|
||||
_sm
|
||||
1
|
||||
,
|
||||
_cm
|
||||
2
|
||||
"
|
||||
_qo
|
||||
3
|
||||
/
|
||||
_dv
|
||||
5
|
||||
~
|
||||
_tl
|
||||
4
|
||||
<
|
||||
_lt
|
||||
3
|
||||
>
|
||||
_gt
|
||||
3
|
||||
\
|
||||
_re
|
||||
5
|
||||
|
|
||||
_vb
|
||||
1
|
||||
.
|
||||
_dt
|
||||
1
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,288 @@
|
|||
-- Font: 04.jp.org
|
||||
|
||||
-- load characters map
|
||||
local chars_file = io.open(minetest.get_modpath("signs").."/characters", "r")
|
||||
local charmap = {}
|
||||
local charwidth = {}
|
||||
local max_chars = 16
|
||||
if not chars_file then
|
||||
print("[signs] E: character map file not found")
|
||||
else
|
||||
while true do
|
||||
local char = chars_file:read("*l")
|
||||
if char == nil then
|
||||
break
|
||||
end
|
||||
local img = chars_file:read("*l")
|
||||
local width = chars_file:read("*n")
|
||||
chars_file:read("*l")
|
||||
charmap[char] = img
|
||||
charwidth[img] = width
|
||||
end
|
||||
end
|
||||
|
||||
--local metas = {"line1", "line2", "line3", "line4", "line5", "line6", "line7"}
|
||||
local signs = {
|
||||
{delta = {x = 0, y = 0, z = 0.399}, yaw = 0},
|
||||
{delta = {x = 0.399, y = 0, z = 0}, yaw = math.pi / -2},
|
||||
{delta = {x = 0, y = 0, z = -0.399}, yaw = math.pi},
|
||||
{delta = {x = -0.399, y = 0, z = 0}, yaw = math.pi / 2},
|
||||
}
|
||||
|
||||
local signs_yard = {
|
||||
{delta = {x = 0, y = 0, z = -0.05}, yaw = 0},
|
||||
{delta = {x = -0.05, y = 0, z = 0}, yaw = math.pi / -2},
|
||||
{delta = {x = 0, y = 0, z = 0.05}, yaw = math.pi},
|
||||
{delta = {x = 0.05, y = 0, z = 0}, yaw = math.pi / 2},
|
||||
}
|
||||
|
||||
local sign_groups = {choppy=2, dig_immediate=2}
|
||||
|
||||
local construct_sign = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", "field[text;;${text}]")
|
||||
meta:set_string("infotext", "")
|
||||
end
|
||||
|
||||
local destruct_sign = function(pos)
|
||||
local objects = minetest.env:get_objects_inside_radius(pos, 0.5)
|
||||
for _, v in ipairs(objects) do
|
||||
if v:get_entity_name() == "signs:text" then
|
||||
v:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local update_sign = function(pos, fields)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("infotext", "")
|
||||
meta:set_string("text", fields.text)
|
||||
local text = meta:get_string("text")
|
||||
local objects = minetest.env:get_objects_inside_radius(pos, 0.5)
|
||||
for _, v in ipairs(objects) do
|
||||
if v:get_entity_name() == "signs:text" then
|
||||
v:set_properties({textures={generate_texture(create_lines(text))}})
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- if there is no entity
|
||||
local sign_info
|
||||
if minetest.env:get_node(pos).name == "signs:sign_yard" then
|
||||
sign_info = signs_yard[minetest.env:get_node(pos).param2 + 1]
|
||||
elseif minetest.env:get_node(pos).name == "default:sign_wall" then
|
||||
sign_info = signs[minetest.env:get_node(pos).param2 + 1]
|
||||
end
|
||||
if sign_info == nil then
|
||||
return
|
||||
end
|
||||
local text = minetest.env:add_entity({x = pos.x + sign_info.delta.x,
|
||||
y = pos.y + sign_info.delta.y,
|
||||
z = pos.z + sign_info.delta.z}, "signs:text")
|
||||
text:setyaw(sign_info.yaw)
|
||||
end
|
||||
|
||||
minetest.register_node(":default:sign_wall", {
|
||||
description = "Sign",
|
||||
inventory_image = "default_sign_wall.png",
|
||||
wield_image = "default_sign_wall.png",
|
||||
node_placement_prediction = "",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
node_box = {type = "fixed", fixed = {-0.45, -0.15, 0.4, 0.45, 0.45, 0.498}},
|
||||
selection_box = {type = "fixed", fixed = {-0.45, -0.15, 0.4, 0.45, 0.45, 0.498}},
|
||||
tiles = {"signs_top.png", "signs_bottom.png", "signs_side.png", "signs_side.png", "signs_back.png", "signs_front.png"},
|
||||
walkable = false,
|
||||
groups = sign_groups,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
local dir = {x = under.x - above.x,
|
||||
y = under.y - above.y,
|
||||
z = under.z - above.z}
|
||||
|
||||
local wdir = minetest.dir_to_wallmounted(dir)
|
||||
|
||||
local placer_pos = placer:getpos()
|
||||
if placer_pos then
|
||||
dir = {
|
||||
x = above.x - placer_pos.x,
|
||||
y = above.y - placer_pos.y,
|
||||
z = above.z - placer_pos.z
|
||||
}
|
||||
end
|
||||
|
||||
local fdir = minetest.dir_to_facedir(dir)
|
||||
|
||||
local sign_info
|
||||
if wdir == 0 then
|
||||
--how would you add sign to ceiling?
|
||||
minetest.env:add_item(above, "default:sign_wall")
|
||||
return ItemStack("")
|
||||
elseif wdir == 1 then
|
||||
minetest.env:add_node(above, {name = "signs:sign_yard", param2 = fdir})
|
||||
sign_info = signs_yard[fdir + 1]
|
||||
else
|
||||
minetest.env:add_node(above, {name = "default:sign_wall", param2 = fdir})
|
||||
sign_info = signs[fdir + 1]
|
||||
end
|
||||
|
||||
local text = minetest.env:add_entity({x = above.x + sign_info.delta.x,
|
||||
y = above.y + sign_info.delta.y,
|
||||
z = above.z + sign_info.delta.z}, "signs:text")
|
||||
text:setyaw(sign_info.yaw)
|
||||
|
||||
return ItemStack("")
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
construct_sign(pos)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
destruct_sign(pos)
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
update_sign(pos, fields)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("signs:sign_yard", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
node_box = {type = "fixed", fixed = {
|
||||
{-0.45, -0.15, -0.049, 0.45, 0.45, 0.049},
|
||||
{-0.05, -0.5, -0.049, 0.05, -0.15, 0.049}
|
||||
}},
|
||||
selection_box = {type = "fixed", fixed = {-0.45, -0.15, -0.049, 0.45, 0.45, 0.049}},
|
||||
tiles = {"signs_top.png", "signs_bottom.png", "signs_side.png", "signs_side.png", "signs_back.png", "signs_front.png"},
|
||||
walkable = false,
|
||||
groups = {choppy=2, dig_immediate=2},
|
||||
drop = "default:sign_wall",
|
||||
|
||||
on_construct = function(pos)
|
||||
construct_sign(pos)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
destruct_sign(pos)
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
update_sign(pos, fields)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_entity("signs:text", {
|
||||
collisionbox = { 0, 0, 0, 0, 0, 0 },
|
||||
visual = "upright_sprite",
|
||||
textures = {},
|
||||
|
||||
on_activate = function(self)
|
||||
local meta = minetest.env:get_meta(self.object:getpos())
|
||||
local text = meta:get_string("text")
|
||||
self.object:set_properties({textures={generate_texture(create_lines(text))}})
|
||||
end
|
||||
})
|
||||
|
||||
local sign_width = 110
|
||||
local sign_padding = 8
|
||||
|
||||
string_to_array = function(str)
|
||||
local tab = {}
|
||||
for i=1,string.len(str) do
|
||||
table.insert(tab, string.sub(str, i,i))
|
||||
end
|
||||
return tab
|
||||
end
|
||||
|
||||
string_to_word_array = function(str)
|
||||
local tab = {}
|
||||
local current = 1
|
||||
tab[1] = ""
|
||||
for _,char in ipairs(string_to_array(str)) do
|
||||
if char ~= " " then
|
||||
tab[current] = tab[current]..char
|
||||
else
|
||||
current = current+1
|
||||
tab[current] = ""
|
||||
end
|
||||
end
|
||||
return tab
|
||||
end
|
||||
|
||||
LINE_LENGTH = 16
|
||||
NUMBER_OF_LINES = 7
|
||||
|
||||
create_lines = function(text)
|
||||
local line = ""
|
||||
local line_num = 1
|
||||
local tab = {}
|
||||
for _,word in ipairs(string_to_word_array(text)) do
|
||||
if string.len(line)+string.len(word) < LINE_LENGTH and word ~= "|" then
|
||||
if line ~= "" then
|
||||
line = line.." "..word
|
||||
else
|
||||
line = word
|
||||
end
|
||||
else
|
||||
table.insert(tab, line)
|
||||
if word ~= "|" then
|
||||
line = word
|
||||
else
|
||||
line = ""
|
||||
end
|
||||
line_num = line_num+1
|
||||
if line_num > NUMBER_OF_LINES then
|
||||
return tab
|
||||
end
|
||||
end
|
||||
end
|
||||
table.insert(tab, line)
|
||||
return tab
|
||||
end
|
||||
|
||||
generate_texture = function(lines)
|
||||
local texture = "[combine:"..sign_width.."x"..sign_width
|
||||
local ypos = 12
|
||||
for i = 1, #lines do
|
||||
texture = texture..generate_line(lines[i], ypos)
|
||||
ypos = ypos + 8
|
||||
end
|
||||
return texture
|
||||
end
|
||||
|
||||
generate_line = function(s, ypos)
|
||||
local i = 1
|
||||
local parsed = {}
|
||||
local width = 0
|
||||
local chars = 0
|
||||
while chars < max_chars and i <= #s do
|
||||
local file = nil
|
||||
if charmap[s:sub(i, i)] ~= nil then
|
||||
file = charmap[s:sub(i, i)]
|
||||
i = i + 1
|
||||
elseif i < #s and charmap[s:sub(i, i + 1)] ~= nil then
|
||||
file = charmap[s:sub(i, i + 1)]
|
||||
i = i + 2
|
||||
else
|
||||
print("[signs] W: unknown symbol in '"..s.."' at "..i.." (probably "..s:sub(i, i)..")")
|
||||
i = i + 1
|
||||
end
|
||||
if file ~= nil then
|
||||
width = width + charwidth[file] + 1
|
||||
table.insert(parsed, file)
|
||||
chars = chars + 1
|
||||
end
|
||||
end
|
||||
width = width - 1
|
||||
|
||||
local texture = ""
|
||||
local xpos = math.floor((sign_width - 2 * sign_padding - width) / 2 + sign_padding)
|
||||
for i = 1, #parsed do
|
||||
texture = texture..":"..xpos..","..ypos.."="..parsed[i]..".png"
|
||||
xpos = xpos + charwidth[parsed[i]] + 1
|
||||
end
|
||||
return texture
|
||||
end
|
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 144 B |
After Width: | Height: | Size: 156 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 153 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 144 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 156 B |
After Width: | Height: | Size: 128 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 153 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 145 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 149 B |
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 145 B |
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 128 B |
After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 139 B |
After Width: | Height: | Size: 142 B |
After Width: | Height: | Size: 149 B |
After Width: | Height: | Size: 149 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 144 B |
After Width: | Height: | Size: 139 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 135 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 142 B |
After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 158 B |
After Width: | Height: | Size: 153 B |
After Width: | Height: | Size: 156 B |
After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 140 B |
After Width: | Height: | Size: 156 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 158 B |
After Width: | Height: | Size: 156 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 143 B |
After Width: | Height: | Size: 141 B |
After Width: | Height: | Size: 128 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 143 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 142 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 135 B |
After Width: | Height: | Size: 142 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 149 B |
After Width: | Height: | Size: 158 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 277 B |
After Width: | Height: | Size: 132 B |
After Width: | Height: | Size: 263 B |