1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-23 00:20:17 +01:00

Added the ability to place a sign onto a brass or wrought iron fence

uses code from PilzAdam's rework of thexyz's signs mod.
This commit is contained in:
Vanessa Ezekowitz 2013-02-08 02:31:40 -05:00
parent 94af6653fd
commit 178386ee53
111 changed files with 631 additions and 27 deletions

279
characters Normal file
View File

@ -0,0 +1,279 @@
A
_a_
7
B
_b_
5
C
_c_
6
D
_d_
6
E
_e_
5
F
_f_
5
G
_g_
6
H
_h_
6
I
_i_
1
J
_j_
4
K
_k_
5
L
_l_
4
M
_m_
7
N
_n_
6
O
_o_
6
P
_p_
5
Q
_q_
7
R
_r_
5
S
_s_
5
T
_t_
5
U
_u_
6
V
_v_
7
W
_w_
9
X
_x_
5
Y
_y_
7
Z
_z_
5
a
_a
5
b
_b
5
c
_c
4
d
_d
5
e
_e
4
f
_f
4
g
_g
5
h
_h
5
i
_i
1
j
_j
1
k
_k
4
l
_l
1
m
_m
7
n
_n
5
o
_o
5
p
_p
5
q
_q
5
r
_r
3
s
_s
4
t
_t
3
u
_u
4
v
_v
5
w
_w
7
x
_x
5
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

View File

