master
hunterdelyx1 2014-01-28 17:43:16 +04:00
parent fc97204573
commit a3b758be1f
120 changed files with 716 additions and 0 deletions

315
signs/characters Normal file
View File

@ -0,0 +1,315 @@
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
А
_a_rus
4
Б
_b_rus
4
В
_v_rus
4
Г
_g_rus
4
Д
_d_rus
5
Е
_e_rus
4
а
a_rus
4
б
b_rus
4
в
v_rus
4
г
g_rus
4
д
d_rus
5
е
e_rus
4

1
signs/depends.txt Normal file
View File

@ -0,0 +1 @@
default

400
signs/init.lua Normal file
View File

@ -0,0 +1,400 @@
-- Font: 04.jp.org
-- avoiding of bug with russian input =========================================================================================================
local crutch_table = {
["233131144"]="А",
["235131144"]="а",
["233135144"]="Б",
["235135144"]="б",
["233139144"]="В",
["235139144"]="в",
["233143144"]="Г",
["235143144"]="г",
["233147144"]="Д",
["235147144"]="д",
["233151144"]="Е",
["235151144"]="е",
["232135144"]="Ё",
["233135145"]="ё",
["233155144"]="Ж",
["235155144"]="ж",
["233159144"]="З",
["235159144"]="з",
["233163144"]="И",
["235163144"]="и",
["233167144"]="Й",
["235167144"]="й",
["233171144"]="К",
["235171144"]="к",
["233175144"]="Л",
["235175144"]="л",
["233179144"]="М",
["235179144"]="м",
["233183144"]="Н",
["235183144"]="н",
["233187144"]="О",
["235187144"]="о",
["233191144"]="П",
["235191144"]="п",
["234131144"]="Р",
["232131145"]="р",
["234135144"]="С",
["232135145"]="с",
["234139144"]="Т",
["232139145"]="т",
["234143144"]="У",
["232143145"]="у",
["234147144"]="Ф",
["232147145"]="ф",
["234151144"]="Х",
["232151145"]="х",
["234155144"]="Ц",
["232155145"]="ц",
["234159144"]="Ч",
["232159145"]="ч",
["234163144"]="Ш",
["232163145"]="ш",
["234167144"]="Щ",
["232167145"]="щ",
["234171144"]="Ъ",
["232171145"]="ъ",
["234175144"]="Ы",
["232175145"]="ы",
["234179144"]="Ь",
["232179145"]="ь",
["234183144"]="Э",
["232183145"]="э",
["234187144"]="Ю",
["232187145"]="ю",
["234191144"]="Я",
["232191145"]="я"
};
function tobytes(str)
i=1
byte={}
while i<=#str do
table.insert(byte, string.byte(string.sub(str, i, i)))
i=i+1
end
return byte;
end
function string.km_rus_crutch_regen(str)
byte=tobytes(str)
text=""
if byte[1]~=nil then
i=1
repeat
if byte[i]>128 then
if byte[i+2]~=nil and byte[i+1]~=nil and byte[i] then
tmp = byte[i]..byte[i+1]..byte[i+2]
else
tmp = "0"
end
if crutch_table[tmp]~=nil then
char = crutch_table[tmp]
i=i+3
else
char = string.sub(str, i, i+1)
i=i+2
end
else
char=string.sub(str, i, i)
i=i+1
end
text=text..char
until i>#byte
end
return text
end
-- ============================================================================================================================================
minetest.register_craft({
output = "signs:sign",
recipe = {
{"default:wood", "default:wood", "default:wood"},
{"default:wood", "default:wood", "default:wood"},
{"", "", ""}
}
})
-- 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", "size[7,8]"..
"field[1,0;6,3;line1;;${line1}]"..
"field[1,1;6,3;line2;;${line2}]"..
"field[1,2;6,3;line3;;${line3}]"..
"field[1,3;6,3;line4;;${line4}]"..
"field[1,4;6,3;line5;;${line5}]"..
"field[1,5;6,3;line6;;${line6}]"..
"field[1,6;6,3;line7;;${line7}]")
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)
local text = {}
for _, v in ipairs(metas) do
table.insert(text, fields[v])
meta:set_string(v, fields[v])
end
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(text)}})
end
end
end
minetest.register_node("signs:sign", {
description = "Sign",
inventory_image = "signs_sign.png",
wield_image = "signs_sign.png",
stack_max = 1,
node_placement_prediction = "",
paramtype = "light",
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, "signs:sign")
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 = "signs:sign", 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)
-- avoiding of bug with russian input =========================================================================================================
line_cycle=1; --cycle parametr
while line_cycle<8 do
fields["line"..line_cycle]= string.km_rus_crutch_regen(fields["line"..line_cycle])
line_cycle=line_cycle+1
end
--end==========================================================================================================================================
update_sign(pos, fields)
end,
})
minetest.register_node("signs:sign_yard", {
paramtype = "light",
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 = "signs:sign",
on_construct = function(pos)
construct_sign(pos)
end,
on_destruct = function(pos)
destruct_sign(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
-- avoiding of bug with russian input =========================================================================================================
line_cycle=1; --cycle parametr
while line_cycle<8 do
fields["line"..line_cycle]= string.km_rus_crutch_regen(fields["line"..line_cycle])
line_cycle=line_cycle+1
end
--end==========================================================================================================================================
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 = {}
for _, v in ipairs(metas) do
table.insert(text, meta:get_string(v))
end
self.object:set_properties({textures={generate_texture(text)}})
end
})
local sign_width = 110
local sign_padding = 8
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

BIN
signs/textures/_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

BIN
signs/textures/_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

BIN
signs/textures/_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
signs/textures/_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

BIN
signs/textures/_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

BIN
signs/textures/_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
signs/textures/_6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

BIN
signs/textures/_7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

BIN
signs/textures/_9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

BIN
signs/textures/_a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

BIN
signs/textures/_a_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

BIN
signs/textures/_am.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
signs/textures/_ap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

BIN
signs/textures/_as.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_at.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

BIN
signs/textures/_b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
signs/textures/_b_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

BIN
signs/textures/_b_rus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

BIN
signs/textures/_bl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

BIN
signs/textures/_br.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

BIN
signs/textures/_c.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

BIN
signs/textures/_c_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

BIN
signs/textures/_ca.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
signs/textures/_cl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

BIN
signs/textures/_cm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

BIN
signs/textures/_cr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

BIN
signs/textures/_d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

BIN
signs/textures/_d_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

BIN
signs/textures/_d_rus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

BIN
signs/textures/_dl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

BIN
signs/textures/_dt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

BIN
signs/textures/_dv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

BIN
signs/textures/_e.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_e_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

BIN
signs/textures/_e_rus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

BIN
signs/textures/_eq.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

BIN
signs/textures/_ex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
signs/textures/_f.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
signs/textures/_f_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
signs/textures/_g.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

BIN
signs/textures/_g_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

BIN
signs/textures/_g_rus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

BIN
signs/textures/_gt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
signs/textures/_h.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

BIN
signs/textures/_h_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

BIN
signs/textures/_hs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

BIN
signs/textures/_i.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

BIN
signs/textures/_i_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

BIN
signs/textures/_j.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

BIN
signs/textures/_j_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

BIN
signs/textures/_k.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

BIN
signs/textures/_k_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

BIN
signs/textures/_l.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

BIN
signs/textures/_l_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

BIN
signs/textures/_lt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_m.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_m_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

BIN
signs/textures/_m_rus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

BIN
signs/textures/_mn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
signs/textures/_n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

BIN
signs/textures/_n_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

BIN
signs/textures/_o.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

BIN
signs/textures/_o_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

BIN
signs/textures/_p.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

BIN
signs/textures/_p_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
signs/textures/_pr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
signs/textures/_ps.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

BIN
signs/textures/_q.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

BIN
signs/textures/_q_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

BIN
signs/textures/_qo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

BIN
signs/textures/_qu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
signs/textures/_r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_r_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_re.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

BIN
signs/textures/_s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
signs/textures/_s_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

BIN
signs/textures/_sl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

BIN
signs/textures/_sm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

BIN
signs/textures/_sp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

BIN
signs/textures/_sr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
signs/textures/_t.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
signs/textures/_t_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

BIN
signs/textures/_tl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_u.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_u_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_un.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
signs/textures/_v.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
signs/textures/_v_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

BIN
signs/textures/_v_rus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

BIN
signs/textures/_vb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

BIN
signs/textures/_w.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
signs/textures/_w_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

BIN
signs/textures/_x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
signs/textures/_x_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
signs/textures/_x_rus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
signs/textures/_y.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Some files were not shown because too many files have changed in this diff Show More