improved linebreak.

removes now whitespaces before and after a linebreak.
This commit is contained in:
adrido 2015-04-03 10:32:57 +02:00
parent 2907b3dd0c
commit e2938bf17e

View File

@ -115,14 +115,10 @@ arrow_signs.savetext = function(pos, formname, fields, sender)
minetest.log("action", (sender:get_player_name() or "").." wrote \""..fields.text..
"\" to sign at "..minetest.pos_to_string(pos));
meta:set_string("text", fields.text)
local text = arrow_signs.create_lines(fields.text)
local text,lines = arrow_signs.create_lines(fields.text)
meta:set_string("infotext", '"'..text..'"')
local i=0
for wort in text:gfind("\n") do
i=i+1
end
if i > 4 then
minetest.chat_send_player(sender:get_player_name(),"\tInformation: \nYou've written more than 5 lines. \n it may be that not all lines are displayed. \n Please remove the last entry")
if lines > 4 then
minetest.chat_send_player(sender:get_player_name(),"\tInformation: \nYou've written more than 5 lines. \n it may be that not all lines are displayed. \n Please remove the last entry")
end
return true
end
@ -130,9 +126,9 @@ end
--this function creates the linebreaks
arrow_signs.create_lines = function(text)
text = text:gsub("/", "\"\n\"")
text = text:gsub("|", "\"\n\"")
return text
local text, n = text:gsub("[ ]*(%|)[ ]*", '"\n"')--search for |
local text, m = text:gsub("[ ]*(%/)[ ]*", '"\n"')--search for /
return text, n+m
end
minetest.override_item("default:sign_wall", {