3 Commits

Author SHA1 Message Date
bd9707abfe format text message "too much lines" 2015-04-26 10:50:04 +02:00
0f7badedd9 check for protection before allowing to write on the sign 2015-04-03 10:38:51 +02:00
e2938bf17e improved linebreak.
removes now whitespaces before and after a linebreak.
2015-04-03 10:32:57 +02:00

View File

@ -110,19 +110,19 @@ arrow_signs.savetext = function(pos, formname, fields, sender)
minetest.chat_send_player(sender:get_player_name(), "error: you don't have permission to edit the sign. you need the interact priv")
return
end
if minetest.is_protected(pos, sender:get_player_name()) then
minetest.record_protection_violation(pos, sender:get_player_name())
return
end
local meta = minetest.get_meta(pos)
fields.text = fields.text or ""
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(),"Information: \nYou've written more than 5 lines. \nIt may be that not all lines are displayed. \nPlease remove the last entry")
end
return true
end
@ -130,9 +130,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", {