Modul:X: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 12: | Zeile 12: | ||
end | end | ||
function p. | function p.cut( frame ) | ||
i = 2; --2 | i = 2; --2 | ||
Zeile 60: | Zeile 60: | ||
end | end | ||
function cut( limit, text ) | |||
i = 2; --2 | |||
limit = limit | |||
stext = split(text, " ")--fiick|dich(list) | |||
if(table.getn(stext)==1) then | |||
if(string.len(stext[1])>limit) then | |||
return "%@%"..text | |||
else | |||
return text.."%@%" | |||
end | |||
end | |||
cuttext = stext[1]--fiick | |||
nextwo = stext[2]--dich | |||
nextlen = string.len(nextwo)--4 | |||
textlen = string.len(text)--10 | |||
cuttextlen = string.len(cuttext)--5 | |||
set = true; | |||
if(limit>=textlen)then --9>=10 | |||
return text.."%@%" | |||
elseif(cuttextlen>limit) then--5>9 | |||
return "%@%"..text | |||
elseif(cuttextlen+nextlen+1>=limit) then--5>9 | |||
return cuttext.." "..nextwo.."%@%" | |||
else | |||
while (cuttextlen+nextlen+1<=textlen+2) do -- | |||
if(cuttextlen+nextlen>=limit and set) then --5+4>9(9>=9) | |||
set = false | |||
cuttext = cuttext.."%@%" | |||
else | |||
cuttext = cuttext.." " | |||
end | |||
i = i + 1 --3 | |||
cuttext = cuttext..nextwo -- fick%@%dich | |||
nextwo = stext[i]-- halli | |||
nextlen = string.len(nextwo) -- 5 | |||
cuttextlen = string.len(cuttext) -- 11 | |||
end | |||
cuttext = cuttext.." "..nextwo | |||
return split(text, "%@%") | |||
end | |||
end | |||
Version vom 13. Januar 2020, 21:44 Uhr
Die Dokumentation für dieses Modul kann unter Modul:X/Doku erstellt werden
local p = {} --local p = {} -- p steht für Paket (engl. package)
function split (inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
function p.cut( frame )
i = 2; --2
limit = tonumber(frame.args[1]) --9
text = frame.args[2] --fiick dich
stext = split(text, " ")--fiick|dich(list)
if(table.getn(stext)==1) then
if(string.len(stext[1])>limit) then
return "%@%"..text
else
return text.."%@%"
end
end
cuttext = stext[1]--fiick
nextwo = stext[2]--dich
nextlen = string.len(nextwo)--4
textlen = string.len(text)--10
cuttextlen = string.len(cuttext)--5
set = true;
if(limit>=textlen)then --9>=10
return text.."%@%"
elseif(cuttextlen>limit) then--5>9
return "%@%"..text
elseif(cuttextlen+nextlen+1>=limit) then--5>9
return cuttext.." "..nextwo.."%@%"
else
while (cuttextlen+nextlen+1<=textlen+2) do --
if(cuttextlen+nextlen>=limit and set) then --5+4>9(9>=9)
set = false
cuttext = cuttext.."%@%"
else
cuttext = cuttext.." "
end
i = i + 1 --3
cuttext = cuttext..nextwo -- fick%@%dich
nextwo = stext[i]-- halli
nextlen = string.len(nextwo) -- 5
cuttextlen = string.len(cuttext) -- 11
end
cuttext = cuttext.." "..nextwo
return cuttext
end
end
function cut( limit, text )
i = 2; --2
limit = limit
stext = split(text, " ")--fiick|dich(list)
if(table.getn(stext)==1) then
if(string.len(stext[1])>limit) then
return "%@%"..text
else
return text.."%@%"
end
end
cuttext = stext[1]--fiick
nextwo = stext[2]--dich
nextlen = string.len(nextwo)--4
textlen = string.len(text)--10
cuttextlen = string.len(cuttext)--5
set = true;
if(limit>=textlen)then --9>=10
return text.."%@%"
elseif(cuttextlen>limit) then--5>9
return "%@%"..text
elseif(cuttextlen+nextlen+1>=limit) then--5>9
return cuttext.." "..nextwo.."%@%"
else
while (cuttextlen+nextlen+1<=textlen+2) do --
if(cuttextlen+nextlen>=limit and set) then --5+4>9(9>=9)
set = false
cuttext = cuttext.."%@%"
else
cuttext = cuttext.." "
end
i = i + 1 --3
cuttext = cuttext..nextwo -- fick%@%dich
nextwo = stext[i]-- halli
nextlen = string.len(nextwo) -- 5
cuttextlen = string.len(cuttext) -- 11
end
cuttext = cuttext.." "..nextwo
return split(text, "%@%")
end
end
return p