@ -1321,6 +1321,29 @@ minetest.register_craft( {
},
})
-- the version of brass/wrought iron fences with signs attached
minetest.register_craft( {
type = "shapeless",
output = 'homedecor:fence_brass_with_sign',
recipe = {
'homedecor:fence_brass',
'default:sign_wall',
},
})
minetest.register_craft( {
type = "shapeless",
output = 'homedecor:fence_wrought_iron_with_sign',
recipe = {
'homedecor:fence_wrought_iron',
'default:sign_wall',
},
})
-- other types of fences/gates
minetest.register_craft( {
output = "homedecor:fence_picket 6",
recipe = {

View File

@ -7,7 +7,6 @@ minetest.register_node("homedecor:fence_brass", {
inventory_image = "homedecor_fence_brass.png",
wield_image = "homedecor_pole_brass.png",
paramtype = "light",
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
@ -17,6 +16,7 @@ minetest.register_node("homedecor:fence_brass", {
walkable = true,
})
minetest.register_node("homedecor:fence_wrought_iron", {
description = "Wrought Iron Fence/railing",
drawtype = "fencelike",
@ -24,7 +24,6 @@ minetest.register_node("homedecor:fence_wrought_iron", {
inventory_image = "homedecor_fence_wrought_iron.png",
wield_image = "homedecor_pole_wrought_iron.png",
paramtype = "light",
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
@ -34,6 +33,116 @@ minetest.register_node("homedecor:fence_wrought_iron", {
walkable = true,
})
-- brass/wrought iron with signs:
minetest.register_node("homedecor:fence_brass_with_sign", {
description = "Brass Fence/railing with sign",
drawtype = "nodebox",
tiles = {
"homedecor_sign_brass_post_top.png",
"homedecor_sign_brass_post_bottom.png",
"homedecor_sign_brass_post_side.png",
"homedecor_sign_brass_post_side.png",
"homedecor_sign_brass_post_back.png",
"homedecor_sign_brass_post_front.png",
},
inventory_image = "homedecor_sign_brass_post.png",
wield_image = "homedecor_sign_brass_post.png",
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{ -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 },
{ -0.45, -0.1875, -0.225, 0.45, 0.4375, -0.125 },
}
},
selection_box = {
type = "fixed",
fixed = {
{ -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 },
{ -0.45, -0.1875, -0.225, 0.45, 0.4375, -0.125 },
}
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
walkable = true,
drop = {
max_items = 2,
items = {
{ items = { "default:sign_wall" }},
{ items = { "homedecor:fence_brass" }},
},
},
on_construct = function(pos)
homedecor_construct_sign(pos)
end,
on_destruct = function(pos)
homedecor_destruct_sign(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
homedecor_update_sign(pos, fields)
end,
on_punch = function(pos, node, puncher)
homedecor_update_sign(pos)
end,
})
minetest.register_node("homedecor:fence_wrought_iron_with_sign", {
description = "Wrought Iron Fence/railing with sign",
drawtype = "nodebox",
tiles = {
"homedecor_sign_wrought_iron_post_top.png",
"homedecor_sign_wrought_iron_post_bottom.png",
"homedecor_sign_wrought_iron_post_side.png",
"homedecor_sign_wrought_iron_post_side.png",
"homedecor_sign_wrought_iron_post_back.png",
"homedecor_sign_wrought_iron_post_front.png",
},
inventory_image = "homedecor_sign_wrought_iron_post.png",
wield_image = "homedecor_sign_wrought_iron_post.png",
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{ -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 },
{ -0.45, -0.1875, -0.225, 0.45, 0.4375, -0.125 },
}
},
selection_box = {
type = "fixed",
fixed = {
{ -0.125, -0.5, -0.125, 0.125, 0.5, 0.125 },
{ -0.45, -0.1875, -0.225, 0.45, 0.4375, -0.125 },
}
},
groups = {snappy=3},
sounds = default.node_sound_wood_defaults(),
walkable = true,
drop = {
max_items = 2,
items = {
{ items = { "default:sign_wall" }},
{ items = { "homedecor:fence_wrought_iron" }},
},
},
on_construct = function(pos)
homedecor_construct_sign(pos)
end,
on_destruct = function(pos)
homedecor_destruct_sign(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
homedecor_update_sign(pos, fields)
end,
on_punch = function(pos, node, puncher)
homedecor_update_sign(pos)
end,
})
-- other types of fences
minetest.register_node("homedecor:fence_picket", {
drawtype = "nodebox",
description = "Unpainted Picket Fence",

View File

@ -793,8 +793,10 @@ end
dofile(minetest.get_modpath("homedecor").."/door_models.lua")
dofile(minetest.get_modpath("homedecor").."/door_nodes.lua")
dofile(minetest.get_modpath("homedecor").."/lighting.lua")
dofile(minetest.get_modpath("homedecor").."/signs_lib.lua")
dofile(minetest.get_modpath("homedecor").."/fences.lua")
dofile(minetest.get_modpath("homedecor").."/lighting.lua")
dofile(minetest.get_modpath("homedecor").."/kitchen_cabinet.lua")
dofile(minetest.get_modpath("homedecor").."/refrigerator.lua")
dofile(minetest.get_modpath("homedecor").."/oven.lua")

191
signs_lib.lua Normal file
View File

@ -0,0 +1,191 @@
-- This code was borrowed from Pilzadam's rework of thexyz's signs mod
-- Font: 04.jp.org
-- load characters map
local chars_file = io.open(minetest.get_modpath("homedecor").."/characters", "r")
local charmap = {}
local max_chars = 16
if not chars_file then
print("[homedecor] 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")
chars_file:read("*l")
charmap[char] = img
end
end
local signs_post = {
{delta = {x = 0, y = 0, z = -0.226}, yaw = 0},
{delta = {x = -0.226, y = 0, z = 0}, yaw = math.pi / -2},
{delta = {x = 0, y = 0, z = 0.226}, yaw = math.pi},
{delta = {x = 0.226, y = 0, z = 0}, yaw = math.pi / 2},
}
homedecor_construct_sign = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", "field[text;;${text}]")
meta:set_string("infotext", "")
end
homedecor_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() == "homedecor:sign_text" then
v:remove()
end
end
end
homedecor_update_sign = function(pos, fields)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "")
if fields then
meta:set_string("text", fields.text)
end
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() == "homedecor:sign_text" then
v:set_properties({textures={homedecor_generate_texture(homedecor_create_lines(text))}})
return
end
end
-- if there is no entity
local sign_info
if minetest.env:get_node(pos).name == "homedecor:fence_brass_with_sign"
or minetest.env:get_node(pos).name == "homedecor:fence_wrought_iron_with_sign" then
sign_info = signs_post[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}, "homedecor:sign_text")
text:setyaw(sign_info.yaw)
end
minetest.register_entity("homedecor:sign_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={homedecor_generate_texture(homedecor_create_lines(text))}})
end
})
-- CONSTANTS
local SIGN_WITH = 110
local SIGN_PADDING = 8
local LINE_LENGTH = 16
local NUMBER_OF_LINES = 4
local LINE_HEIGHT = 14
local CHAR_WIDTH = 5
homedecor_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
homedecor_string_to_word_array = function(str)
local tab = {}
local current = 1
tab[1] = ""
for _,char in ipairs(homedecor_string_to_array(str)) do
if char ~= " " then
tab[current] = tab[current]..char
else
current = current+1
tab[current] = ""
end
end
return tab
end
homedecor_create_lines = function(text)
local line = ""
local line_num = 1
local tab = {}
for _,word in ipairs(homedecor_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
homedecor_generate_texture = function(lines)
local texture = "[combine:"..SIGN_WITH.."x"..SIGN_WITH
local ypos = 12
for i = 1, #lines do
texture = texture..homedecor_generate_line(lines[i], ypos)
ypos = ypos + LINE_HEIGHT
end
return texture
end
homedecor_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("[homedecor] W: unknown symbol in '"..s.."' at "..i.." (probably "..s:sub(i, i)..")")
i = i + 1
end
if file ~= nil then
width = width + CHAR_WIDTH
table.insert(parsed, file)
chars = chars + 1
end
end
width = width - 1
local texture = ""
local xpos = math.floor((SIGN_WITH - 2 * SIGN_PADDING - width) / 2 + SIGN_PADDING)
for i = 1, #parsed do
texture = texture..":"..xpos..","..ypos.."="..parsed[i]..".png"
xpos = xpos + CHAR_WIDTH + 1
end
return texture
end

BIN
textures/_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
textures/_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

BIN
textures/_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

BIN
textures/_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

BIN
textures/_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

BIN
textures/_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
textures/_6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
textures/_7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

BIN
textures/_8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

BIN
textures/_9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

BIN
textures/_a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

BIN
textures/_a_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

BIN
textures/_am.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
textures/_ap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

BIN
textures/_as.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

BIN
textures/_at.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

BIN
textures/_b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

BIN
textures/_b_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

BIN
textures/_bl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
textures/_br.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
textures/_c.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

BIN
textures/_c_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
textures/_ca.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

BIN
textures/_cl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

BIN
textures/_cm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

BIN
textures/_cr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

BIN
textures/_d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

BIN
textures/_d_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
textures/_dl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
textures/_dt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

BIN
textures/_dv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

BIN
textures/_e.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

BIN
textures/_e_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

BIN
textures/_eq.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

BIN
textures/_ex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

BIN
textures/_f.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

BIN
textures/_f_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
textures/_g.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

BIN
textures/_g_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

BIN
textures/_gt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

BIN
textures/_h.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

BIN
textures/_h_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

BIN
textures/_ha.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

BIN
textures/_hs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

BIN
textures/_i.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
textures/_i_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
textures/_j.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

BIN
textures/_j_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

BIN
textures/_k.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

BIN
textures/_k_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

BIN
textures/_l.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

BIN
textures/_l_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

BIN
textures/_lt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

BIN
textures/_m.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

BIN
textures/_m_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

BIN
textures/_mn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

BIN
textures/_n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

BIN
textures/_n_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

BIN
textures/_o.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

BIN
textures/_o_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
textures/_p.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

BIN
textures/_p_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
textures/_pr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

BIN
textures/_ps.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

BIN
textures/_q.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

BIN
textures/_q_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

BIN
textures/_qo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

BIN
textures/_qu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

BIN
textures/_r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

BIN
textures/_r_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

BIN
textures/_re.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

BIN
textures/_s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
textures/_s_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

BIN
textures/_sl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

BIN
textures/_sm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

BIN
textures/_sp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

BIN
textures/_sr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

BIN
textures/_t.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

BIN
textures/_t_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

BIN
textures/_tl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

BIN
textures/_u.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

BIN
textures/_u_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

BIN
textures/_un.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

BIN
textures/_v.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

BIN
textures/_v_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
textures/_vb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

BIN
textures/_w.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

BIN
textures/_w_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

BIN
textures/_x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

BIN
textures/_x_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
textures/_y.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
textures/_y_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

BIN
textures/_z.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

BIN
textures/_z_.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

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