Modul:X: Unterschied zwischen den Versionen

Aus How to be a Hero
Wechseln zu: Navigation, Suche
 
(218 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 2: Zeile 2:
  
 
function split (inputstr, sep)
 
function split (inputstr, sep)
 +
 
         if sep == nil then
 
         if sep == nil then
 
                 sep = "%s"
 
                 sep = "%s"
Zeile 11: Zeile 12:
 
         return t
 
         return t
 
end
 
end
 +
 +
function tablelength(T)
 +
  local count = 0
 +
  for _ in pairs(T) do count = count + 1 end
 +
  return count
 +
end
 +
  
 
function p.cut( frame )
 
function p.cut( frame )
 +
testtext = ""
 +
realtext = frame.args[2] --Die Schmiede
 +
realtext = removespaceinlink(realtext) --Die Schmiede
 +
srealtext = split(realtext, " ") --Die|Schmiede(list)
 +
i = 2; --2
 +
testtext = testtext.."<br \>"..i..": "
 +
limit = tonumber(frame.args[1]) --4
 +
text = display(removespaceinlink(realtext)) --Die Schmiede
 +
stext = split(text, " ") --Die|Schmiede(list)
 
 
realtext = frame.args[2]
 
srealtext = split(realtext, " ")
 
i = 2; --2
 
limit = tonumber(frame.args[1]) --9
 
text = display(frame.args[2]) --fiick dich
 
stext = split(text, " ")--fiick|dich(list)
 
 
if(table.getn(stext)==1) then
 
if(table.getn(stext)==1) then
 
if(string.len(stext[1])>limit) then
 
if(string.len(stext[1])>limit) then
Zeile 27: Zeile 38:
 
end
 
end
 
end
 
end
cuttext = stext[1]--fiick
+
realcuttext = srealtext[1]
+
cuttext = stext[1] --Die
nextwo = stext[2]--dich
+
realcuttext = srealtext[1] --Die
realnextwo = srealtext[2]--dich
+
nextlen = string.len(nextwo)--4
+
nextwo = stext[2] --Schmiede
textlen = string.len(text)--10
+
realnextwo = srealtext[2] --Schmiede
cuttextlen = string.len(cuttext)--5
+
 +
nextlen = string.len(nextwo)--8
 +
textlen = string.len(text)--12
 +
cuttextlen = string.len(cuttext)--3
 +
 
set = true;
 
set = true;
if(limit>=textlen)then --9>=10
+
testtext = testtext.."<br \>"..i..": "..realcuttext
return text.."%@%"
+
elseif(cuttextlen>limit) then--5>9
+
if(limit>=textlen)then --4>=12
return "%@%"..text
+
return realtext.."%@%"
+
elseif(cuttextlen+nextlen+1>=limit) then--5>9
+
elseif(cuttextlen>limit) then--3>4
return cuttext.." "..nextwo.."%@%"
+
return "%@%"..realtext
+
 +
 +
 +
 
 
else
 
else
while (cuttextlen+nextlen+1<=textlen+2) do --
+
while (cuttextlen+nextlen+1<=textlen+2) do --8+3+1<=12+2(12<=14)|14+3+1<=12+2(18<=14)
 
 
if(cuttextlen+nextlen>=limit and set) then --5+4>9(9>=9)
+
if(cuttextlen+nextlen+1>limit and set) then --8+3+1>4(12>4)|
 
set = false
 
set = false
cuttext = cuttext.."%@%"
+
cuttext = cuttext.."%@%" --"Die %@%"
 +
realcuttext = realcuttext.."%@%" --"Die %@%"
 +
 
else
 
else
cuttext = cuttext.." "
+
cuttext = cuttext.." " --
 +
realcuttext = realcuttext.." " --
 +
 
end
 
end
 +
-- testtext = testtext..tostring(i)..": "..realcuttext.."<br />"
 
i = i + 1 --3
 
i = i + 1 --3
cuttext = cuttext..nextwo -- fick%@%dich
+
realcuttext = realcuttext..realnextwo
+
cuttext = cuttext..nextwo -- "Die%@%Schmiede"
nextwo = stext[i]-- halli
+
realcuttext = realcuttext..realnextwo -- "Die%@%Schmiede"
realnextwo = stext[i]-- halli
+
nextlen = string.len(nextwo) -- 5
+
nextwo = stext[i]-- nil
cuttextlen = string.len(cuttext) -- 11
+
realnextwo = srealtext[i]-- nil
 +
 +
if (nextwo ~= nil) then
 +
nextlen = string.len(nextwo) -- 5
 +
end
 +
cuttextlen = string.len(cuttext) -- 14
 +
testtext = testtext.."<br \>"..i..": "..realcuttext
 +
 +
end
 +
realnextwo = srealtext[i]
 +
if (realnextwo ~= nil) then
 +
realcuttext = realcuttext.." "..realnextwo
 
end
 
end
realcuttext = realcuttext.." "..realnextwo
 
 
return realcuttext
 
 
end
 
end
 +
testtext = testtext.."<br \>"..(i+1)..": "..realcuttext
 +
return realcuttext
 
end
 
end
  
function cut( limit, text )
+
 
 +
function cut( limit, realtext )
 +
testtext = ""
 
 
realtext = text
+
realtext = removespaceinlink(realtext) --Die Schmiede
srealtext = split(realtext, " ")
+
srealtext = split(realtext, " ") --Die|Schmiede(list)
 
i = 2; --2
 
i = 2; --2
text = display(text) --fiick dich
+
testtext = testtext.."<br \>"..i..": "
stext = split(text, " ")--fiick|dich(list)
+
 +
text = display(removespaceinlink(realtext)) --Die Schmiede
 +
stext = split(text, " ") --Die|Schmiede(list)
 +
 
if(table.getn(stext)==1) then
 
if(table.getn(stext)==1) then
 
if(string.len(stext[1])>limit) then
 
if(string.len(stext[1])>limit) then
Zeile 80: Zeile 118:
 
end
 
end
 
end
 
end
cuttext = stext[1]--fiick
+
realcuttext = srealtext[1]
+
cuttext = stext[1] --Die
nextwo = stext[2]--dich
+
realcuttext = srealtext[1] --Die
realnextwo = srealtext[2]--dich
+
nextlen = string.len(nextwo)--4
+
nextwo = stext[2] --Schmiede
textlen = string.len(text)--10
+
realnextwo = srealtext[2] --Schmiede
cuttextlen = string.len(cuttext)--5
+
 +
nextlen = string.len(nextwo)--8
 +
textlen = string.len(text)--12
 +
cuttextlen = string.len(cuttext)--3
 +
 
set = true;
 
set = true;
if(limit>=textlen)then --9>=10
+
testtext = testtext.."<br \>"..i..": "..realcuttext
return text.."%@%"
+
elseif(cuttextlen>limit) then--5>9
+
if(limit>=textlen)then --4>=12
return "%@%"..text
+
return realtext.."%@%"
+
elseif(cuttextlen+nextlen+1>=limit) then--5>9
+
elseif(cuttextlen>limit) then--3>4
return cuttext.." "..nextwo.."%@%"
+
return "%@%"..realtext
+
 +
 +
 +
 
 
else
 
else
while (cuttextlen+nextlen+1<=textlen+2) do --
+
while (cuttextlen+nextlen+1<=textlen+2) do --8+3+1<=12+2(12<=14)|14+3+1<=12+2(18<=14)
 
 
if(cuttextlen+nextlen>=limit and set) then --5+4>9(9>=9)
+
if(cuttextlen+nextlen+1>limit and set) then --8+3+1>4(12>4)|
 
set = false
 
set = false
cuttext = cuttext.."%@%"
+
cuttext = cuttext.."%@%" --"Die %@%"
 +
realcuttext = realcuttext.."%@%" --"Die %@%"
 +
 
else
 
else
cuttext = cuttext.." "
+
cuttext = cuttext.." " --
 +
realcuttext = realcuttext.." " --
 +
 
end
 
end
 +
-- testtext = testtext..tostring(i)..": "..realcuttext.."<br />"
 
i = i + 1 --3
 
i = i + 1 --3
cuttext = cuttext..nextwo -- fick%@%dich
+
realcuttext = realcuttext..realnextwo
+
cuttext = cuttext..nextwo -- "Die%@%Schmiede"
nextwo = stext[i]-- halli
+
realcuttext = realcuttext..realnextwo -- "Die%@%Schmiede"
realnextwo = stext[i]-- halli
+
nextlen = string.len(nextwo) -- 5
+
nextwo = stext[i]-- nil
cuttextlen = string.len(cuttext) -- 11
+
realnextwo = srealtext[i]-- nil
 +
 +
if (nextwo ~= nil) then
 +
nextlen = string.len(nextwo) -- 5
 +
end
 +
cuttextlen = string.len(cuttext) -- 14
 +
testtext = testtext.."<br \>"..i..": "..realcuttext
 +
 +
end
 +
realnextwo = srealtext[i]
 +
if (realnextwo ~= nil) then
 +
realcuttext = realcuttext.." "..realnextwo
 
end
 
end
realcuttext = realcuttext.." "..realnextwo
 
 
return split(realcuttext, "%@%")
 
 
end
 
end
 +
testtext = testtext.."<br \>"..(i+1)..": "..realcuttext
 +
return realcuttext
 
end
 
end
 +
  
 
function p.cutblock ( frame )
 
function p.cutblock ( frame )
text = frame.args[3]
+
text = frame.args[3]-- "Die Schmiede"
width = frame.args[2]
+
width = tonumber(frame.args[2]) -- 4
height = frame.args[1]
+
height = tonumber(frame.args[1]) -- 12
block = {}
+
block = ""
rest = ""
+
textlen = string.len(text) -- 12
 +
tempsplit = {}
 
 
 
 
 +
while (height>0 and textlen>=width) do -- 12>0 and 12>=4|11>0 and 11>=4
 +
tempsplit = split(cut(width, text), "%%%@%%") -- ("Die", "Schmiede")| (
 +
block = block..tempsplit[1].." " -- "Die "
 +
text = tempsplit[2] -- "Schmiede"
 +
height = height-1 -- 11
 +
if (text==nil) then
 +
text = ""
 +
end
 +
textlen = string.len(text) -- 8
 +
end
 +
if (height>0) then
 +
block = block.." "..text
 +
text = ""
 +
end
 
 
 +
result = block.."%@%"..text
 +
result = string.gsub(result, "%§", " ")
 +
return result
  
  
 +
end
  
 +
function p.display ( frame )
 +
text = frame.args[1]
 +
text = text:gsub("'", "")
 +
lend = string.len(text)
 +
i=1
 +
auf = {}
 +
zu = {}
 +
currentauf = string.find(text, "%[%[")
 +
while (currentauf ~= nil) do
 +
auf[i] = currentauf;
 +
if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then
 +
currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[")
 +
else
 +
currentauf = nil
 +
end
 +
 +
i=i+1
 +
end
 +
 +
i=1
 +
currentzu = string.find(text, "%|")
 +
while (currentzu ~= nil) do
 +
zu[i] = currentzu;
 +
if (string.find(string.sub(text,currentzu+2), "%|")~=nil)then
 +
currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%|")
 +
else
 +
currentzu = nil
 +
end
 +
i=i+1
 +
end
 +
 +
offset = 0
 +
 +
if(table.getn(auf) == table.getn(zu))then
 +
 +
i=1
 +
while (table.getn(auf)>=i) do
 +
anfang = auf[i]
 +
ende = zu[i]
 +
tt, uu = string.find(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|")
 +
text = string.gsub(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|", "")..string.sub(text,anfang-offset+2,string.len(text))
 +
-- text = string.sub(text,1,anfang-offset+1)..string.sub(text,ende+1-offset,string.len(text))
 +
if (tt ~= nil) and (uu ~= nil) then
 +
offset = offset+uu-tt
 +
end
 +
i=i+1
 +
end
 +
text = string.gsub(text, "%[%[(.+)%|", "")
 +
end
 +
 +
-- text = text:gsub("%[", "")
 +
-- text = text:gsub("%|", "")
 +
text = text:gsub("%]", "")
  
  
 +
return text
 +
end
  
 +
function display ( text )
 +
text = text:gsub("'", "")
 +
lend = string.len(text)
 +
ii=1
 +
auf = {}
 +
zu = {}
 +
currentauf = string.find(text, "%[%[")
 +
while (currentauf ~= nil) do
 +
auf[ii] = currentauf;
 +
if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then
 +
currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[")
 +
else
 +
currentauf = nil
 +
end
 +
 +
ii=ii+1
 +
end
 +
 +
ii=1
 +
currentzu = string.find(text, "%|")
 +
while (currentzu ~= nil) do
 +
zu[ii] = currentzu;
 +
if (string.find(string.sub(text,currentzu+2), "%|")~=nil)then
 +
currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%|")
 +
else
 +
currentzu = nil
 +
end
 +
ii=ii+1
 +
end
 +
 +
offset = 0
 +
 +
if(table.getn(auf) == table.getn(zu))then
 +
 +
ii=1
 +
while (table.getn(auf)>=ii) do
 +
anfang = auf[ii]
 +
ende = zu[ii]
 +
tt, uu = string.find(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|")
 +
text = string.gsub(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|", "")..string.sub(text,anfang-offset+2,string.len(text))
 +
-- text = string.sub(text,1,anfang-offset+1)..string.sub(text,ende+1-offset,string.len(text))
 +
if (tt ~= nil) and (uu ~= nil) then
 +
offset = offset+uu-tt
 +
end
 +
ii=ii+1
 +
end
 +
text = string.gsub(text, "%[%[(.+)%|", "")
 +
end
 +
 +
-- text = text:gsub("%[", "")
 +
-- text = text:gsub("%|", "")
 +
text = text:gsub("%]", "")
 +
 +
 +
return text
 +
end
 +
 +
function removespaceinlink(text)
 +
iii=1
 +
auf = {}
 +
zu = {}
 +
currentauf = string.find(text, "%[%[")
 +
while (currentauf ~= nil) do
 +
auf[iii] = currentauf;
 +
if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then
 +
currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[")
 +
else
 +
currentauf = nil
 +
end
 +
 +
iii=iii+1
 +
end
 +
 +
iii=1
 +
currentzu = string.find(text, "%]%]")
 +
while (currentzu ~= nil) do
 +
zu[iii] = currentzu;
 +
if (string.find(string.sub(text,currentzu+2), "%]%]")~=nil)then
 +
currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%]%]")
 +
else
 +
currentzu = nil
 +
end
 +
iii=iii+1
 +
end
 +
if(table.getn(auf) == table.getn(zu))then
 +
iii=1
 +
while (table.getn(auf)>=iii) do
 +
anfang = auf[iii]
 +
ende = zu[iii]
 +
text = string.sub(text,1,anfang-1)..string.gsub(string.sub(text,anfang,ende)," ","§")..string.sub(text,ende+1,string.len(text))
  
 +
iii=iii+1
 +
end
 +
end
 +
 +
return text
 
end
 
end
  
function p.display ( frame )
+
function p.removespaceinlink(frame)
 
text = frame.args[1]
 
text = frame.args[1]
text = text:gsub("'", "")
+
i=1
text = text:gsub("<.*>", "")
+
auf = {}
text = text:gsub("/[/[.*/|", "")
+
zu = {}
text = text:gsub("/[", "")
+
currentauf = string.find(text, "%[%[")
text = text:gsub("/|", "")
+
while (currentauf ~= nil) do
text = text:gsub("/]", "")
+
auf[i] = currentauf;
 +
if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then
 +
currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[")
 +
else
 +
currentauf = nil
 +
end
 +
 +
i=i+1
 +
end
 +
 +
i=1
 +
currentzu = string.find(text, "%]%]")
 +
while (currentzu ~= nil) do
 +
zu[i] = currentzu;
 +
if (string.find(string.sub(text,currentzu+2), "%]%]")~=nil)then
 +
currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%]%]")
 +
else
 +
currentzu = nil
 +
end
 +
i=i+1
 +
end
 +
if(table.getn(auf) == table.getn(zu))then
 +
i=1
 +
while (table.getn(auf)>=i) do
 +
anfang = auf[i]
 +
ende = zu[i]
 +
text = string.sub(text,1,anfang-1)..string.gsub(string.sub(text,anfang,ende)," ","§")..string.sub(text,ende+1,string.len(text))
  
 +
i=i+1
 +
end
 +
end
 +
 
return text
 
return text
 
end
 
end
  
function display ( text )
 
text = text:gsub("'", "")
 
text = text:gsub("<.*>", "")
 
text = text:gsub("[[.*|", "")
 
text = text:gsub("[", "")
 
text = text:gsub("|", "")
 
text = text:gsub("]", "")
 
  
return text
+
 
 +
 
 +
 
 +
 
 +
function p.size ( frame )
 +
text = frame.args[1]
 +
return textSize(text)
 +
end
 +
 
 +
 
 +
 
 +
 
 +
 
 +
function p.size ( frame )
 +
text = frame.args[1]
 +
return textSize(text)
 +
end
 +
 
 +
function p.findg( frame )
 +
text = frame.args[1]
 +
d,s,r = string.find(text, "g")
 +
return d,s,r
 +
 
 +
end
 +
 
 +
function p.index( frame )
 +
text = frame.args[1]
 +
stext = split (text, "\n")
 +
ending = ""
 +
 +
for i = 1,tablelength(stext),1 do
 +
currentsplit = split (stext[i], "%>")
 +
leng = tablelength(currentsplit)
 +
ending = ending.."|<big>'''[[Yggdrasil:"..currentsplit[2].."#"..currentsplit[1].."|"..currentsplit[1].."]]'''</big>\n|<big>'''[[Yggdrasil:"..currentsplit[2].."|"..currentsplit[2].."]]'''</big>\n|-\n"
 +
end
 +
 +
return ending
 
end
 
end
  
  
 +
function p.yggrassen( frame )
 +
text = frame.args[1]
 +
stext = split (text, "\n")
 +
haupttext = split (text, "'''Nebenrassen'''")[1]
 +
nebentext = split (text, "'''Nebenrassen'''")[2]
 +
shaupttext = split (haupttext, "\n")
 +
snebentext = split (nebentext, "\n")
 +
ending = "!<big>Hauptrassen</big>\n|-\n"
 +
 +
for i = 2,tablelength(stext),1 do
 +
if (stext[i]=="'''Nebenrassen'''") then
 +
ending = ending.."!<big>Nebenrassen</big>\n|-\n"
 +
else
 +
ending = ending.."|<big>'''[[#"..stext[i].."|"..stext[i].."]]'''</big>\n|-\n"
 +
end
 +
end
 +
 +
 +
 +
 +
return ending
 +
 +
end
  
 
return p
 
return p

Aktuelle Version vom 5. März 2020, 22:17 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 tablelength(T)
  local count = 0
  for _ in pairs(T) do count = count + 1 end
  return count
end


function p.cut( frame )
	testtext = ""
	realtext = frame.args[2] --Die Schmiede
	realtext = removespaceinlink(realtext) --Die Schmiede
	srealtext = split(realtext, " ") --Die|Schmiede(list)
	i = 2; --2
	testtext = testtext.."<br \>"..i..": "
	limit = tonumber(frame.args[1]) --4
	text = display(removespaceinlink(realtext)) --Die Schmiede
	stext = split(text, " ") --Die|Schmiede(list)
	
	if(table.getn(stext)==1) then
		if(string.len(stext[1])>limit) then
			return "%@%"..text
		else
			return text.."%@%"
		end
	end
	
	cuttext = stext[1] --Die
	realcuttext = srealtext[1] --Die
	
	nextwo = stext[2] --Schmiede
	realnextwo = srealtext[2] --Schmiede
	
	nextlen = string.len(nextwo)--8
	textlen = string.len(text)--12
	cuttextlen = string.len(cuttext)--3
	
	set = true;
	testtext = testtext.."<br \>"..i..": "..realcuttext
	
	if(limit>=textlen)then --4>=12
		return realtext.."%@%"
	
	elseif(cuttextlen>limit) then--3>4
		return "%@%"..realtext
	
	
	

	else
		while (cuttextlen+nextlen+1<=textlen+2) do --8+3+1<=12+2(12<=14)|14+3+1<=12+2(18<=14)
			
			if(cuttextlen+nextlen+1>limit and set) then --8+3+1>4(12>4)|
				set = false
				cuttext = cuttext.."%@%" --"Die %@%"
				realcuttext = realcuttext.."%@%" --"Die %@%"
				
			else
				cuttext = cuttext.." " --
				realcuttext = realcuttext.." " --
				
			end
			-- testtext = testtext..tostring(i)..": "..realcuttext.."<br />"
			i = i + 1 --3
			
			cuttext = cuttext..nextwo -- "Die%@%Schmiede"
			realcuttext = realcuttext..realnextwo -- "Die%@%Schmiede"
			
			nextwo = stext[i]-- nil
			realnextwo = srealtext[i]-- nil
			
			if (nextwo ~= nil) then
				nextlen = string.len(nextwo) -- 5
			end
			cuttextlen = string.len(cuttext) -- 14
			testtext = testtext.."<br \>"..i..": "..realcuttext
			
		end
		realnextwo = srealtext[i]
		if (realnextwo ~= nil) then
			realcuttext = realcuttext.." "..realnextwo
		end
	end
	testtext = testtext.."<br \>"..(i+1)..": "..realcuttext
	return realcuttext
end


function cut( limit, realtext )
	testtext = ""
	
	realtext = removespaceinlink(realtext) --Die Schmiede
	srealtext = split(realtext, " ") --Die|Schmiede(list)
	i = 2; --2
	testtext = testtext.."<br \>"..i..": "
	
	text = display(removespaceinlink(realtext)) --Die Schmiede
	stext = split(text, " ") --Die|Schmiede(list)
	
	if(table.getn(stext)==1) then
		if(string.len(stext[1])>limit) then
			return "%@%"..text
		else
			return text.."%@%"
		end
	end
	
	cuttext = stext[1] --Die
	realcuttext = srealtext[1] --Die
	
	nextwo = stext[2] --Schmiede
	realnextwo = srealtext[2] --Schmiede
	
	nextlen = string.len(nextwo)--8
	textlen = string.len(text)--12
	cuttextlen = string.len(cuttext)--3
	
	set = true;
	testtext = testtext.."<br \>"..i..": "..realcuttext
	
	if(limit>=textlen)then --4>=12
		return realtext.."%@%"
	
	elseif(cuttextlen>limit) then--3>4
		return "%@%"..realtext
	
	
	

	else
		while (cuttextlen+nextlen+1<=textlen+2) do --8+3+1<=12+2(12<=14)|14+3+1<=12+2(18<=14)
			
			if(cuttextlen+nextlen+1>limit and set) then --8+3+1>4(12>4)|
				set = false
				cuttext = cuttext.."%@%" --"Die %@%"
				realcuttext = realcuttext.."%@%" --"Die %@%"
				
			else
				cuttext = cuttext.." " --
				realcuttext = realcuttext.." " --
				
			end
			-- testtext = testtext..tostring(i)..": "..realcuttext.."<br />"
			i = i + 1 --3
			
			cuttext = cuttext..nextwo -- "Die%@%Schmiede"
			realcuttext = realcuttext..realnextwo -- "Die%@%Schmiede"
			
			nextwo = stext[i]-- nil
			realnextwo = srealtext[i]-- nil
			
			if (nextwo ~= nil) then
				nextlen = string.len(nextwo) -- 5
			end
			cuttextlen = string.len(cuttext) -- 14
			testtext = testtext.."<br \>"..i..": "..realcuttext
			
		end
		realnextwo = srealtext[i]
		if (realnextwo ~= nil) then
			realcuttext = realcuttext.." "..realnextwo
		end
	end
	testtext = testtext.."<br \>"..(i+1)..": "..realcuttext
	return realcuttext
end


function p.cutblock ( frame )
	text = frame.args[3]-- "Die Schmiede"
	width = tonumber(frame.args[2]) -- 4
	height = tonumber(frame.args[1]) -- 12
	block = ""
	textlen = string.len(text) -- 12
	tempsplit = {}
	
	
	while (height>0 and textlen>=width) do -- 12>0 and 12>=4|11>0 and 11>=4
		tempsplit = split(cut(width, text), "%%%@%%") -- ("Die", "Schmiede")| (
		block = block..tempsplit[1].." " -- "Die "
		text = tempsplit[2] -- "Schmiede"
		height = height-1 -- 11
		if (text==nil) then
			text = ""
		end
		textlen = string.len(text) -- 8
	end
	if (height>0) then
		block = block.." "..text
		text = ""
	end
	
	result = block.."%@%"..text
	result = string.gsub(result, "%§", " ")
	return result


end

function p.display ( frame )
	text = frame.args[1]
	text = text:gsub("'", "")
	lend = string.len(text)
	i=1
	auf = {}
	zu = {}
	currentauf = string.find(text, "%[%[")
	while (currentauf ~= nil) do
		auf[i] = currentauf;
		if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then
			currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[")
		else
			currentauf = nil
		end
		
		i=i+1
	end
	
	i=1
	currentzu = string.find(text, "%|")
	while (currentzu ~= nil) do
		zu[i] = currentzu;
		if (string.find(string.sub(text,currentzu+2), "%|")~=nil)then
			currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%|")
		else
			currentzu = nil
		end
		i=i+1
	end
	
	offset = 0
	
	if(table.getn(auf) == table.getn(zu))then
		
		 i=1
		 while (table.getn(auf)>=i) do
			anfang = auf[i]
			ende = zu[i]
			tt, uu = string.find(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|")
			text = string.gsub(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|", "")..string.sub(text,anfang-offset+2,string.len(text))
			-- text = string.sub(text,1,anfang-offset+1)..string.sub(text,ende+1-offset,string.len(text))
			if (tt ~= nil) and (uu ~= nil) then
				offset = offset+uu-tt
			end
			i=i+1
		 end
		 text = string.gsub(text, "%[%[(.+)%|", "")
	end
	
	-- text = text:gsub("%[", "")
	-- text = text:gsub("%|", "")
	text = text:gsub("%]", "")


	return text
end

function display ( text )
	text = text:gsub("'", "")
	lend = string.len(text)
	ii=1
	auf = {}
	zu = {}
	currentauf = string.find(text, "%[%[")
	while (currentauf ~= nil) do
		auf[ii] = currentauf;
		if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then
			currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[")
		else
			currentauf = nil
		end
		
		ii=ii+1
	end
	
	ii=1
	currentzu = string.find(text, "%|")
	while (currentzu ~= nil) do
		zu[ii] = currentzu;
		if (string.find(string.sub(text,currentzu+2), "%|")~=nil)then
			currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%|")
		else
			currentzu = nil
		end
		ii=ii+1
	end
	
	offset = 0
	
	if(table.getn(auf) == table.getn(zu))then
		
		 ii=1
		 while (table.getn(auf)>=ii) do
			anfang = auf[ii]
			ende = zu[ii]
			tt, uu = string.find(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|")
			text = string.gsub(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|", "")..string.sub(text,anfang-offset+2,string.len(text))
			-- text = string.sub(text,1,anfang-offset+1)..string.sub(text,ende+1-offset,string.len(text))
			if (tt ~= nil) and (uu ~= nil) then
				offset = offset+uu-tt
			end
			ii=ii+1
		 end
		 text = string.gsub(text, "%[%[(.+)%|", "")
	end
	
	-- text = text:gsub("%[", "")
	-- text = text:gsub("%|", "")
	text = text:gsub("%]", "")


	return text
end

function removespaceinlink(text)
	iii=1
	auf = {}
	zu = {}
	currentauf = string.find(text, "%[%[")
	while (currentauf ~= nil) do
		auf[iii] = currentauf;
		if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then
			currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[")
		else
			currentauf = nil
		end
		
		iii=iii+1
	end
	
	iii=1
	currentzu = string.find(text, "%]%]")
	while (currentzu ~= nil) do
		zu[iii] = currentzu;
		if (string.find(string.sub(text,currentzu+2), "%]%]")~=nil)then
			currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%]%]")
		else
			currentzu = nil
		end
		iii=iii+1
	end
	if(table.getn(auf) == table.getn(zu))then
		iii=1
		while (table.getn(auf)>=iii) do
			anfang = auf[iii]
			ende = zu[iii]
			text = string.sub(text,1,anfang-1)..string.gsub(string.sub(text,anfang,ende)," ","§")..string.sub(text,ende+1,string.len(text))

			iii=iii+1
		end
	end
	
	return text
end

function p.removespaceinlink(frame)
	text = frame.args[1]
	i=1
	auf = {}
	zu = {}
	currentauf = string.find(text, "%[%[")
	while (currentauf ~= nil) do
		auf[i] = currentauf;
		if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then
			currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[")
		else
			currentauf = nil
		end
		
		i=i+1
	end
	
	i=1
	currentzu = string.find(text, "%]%]")
	while (currentzu ~= nil) do
		zu[i] = currentzu;
		if (string.find(string.sub(text,currentzu+2), "%]%]")~=nil)then
			currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%]%]")
		else
			currentzu = nil
		end
		i=i+1
	end
	if(table.getn(auf) == table.getn(zu))then
		i=1
		while (table.getn(auf)>=i) do
			anfang = auf[i]
			ende = zu[i]
			text = string.sub(text,1,anfang-1)..string.gsub(string.sub(text,anfang,ende)," ","§")..string.sub(text,ende+1,string.len(text))

			i=i+1
		end
	end
	
	return text
end






function p.size ( frame )
	text = frame.args[1]
	return textSize(text)
end





function p.size ( frame )
	text = frame.args[1]
	return textSize(text)
end

function p.findg( frame )
	text = frame.args[1]
	d,s,r = string.find(text, "g")
	return d,s,r

end

function p.index( frame )
	text = frame.args[1]
	stext = split (text, "\n")
	ending = ""
	
	for i = 1,tablelength(stext),1 do 
		currentsplit = split (stext[i], "%>")
		leng = tablelength(currentsplit)
		ending = ending.."|<big>'''[[Yggdrasil:"..currentsplit[2].."#"..currentsplit[1].."|"..currentsplit[1].."]]'''</big>\n|<big>'''[[Yggdrasil:"..currentsplit[2].."|"..currentsplit[2].."]]'''</big>\n|-\n"
	end
	
	return ending
end


function p.yggrassen( frame )
	text = frame.args[1]
	stext = split (text, "\n")
	haupttext = split (text, "'''Nebenrassen'''")[1]
	nebentext = split (text, "'''Nebenrassen'''")[2]
	shaupttext = split (haupttext, "\n")
	snebentext = split (nebentext, "\n")
	ending = "!<big>Hauptrassen</big>\n|-\n"
	
	for i = 2,tablelength(stext),1 do 
		if (stext[i]=="'''Nebenrassen'''") then
			ending = ending.."!<big>Nebenrassen</big>\n|-\n"
		else
			ending = ending.."|<big>'''[[#"..stext[i].."|"..stext[i].."]]'''</big>\n|-\n"
		end
	end
	
	
	

	return ending

end

return p