when the world loads and the player spawns in, or is
teleported to the same node space as a sign, occasionally, the
player's model goes flat and their skin gets changed to the
whatever the sign's text is.
Also, when checking if an entity needs spawned, or when
deleting, try to make absolutely sure that only sign-related
entities will be selected for re-use, or selected for deletion
(we don't want some player's prize cow to be deleted)
I think this will fix it, or at least it'll surely prevent
signs_lib from being able to cause it.
Also, moved another function to the entity-handling section of
the file and made it global (signs_lib namespace) in the
process.
function signs_lib.delete_objects(pos)
local objects = minetest.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do
function signs_lib.delete_objects(pos)
local objects = minetest.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do
+ if v then
+ local e = v:get_luaentity()
+ if e and string.match(e.name, "sign.*text") then
+ v:remove()
+ end
+ end
local obj
if #objects > 0 then
local obj
if #objects > 0 then
- obj = objects[1]
- else
+ for _, v in ipairs(objects) do
+ if v then
+ local e = v:get_luaentity()
+ if e and e.name == "signs_lib:text" then
+ obj = v
+ end
+ end
+ end
+ end
+
+ if not obj then
obj = minetest.add_entity(pos, "signs_lib:text")
end
obj = minetest.add_entity(pos, "signs_lib:text")
end
+function signs_lib.set_obj_text(pos, text)
+ local split = signs_lib.split_lines_and_words
+ local text_ansi = Utf8ToAnsi(text)
+ local n = minetest.registered_nodes[minetest.get_node(pos).name]
+ signs_lib.delete_objects(pos)
+ signs_lib.spawn_entity(pos, signs_lib.make_sign_texture(split(text_ansi), pos) )
+end
+
-- rotation
function signs_lib.handle_rotation(pos, node, user, mode)
-- rotation
function signs_lib.handle_rotation(pos, node, user, mode)
minetest.swap_node(tpos, { name = node.name, param2 = signs_lib.rotate_facedir[node.param2] or 0 })
end
minetest.swap_node(tpos, { name = node.name, param2 = signs_lib.rotate_facedir[node.param2] or 0 })
end
- signs_lib.delete_objects(tpos)
signs_lib.update_sign(tpos)
return true
end
signs_lib.update_sign(tpos)
return true
end
return table.concat(texture), lineno
end
return table.concat(texture), lineno
end
-local function make_sign_texture(lines, pos)
+function signs_lib.make_sign_texture(lines, pos)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
-function signs_lib.set_obj_text(pos, text)
- local split = signs_lib.split_lines_and_words
- local text_ansi = Utf8ToAnsi(text)
- local n = minetest.registered_nodes[minetest.get_node(pos).name]
- signs_lib.delete_objects(pos)
- signs_lib.spawn_entity(pos, make_sign_texture(split(text_ansi), pos))
-end
-
function signs_lib.construct_sign(pos)
local form = "size[6,4]"..
"textarea[0,-0.3;6.5,3;text;;${text}]"..
function signs_lib.construct_sign(pos)
local form = "size[6,4]"..
"textarea[0,-0.3;6.5,3;text;;${text}]"..
minetest.swap_node(pos, {name = basename, param2 = node.param2})
local meta = minetest.get_meta(pos)
meta:set_int("widefont", 1)
minetest.swap_node(pos, {name = basename, param2 = node.param2})
local meta = minetest.get_meta(pos)
meta:set_int("widefont", 1)
- signs_lib.delete_objects(pos)
signs_lib.update_sign(pos)
end
})
signs_lib.update_sign(pos)
end
})