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
1 changed files with 6 additions and 10 deletions

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.. minetest.log("action", (sender:get_player_name() or "").." wrote \""..fields.text..
"\" to sign at "..minetest.pos_to_string(pos)); "\" to sign at "..minetest.pos_to_string(pos));
meta:set_string("text", fields.text) 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..'"') meta:set_string("infotext", '"'..text..'"')
local i=0 if lines > 4 then
for wort in text:gfind("\n") do 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")
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")
end end
return true return true
end end
@ -130,9 +126,9 @@ end
--this function creates the linebreaks --this function creates the linebreaks
arrow_signs.create_lines = function(text) arrow_signs.create_lines = function(text)
text = text:gsub("/", "\"\n\"") local text, n = text:gsub("[ ]*(%|)[ ]*", '"\n"')--search for |
text = text:gsub("|", "\"\n\"") local text, m = text:gsub("[ ]*(%/)[ ]*", '"\n"')--search for /
return text return text, n+m
end end
minetest.override_item("default:sign_wall", { minetest.override_item("default:sign_wall", {