make longer lines in logfile readable
This commit is contained in:
parent
97c6741a4e
commit
258e990d7a
@ -84,6 +84,33 @@ yl_speak_up.input_show_log = function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- helper function for get_fs_show_log
|
||||||
|
-- text: list of string
|
||||||
|
yl_speak_up.show_log_add_line = function(text, last_day, last_who, last_line, same_lines)
|
||||||
|
-- split the line up so that it can actually be read
|
||||||
|
local line_parts = minetest.wrap_text(last_line, 75, true)
|
||||||
|
for i, p in ipairs(line_parts) do
|
||||||
|
if(i == 1) then
|
||||||
|
table.insert(text, '#AAAAAA')
|
||||||
|
table.insert(text, minetest.formspec_escape(last_day))
|
||||||
|
table.insert(text, '#FFFF00')
|
||||||
|
table.insert(text, minetest.formspec_escape(last_who))
|
||||||
|
table.insert(text, '#AAAAAA')
|
||||||
|
if(same_lines > 1) then
|
||||||
|
table.insert(text, tostring(same_lines).."x")
|
||||||
|
else
|
||||||
|
table.insert(text, "")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- do not repeat all the other entries - we just continue text
|
||||||
|
table.insert(text, '#AAAAAA,,#FFFF00,,#AAAAAA,')
|
||||||
|
end
|
||||||
|
table.insert(text, '#FFFFFF')
|
||||||
|
table.insert(text, minetest.formspec_escape(p))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- TODO: make use of log_type and toggle between trade entries and full log?
|
-- TODO: make use of log_type and toggle between trade entries and full log?
|
||||||
yl_speak_up.get_fs_show_log = function(player, log_type)
|
yl_speak_up.get_fs_show_log = function(player, log_type)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
@ -131,18 +158,7 @@ yl_speak_up.get_fs_show_log = function(player, log_type)
|
|||||||
-- just count the line
|
-- just count the line
|
||||||
same_lines = same_lines + 1
|
same_lines = same_lines + 1
|
||||||
else
|
else
|
||||||
table.insert(text, '#AAAAAA')
|
yl_speak_up.show_log_add_line(text, last_day, last_who, last_line, same_lines)
|
||||||
table.insert(text, minetest.formspec_escape(last_day))
|
|
||||||
table.insert(text, '#FFFF00')
|
|
||||||
table.insert(text, minetest.formspec_escape(last_who))
|
|
||||||
table.insert(text, '#AAAAAA')
|
|
||||||
if(same_lines > 1) then
|
|
||||||
table.insert(text, tostring(same_lines).."x")
|
|
||||||
else
|
|
||||||
table.insert(text, "")
|
|
||||||
end
|
|
||||||
table.insert(text, '#FFFFFF')
|
|
||||||
table.insert(text, minetest.formspec_escape(last_line))
|
|
||||||
-- store information about the next line
|
-- store information about the next line
|
||||||
same_lines = 0
|
same_lines = 0
|
||||||
last_line = this_line
|
last_line = this_line
|
||||||
@ -152,18 +168,7 @@ yl_speak_up.get_fs_show_log = function(player, log_type)
|
|||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
-- cover the last line
|
-- cover the last line
|
||||||
table.insert(text, '#AAAAAA')
|
yl_speak_up.show_log_add_line(text, last_day, last_who, last_line, same_lines)
|
||||||
table.insert(text, minetest.formspec_escape(last_day))
|
|
||||||
table.insert(text, '#FFFF00')
|
|
||||||
table.insert(text, minetest.formspec_escape(last_who))
|
|
||||||
table.insert(text, '#AAAAAA')
|
|
||||||
if(same_lines > 1) then
|
|
||||||
table.insert(text, tostring(same_lines).."x")
|
|
||||||
else
|
|
||||||
table.insert(text, "")
|
|
||||||
end
|
|
||||||
table.insert(text, '#FFFFFF')
|
|
||||||
table.insert(text, minetest.formspec_escape(last_line))
|
|
||||||
file:close()
|
file:close()
|
||||||
|
|
||||||
table.insert(formspec, table.concat(text, ','))
|
table.insert(formspec, table.concat(text, ','))
|
||||||
|
Loading…
Reference in New Issue
Block a user