Modul:X: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 14: | Zeile 14: | ||
function p.cut( frame ) | function p.cut( frame ) | ||
realtext = frame.args[2] | realtext = frame.args[2] --fiick dich halli | ||
srealtext = split(realtext, " ") | srealtext = split(realtext, " ") --fiick|dich|halli(list) | ||
i = 2; --2 | i = 2; --2 | ||
limit = tonumber(frame.args[1]) -- | limit = tonumber(frame.args[1]) --6 | ||
text = display(frame.args[2]) --fiick dich | text = display(frame.args[2]) --fiick dich halli | ||
stext = split(text, " ")--fiick|dich(list) | stext = split(text, " ") --fiick|dich|halli(list) | ||
if(table.getn(stext)==1) then | if(table.getn(stext)==1) then | ||
Zeile 29: | Zeile 29: | ||
end | end | ||
cuttext = stext[1]--fiick | cuttext = stext[1] --fiick | ||
realcuttext = srealtext[1] | realcuttext = srealtext[1] --fiick | ||
nextwo = stext[2]--dich | nextwo = stext[2] --dich | ||
realnextwo = srealtext[2]--dich | realnextwo = srealtext[2] --dich | ||
nextlen = string.len(nextwo)--4 | nextlen = string.len(nextwo)--4 | ||
textlen = string.len(text)-- | textlen = string.len(text)--16 | ||
cuttextlen = string.len(cuttext)--5 | cuttextlen = string.len(cuttext)--5 | ||
set = true; | set = true; | ||
if(limit>=textlen)then -- | if(limit>=textlen)then --6>=16 | ||
return realtext.."%@%" | return realtext.."%@%" | ||
elseif(cuttextlen>limit) then--5> | elseif(cuttextlen>limit) then--5>6 | ||
return "%@%"..realtext | return "%@%"..realtext | ||
Zeile 51: | Zeile 51: | ||
else | else | ||
while (cuttextlen+nextlen+1< | while (cuttextlen+nextlen+1<textlen+2) do --5+4+1<=16+2(10<=18)| | ||
if(cuttextlen+nextlen+1>=limit and set) then --5+4> | if(cuttextlen+nextlen+1>=limit and set) then --5+4+1>=6(10>=6)| | ||
set = false | set = false | ||
cuttext = cuttext.."%@%" | cuttext = cuttext.."%@%" --fiick%@% | ||
realcuttext = realcuttext.."%@%" | realcuttext = realcuttext.."%@%" --fiick%@% | ||
else | else | ||
Zeile 66: | Zeile 66: | ||
i = i + 1 --3 | i = i + 1 --3 | ||
cuttext = cuttext..nextwo -- | cuttext = cuttext..nextwo -- fiick%@%dich | ||
realcuttext = realcuttext..realnextwo | realcuttext = realcuttext..realnextwo -- fiick%@%dich | ||
nextwo = stext[i]-- halli | nextwo = stext[i]-- halli | ||
Zeile 73: | Zeile 73: | ||
nextlen = string.len(nextwo) -- 5 | nextlen = string.len(nextwo) -- 5 | ||
cuttextlen = string.len(cuttext) -- | cuttextlen = string.len(cuttext) -- 12 | ||
end | end | ||
end | end | ||
return | return realcuttext | ||
end | end | ||
Version vom 19. Januar 2020, 17:56 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 )
realtext = frame.args[2] --fiick dich halli
srealtext = split(realtext, " ") --fiick|dich|halli(list)
i = 2; --2
limit = tonumber(frame.args[1]) --6
text = display(frame.args[2]) --fiick dich halli
stext = split(text, " ") --fiick|dich|halli(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
realcuttext = srealtext[1] --fiick
nextwo = stext[2] --dich
realnextwo = srealtext[2] --dich
nextlen = string.len(nextwo)--4
textlen = string.len(text)--16
cuttextlen = string.len(cuttext)--5
set = true;
if(limit>=textlen)then --6>=16
return realtext.."%@%"
elseif(cuttextlen>limit) then--5>6
return "%@%"..realtext
else
while (cuttextlen+nextlen+1<textlen+2) do --5+4+1<=16+2(10<=18)|
if(cuttextlen+nextlen+1>=limit and set) then --5+4+1>=6(10>=6)|
set = false
cuttext = cuttext.."%@%" --fiick%@%
realcuttext = realcuttext.."%@%" --fiick%@%
else
cuttext = cuttext.." "
realcuttext = realcuttext.." "
end
i = i + 1 --3
cuttext = cuttext..nextwo -- fiick%@%dich
realcuttext = realcuttext..realnextwo -- fiick%@%dich
nextwo = stext[i]-- halli
realnextwo = srealtext[i]-- halli
nextlen = string.len(nextwo) -- 5
cuttextlen = string.len(cuttext) -- 12
end
end
return realcuttext
end
function cut( limit, text )
realtext = text
srealtext = split(realtext, " ")
i = 2; --2
text = display(text) --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
realcuttext = srealtext[1]
nextwo = stext[2]--dich
realnextwo = srealtext[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
realcuttext = realcuttext..realnextwo
nextwo = stext[i]-- halli
realnextwo = stext[i]-- halli
nextlen = string.len(nextwo) -- 5
cuttextlen = string.len(cuttext) -- 11
end
realcuttext = realcuttext.." "..realnextwo
return split(realcuttext, "%@%")
end
end
function p.cutblock ( frame )
text = frame.args[3]
width = frame.args[2]
height = frame.args[1]
block = {}
rest = ""
end
function p.display ( frame )
text = frame.args[1]
text = text:gsub("'", "")
text = text:gsub("<.*>", "")
text = text:gsub("%[%[.*|", "")
text = text:gsub("%[", "")
text = text:gsub("%|", "")
text = text:gsub("%]", "")
return text
end
function display ( text )
text = text:gsub("'", "")
text = text:gsub("<.*>", "")
text = text:gsub("%[%[.*|", "")
text = text:gsub("%[", "")
text = text:gsub("%|", "")
text = text:gsub("%]", "")
return text
end
return p