forked from mtcontrib/arrow_signs
improved linebreak.
removes now whitespaces before and after a linebreak.
This commit is contained in:
parent
2907b3dd0c
commit
e2938bf17e
14
init.lua
14
init.lua
@ -115,13 +115,9 @@ 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
|
|
||||||
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")
|
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
|
||||||
@ -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", {
|
||||||
|
Loading…
Reference in New Issue
Block a user