Modul:X: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
function split (inputstr, sep) | |||
function | |||
if sep == nil then | |||
sep = "%s" | |||
end | |||
local t={} | |||
for str in string.gmatch(string.gsub(inputstr,sep, "\0"),"%Z+") do | |||
table.insert(t, str) | |||
end | |||
return t | |||
end | |||
function copy(obj, seen) | |||
if type(obj) ~= 'table' then return obj end | |||
if seen and seen[obj] then return seen[obj] end | |||
local s = seen or {} | |||
local res = setmetatable({}, getmetatable(obj)) | |||
s[obj] = res | |||
for k, v in pairs(obj) do res[copy(k, s)] = copy(v, s) end | |||
return res | |||
end | |||
function tabContains(tableasd, keaaay) | |||
solution = nil --"key: "..keaaay.."\n\n" | |||
for numgasbr,crreasdnt in pairs(tableasd) do | |||
if (tableasd[numgasbr] == keaaay) then | |||
solution = numgasbr | |||
end | |||
--solution = solution..numgasbr..": "..crreasdnt[numgasbr].."\n\n" | |||
end | |||
return solution | |||
end | |||
function tablelength(T) | |||
local count = 0 | |||
if (T==nil or T[1]==nil) then | |||
return 0 | |||
end | |||
for _ in pairs(T) do count = count + 1 end | |||
return count | |||
end | |||
function tabcontainstab(tableoneooop, tabletwoooop) | |||
seanwsrer = true | |||
if (tabletwoooop[1]~=nil) then | |||
for numberindexthingiu, currenttableslothi in pairs(tabletwoooop) do | |||
if (tabContains(tableoneooop,currenttableslothi) == nil) then | |||
seanwsrer = false | |||
end | |||
end | end | ||
end | end | ||
if ( | return seanwsrer | ||
end | |||
function displaytablevert(taable) | |||
endresutl="" | |||
if (taable==nil or taable[1]==nil) then | |||
return endresutl | |||
end | |||
for nnnn,entri in pairs(taable) do | |||
endresutl=endresutl..entri.."\n" | |||
end | |||
return endresutl | |||
end | |||
function displaytablehor(taaable) | |||
endresutal="" | |||
if (taaable==nil or taaable[1]==nil) then | |||
return endresutal | |||
end | end | ||
for nn,entria in pairs(taaable) do | |||
endresutal=endresutal..entria.." - " | |||
end | |||
return endresutal | |||
end | |||
function displaytabletwo(taaaable) | |||
endresutaal="" | |||
if (taaaable==nil or taaaable[1]==nil) then | |||
return endresutaal | |||
end | |||
for nnn,entriaa in pairs(taaaable) do | |||
endresutaal=endresutaal..displaytablehor(entriaa).."\n\n" | |||
end | |||
return endresutaal | |||
end | |||
function gmatchtable(text, pattern) | |||
ztable={} | |||
for word in string.gmatch(text, pattern) do | |||
table.insert(ztable,word) | |||
return | end | ||
return ztable | |||
end | |||
function getindexformat() | |||
title = mw.title.new( "Indexformat", "Yggdrasil" ) | |||
content = title:getContent() | |||
content = string.gsub(content, "</pre>.-<pre>" , "!!!") | |||
content = string.gsub(content, "</pre>.*" , "") | |||
content = string.gsub(content, ".*<pre>" , "") | |||
content = string.gsub(content, "|" , "\n|") | |||
content = split(content,"!!!") | |||
return content | |||
end | end | ||
function | |||
function getheader( title, namespace ) | |||
title = mw.title.new( title, namespace ) | |||
content = title:getContent() | |||
content = string.gsub(content, "%=%=+", "§§§") | |||
content = split("hallo"..content, "§§§") | |||
iiii = 2 | |||
iiiii = 1 | |||
length = tablelength(content) | |||
finaltext={} | |||
while (iiii<=length) do | |||
finaltext[iiiii] = content[iiii] | |||
iiii = iiii + 2 | |||
iiiii = iiiii + 1 | |||
end | |||
return finaltext | |||
end | |||
function getheaderlimit( title, namespace ) | |||
limiit = tonumber(string.sub(title, string.len(title))) | |||
title = string.sub(title, 1, string.len(title)-2) | |||
title = mw.title.new( title, namespace ) | |||
content = title:getContent() | |||
curhead="" | |||
while (0<=limiit) do | |||
curhead = curhead.."%=" | |||
limiit = limiit-1 | |||
end | |||
curhead = curhead.."+" | |||
content = string.gsub(content, curhead, "no") | |||
content = string.gsub(content, "%=%=+", "§§§") | |||
content = split("hallo"..content, "§§§") | |||
iiii = 2 | |||
iiiii = 1 | |||
length = tablelength(content) | |||
endtext={} | |||
while (iiii<=length) do | |||
endtext[iiiii] = content[iiii] | |||
iiii = iiii + 2 | |||
iiiii = iiiii + 1 | |||
end | |||
return endtext | |||
end | |||
function cut( limit, realtext ) | |||
testtext = "" | testtext = "" | ||
realtext = removespaceinlink(realtext) --Die Schmiede | realtext = removespaceinlink(realtext) --Die Schmiede | ||
srealtext = split(realtext, " ") --Die|Schmiede(list) | srealtext = split(realtext, " ") --Die|Schmiede(list) | ||
i = 2; --2 | i = 2; --2 | ||
testtext = testtext.."<br \>"..i..": " | testtext = testtext.."<br \>"..i..": " | ||
text = display(removespaceinlink(realtext)) --Die Schmiede | text = display(removespaceinlink(realtext)) --Die Schmiede | ||
stext = split(text, " ") --Die|Schmiede(list) | stext = split(text, " ") --Die|Schmiede(list) | ||
Zeile 112: | Zeile 238: | ||
end | end | ||
function | function headertotablelimit(title, namespace) | ||
limiiiit = tonumber(string.sub(title, string.len(title)))-1 | |||
title = string.sub(title, 1, string.len(title)-2) | |||
title = mw.title.new( title, namespace ) | |||
content = title.getContent(title) | |||
original = headertotable(content) | |||
neworiginal = {} | |||
for nnnnn,entriii in ipairs(original) do | |||
if (tablelength(entriii)<=limiiiit) then | |||
neworiginal[nnnnn] = entriii | |||
end | |||
end | |||
return neworiginal | |||
end | |||
function display ( text ) | |||
text = text:gsub("'", "") | text = text:gsub("'", "") | ||
lend = string.len(text) | lend = string.len(text) | ||
ii=1 | |||
auf = {} | auf = {} | ||
zu = {} | zu = {} | ||
currentauf = string.find(text, "%[%[") | currentauf = string.find(text, "%[%[") | ||
while (currentauf ~= nil) do | while (currentauf ~= nil) do | ||
auf[ | auf[ii] = currentauf; | ||
if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then | if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then | ||
currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[") | currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[") | ||
Zeile 128: | Zeile 268: | ||
end | end | ||
ii=ii+1 | |||
end | end | ||
ii=1 | |||
currentzu = string.find(text, "%|") | currentzu = string.find(text, "%|") | ||
while (currentzu ~= nil) do | while (currentzu ~= nil) do | ||
zu[ | zu[ii] = currentzu; | ||
if (string.find(string.sub(text,currentzu+2), "%|")~=nil)then | if (string.find(string.sub(text,currentzu+2), "%|")~=nil)then | ||
currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%|") | currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%|") | ||
Zeile 140: | Zeile 280: | ||
currentzu = nil | currentzu = nil | ||
end | end | ||
ii=ii+1 | |||
end | end | ||
Zeile 147: | Zeile 287: | ||
if(table.getn(auf) == table.getn(zu))then | if(table.getn(auf) == table.getn(zu))then | ||
ii=1 | |||
while (table.getn(auf)>= | while (table.getn(auf)>=ii) do | ||
anfang = auf[ | anfang = auf[ii] | ||
ende = zu[ | ende = zu[ii] | ||
tt, uu = string.find(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|") | 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.gsub(string.sub(text, 1, anfang-offset+1), "%[%[(.+)%|", "")..string.sub(text,anfang-offset+2,string.len(text)) | ||
Zeile 157: | Zeile 297: | ||
offset = offset+uu-tt | offset = offset+uu-tt | ||
end | end | ||
ii=ii+1 | |||
end | end | ||
text = string.gsub(text, "%[%[(.+)%|", "") | text = string.gsub(text, "%[%[(.+)%|", "") | ||
Zeile 170: | Zeile 310: | ||
end | end | ||
function removespaceinlink(text) | |||
iii=1 | |||
function | |||
auf = {} | auf = {} | ||
zu = {} | zu = {} | ||
currentauf = string.find(text, "%[%[") | currentauf = string.find(text, "%[%[") | ||
while (currentauf ~= nil) do | while (currentauf ~= nil) do | ||
auf[ | auf[iii] = currentauf; | ||
if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then | if (string.find(string.sub(text,currentauf+2), "%[%[")~=nil)then | ||
currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[") | currentauf = currentauf+1+string.find(string.sub(text,currentauf+2), "%[%[") | ||
Zeile 198: | Zeile 323: | ||
end | end | ||
iii=iii+1 | |||
end | end | ||
iii=1 | |||
currentzu = string.find(text, "%]%]") | currentzu = string.find(text, "%]%]") | ||
while (currentzu ~= nil) do | while (currentzu ~= nil) do | ||
zu[ | zu[iii] = currentzu; | ||
if (string.find(string.sub(text,currentzu+2), "%]%]")~=nil)then | if (string.find(string.sub(text,currentzu+2), "%]%]")~=nil)then | ||
currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%]%]") | currentzu = currentzu+1+string.find(string.sub(text,currentzu+2), "%]%]") | ||
Zeile 210: | Zeile 335: | ||
currentzu = nil | currentzu = nil | ||
end | end | ||
iii=iii+1 | |||
end | end | ||
if(table.getn(auf) == table.getn(zu))then | if(table.getn(auf) == table.getn(zu))then | ||
iii=1 | |||
while (table.getn(auf)>= | while (table.getn(auf)>=iii) do | ||
anfang = auf[ | anfang = auf[iii] | ||
ende = zu[ | 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)) | 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 | ||
end | end | ||
Zeile 226: | Zeile 351: | ||
end | end | ||
function gethighest( tabhle ) | |||
highest = tabhle[1] | |||
for numgbr,crregnt in ipairs(tabhle) do | |||
if (highest<tabhle[numgbr]) then | |||
highest=tabhle[numgbr] | |||
function | end | ||
end | |||
return highest | |||
end | end | ||
function duptable( tabhdhle ) | |||
dupe = {} | |||
nothertab = {} | |||
for nuamgbr,craregnt in pairs(tabhdhle) do | |||
function | reallycontains = tabContains(nothertab,craregnt) | ||
if (reallycontains==nil) then | |||
nothertab[nuamgbr] = craregnt | |||
else | |||
tempdupetable = {reallycontains,nuamgbr} | |||
table.insert(dupe,tempdupetable) | |||
end | end | ||
end | end | ||
return dupe | |||
return | |||
end | end | ||
function schlagwortliste() | |||
function | tiasdtasdfle = mw.title.new( "Schlagwortliste", "Yggdrasil" ) | ||
contegfgdfndasdat = tiasdtasdfle:getContent() | |||
schlagworttable = {} | |||
for thingis in string.gmatch(contegfgdfndasdat, "%{%{o%|.-%|") do | |||
iuadiuh = string.sub(thingis,5,string.len(thingis)-1) | |||
if (iuadiuh~="Name") then | |||
table.insert(schlagworttable,iuadiuh) | |||
if ( | |||
end | end | ||
end | end | ||
return | return schlagworttable | ||
end | end | ||
function gegvorapi() | |||
listxy = {} | |||
function | gegtitle = mw.title.new( "Gegenstände", "Yggdrasil" ) | ||
gegcontent = gegtitle:getContent() | |||
tabbbb = headertotable(gegcontent) | |||
headerewnds = {} | |||
tempzwweites = {} | |||
tempzudreites = 0 | |||
tempzudreitasdafsaes = 0 | |||
for eiwnes,zwwweites in pairs(tabbbb) do | |||
if (tablelength(zwwweites) == 3) then | |||
tempzwweites = copy(zwwweites) | |||
x,tempzudreites = string.find(gegcontent,"===="..tempzwweites[3].."====") | |||
tempzudreitasdafsaes,x = string.find(gegcontent,"\n=", tempzudreites) | |||
if (tempzudreitasdafsaes==nil) then | |||
tempzudreitasdafsaes = string.len(gegcontent) | |||
end | end | ||
tempzwweites[4] = string.gsub(string.sub(gegcontent,tempzudreites+1,tempzudreitasdafsaes-1),"<.->","") | |||
table.insert(listxy,tempzwweites) | |||
end | |||
end | end | ||
return | |||
return listxy -- 1:Category 2: Subcategory 3: Name 4:content | |||
end | end | ||
function | function zeros(intedhfgjdgkztger) | ||
resdgsgst = "" | |||
while (intedhfgjdgkztger>0) do | |||
return | resdgsgst=resdgsgst.."0" | ||
intedhfgjdgkztger=intedhfgjdgkztger-1 | |||
end | |||
return resdgsgst | |||
end | end | ||
function | function ones(intedhfgjdfasgkztger) | ||
resdgsasdgst = "" | |||
while (intedhfgjdfasgkztger>0) do | |||
resdgsasdgst=resdgsasdgst.."1" | |||
intedhfgjdfasgkztger=intedhfgjdfasgkztger-1 | |||
end | end | ||
return resdgsasdgst | |||
end | end | ||
function gegapi() | |||
catlist = {} | |||
function | nosortlist = {} | ||
unforlist = gegvorapi() | |||
temptable = {} | |||
temprest = "" | |||
tempsplittable = {} | |||
nothertempsplittable = {} | |||
tempimg = nil | |||
for numd, keyd in pairs(unforlist) do | |||
temptable = {} | |||
if (catlist[keyd[1]] == nil) then | |||
catlist[keyd[1]] = {} | |||
end | |||
if (catlist[keyd[1]][keyd[2]] == nil) then | |||
catlist[keyd[1]][keyd[2]] = {} | |||
end | |||
if (catlist[keyd[1]][keyd[2]][numd] == nil) then | |||
catlist[keyd[1]][keyd[2]][numd] = {} | |||
end | |||
temptable["Category"] = keyd[1] | |||
temptable["Subcategory"] = keyd[2] | |||
temptable["Name"] = keyd[3] | |||
catlist[keyd[1]][keyd[2]][numd]["Name"] = keyd[3] | |||
temptable["Text"] = string.gsub(string.gsub(split(keyd[4], "\n%|\n")[2],"%}%}",""),"\n\n","") | |||
catlist[keyd[1]][keyd[2]][numd]["Text"] = temptable["Text"] | |||
temprest = split(keyd[4], "\n%|\n")[1] | |||
tempimg = string.match(temprest,"img=.-\n") | |||
anothertemp = "" | |||
if (tempimg~= nil) then | |||
temptable["Img"] = string.sub(tempimg,5) | |||
catlist[keyd[1]][keyd[2]][numd]["Img"] = temptable["Img"] | |||
end | |||
temprest = string.gsub(string.gsub(temprest,"\n",""), "{{YggTab.-|!", "") | |||
temprest = string.gsub(temprest, "{{YggTab|!", "|-|!") | |||
temprest = split(temprest,"|%-|!") | |||
for tri,asdf in pairs(temprest) do | |||
tempsplittable = split(asdf,"|") | |||
intindex = 2 | |||
nothertempsplittable = {} | |||
while (intindex<=tablelength(tempsplittable)) do | |||
anothertemp = tempsplittable[intindex] | |||
if (string.find(anothertemp,"/")==1) then | |||
anothertemp = string.sub(anothertemp,2) | |||
elseif (string.find(anothertemp,":")~=nil) then | |||
anothertemp = "[[Yggdrasil:"..split(anothertemp,":")[1].."|"..split(anothertemp,":")[2].."]]" | |||
end | |||
table.insert(nothertempsplittable,anothertemp) | |||
intindex = intindex + 1 | |||
end | end | ||
temptable[tempsplittable[1]] = copy(nothertempsplittable) | |||
catlist[keyd[1]][keyd[2]][numd][tempsplittable[1]] = temptable[tempsplittable[1]] | |||
if (tempsplittable[1]=="Schlagwörter") then | |||
temptable[tempsplittable[1]] = split(temptable[tempsplittable[1]][1],", ") | |||
catlist[keyd[1]][keyd[2]][numd][tempsplittable[1]] = temptable[tempsplittable[1]] | |||
end | end | ||
end | end | ||
table.insert(nosortlist,temptable) | |||
end | end | ||
return nosortlist, catlist | |||
return | end | ||
function changebin(binaasdasfgggary, integeeer) | |||
binaaasdfhry = binaasdasfgggary | |||
tochange = string.sub(binaaasdfhry, integeeer, integeeer) | |||
if(tochange == "1") then | |||
binaaasdfhry = string.sub(binaaasdfhry,1,integeeer-1).."0"..string.sub(binaaasdfhry,integeeer+1) | |||
elseif(tochange == "0") then | |||
binaaasdfhry = string.sub(binaaasdfhry,1,integeeer-1).."1"..string.sub(binaaasdfhry,integeeer+1) | |||
end | |||
return binaaasdfhry | |||
end | end | ||
function | function multchangebin(binaaghdfghsdgggary, integeeerstart, integeeerend) | ||
while (integeeerstart<=integeeerend) do | |||
binaaghdfghsdgggary = changebin(binaaghdfghsdgggary,integeeerstart) | |||
integeeerstart = integeeerstart+1 | |||
end | end | ||
return | return binaaghdfghsdgggary | ||
end | end | ||
function multset(binaafgdhjhsdgggary, numbertoset, integerstart, integerend) | |||
function | if (numbertoset == "1") then | ||
binaafgdhjhsdgggary = string.sub(binaafgdhjhsdgggary, 0, integerstart-1)..ones(integerend-integerstart+1)..string.sub(binaafgdhjhsdgggary, integerend+1) | |||
elseif(numbertoset == "0") then | |||
binaafgdhjhsdgggary = string.sub(binaafgdhjhsdgggary, 0, integerstart-1)..zeros(integerend-integerstart+1)..string.sub(binaafgdhjhsdgggary, integerend+1) | |||
end | end | ||
return binaafgdhjhsdgggary | |||
return | |||
end | end | ||
function | function multchangebinall(binaasdgggary, integerstart, integerend) | ||
izgovouv = string.sub(binaasdgggary, integerstart, integerend) | |||
if (izgovouv~=ones(integerend-integerstart+1)) then | |||
binaasdgggary = multset(binaasdgggary, "1",integerstart, integerend) | |||
else | else | ||
binaasdgggary = multset(binaasdgggary, "0",integerstart, integerend) | |||
end | end | ||
return | return binaasdgggary | ||
end | end | ||
function | |||
function tran(integedasfr) | |||
integerotut = integedasfr | |||
if (integedasfr=="1") then | |||
integerotut = "tagselected" | |||
elseif (integedasfr=="0") then | |||
integerotut = "tagunselected" | |||
end | end | ||
return integerotut | |||
end | end | ||
function | |||
function trancat(integdfghedasfr) | |||
integerdfghotut = integdfghedasfr | |||
if (integdfghedasfr=="1") then | |||
integerdfghotut = "catselected" | |||
elseif (integdfghedasfr=="0") then | |||
integerdfghotut = "catunselected" | |||
end | end | ||
return integerdfghotut | |||
end | end | ||
function | function tranlinkopen(integasdedasfr) | ||
integerasdotut = integasdedasfr | |||
if (integasdedasfr=="1") then | |||
integerasdotut = '<span class="linkwhite">' | |||
elseif (integasdedasfr=="0") then | |||
integerasdotut = '<span class="linkred">' | |||
end | end | ||
return integerasdotut | |||
end | end | ||
function | |||
function multtran(intedfgsdggedasfr) | |||
integerodfghdfghtut = intedfgsdggedasfr | |||
if (intedfgsdggedasfr==ones(string.len(intedfgsdggedasfr))) then | |||
integerodfghdfghtut = "tagselected" | |||
else | |||
integerodfghdfghtut = "tagunselected" | |||
end | end | ||
return integerodfghdfghtut | |||
end | |||
function multtranlinkopen(intedsdfgsdfgfgsdggedasfr) | |||
asdfintegerodfghdfghtut = intedsdfgsdfgfgsdggedasfr | |||
if (intedsdfgsdfgfgsdggedasfr==ones(string.len(intedsdfgsdfgfgsdggedasfr))) then | |||
asdfintegerodfghdfghtut = '<span class="linkwhite">' | |||
else | |||
asdfintegerodfghdfghtut = '<span class="linkred">' | |||
end | end | ||
return asdfintegerodfghdfghtut | |||
end | |||
function getint(binnnarry, ineetger) | |||
return string.sub(binnnarry,ineetger,ineetger) | |||
end | |||
function getmultint(binnnarry, ineetgerstarti, inteegerendi) | |||
return string.sub(binnnarry,ineetgerstarti,inteegerendi) | |||
end | |||
return | |||
function numtran(binsnnafsffarry, ineeggsdgtger) | |||
return tran(getint(binsnnafsffarry, ineeggsdgtger)) | |||
end | end | ||
function numtrancat(binsnsdfnafsffarry, ineegfdfggsdgtger) | |||
return trancat(getint(binsnsdfnafsffarry, ineegfdfggsdgtger)) | |||
end | |||
function | function numtranlinkopen(binhfghsnnarry, ineegdfsdhgtger) | ||
return tranlinkopen(getint(binhfghsnnarry, ineegdfsdhgtger)) | |||
end | end | ||
function | function nummulttran(binsnwrtzeghnarry, ineegsgdfsdhftgereins, ineegsgdfsdhftgerzwei) | ||
return multtran(getmultint(binsnwrtzeghnarry, ineegsgdfsdhftgereins, ineegsgdfsdhftgerzwei)) | |||
end | end | ||
function | function nummulttranlinkopen(binsnnarry, ineegtgereins, ineegtgerzwei) | ||
return multtranlinkopen(getmultint(binsnnarry, ineegtgereins, ineegtgerzwei)) | |||
end | end | ||
function | function categorylist() | ||
gegasdtitle = mw.title.new( "Gegenstände", "Yggdrasil" ) | |||
gegconfsatent = gegasdtitle:getContent() | |||
tabbfghbb = headertotable(gegconfsatent) | |||
lastlist = {} | |||
for | for eiwnes,zwwweites in pairs(tabbfghbb) do | ||
if (tablelength(zwwweites) == 1) then | |||
lastlist[zwwweites[1]] = {} | |||
end | end | ||
if (tablelength(zwwweites) == 2) then | |||
table.insert(lastlist[zwwweites[1]],zwwweites[2]) | |||
end | end | ||
end | end | ||
return lastlist --Kategorie-->stringlist:subcategories | |||
return | |||
end | end | ||
function | function doubletablelength(taaabaaabaal) | ||
seendlength = 0 | |||
for iaubgs,aousbd in pairs(taaabaaabaal) do | |||
seendlength = seendlength+tablelength(aousbd) | |||
end | |||
return seendlength | |||
return | |||
end | end | ||
function | |||
function markheaders(content) | |||
content = content.."\npuffercontent\n" | |||
return | content = string.gsub(content, "=\n", "=\npuffercontent\n") | ||
content = string.gsub(content, "\n=%s*([^%=]+)%s*=\n", "\n") | |||
content = string.gsub(content, "\n==%s*([^%=]+)%s*==\n", "\n!Anfang2!%1!2Ende!\n") | |||
content = string.gsub(content, "\n===%s*([^%=]+)%s*===\n", "\n!Anfang3!%1!3Ende!\n") | |||
content = string.gsub(content, "\n====%s*([^%=]+)%s*====\n", "\n!Anfang4!%1!4Ende!\n") | |||
content = string.gsub(content, "\n=====%s*([^%=]+)%s*=====\n", "\n!Anfang5!%1!5Ende!\n") | |||
content = string.gsub(content, "\n======%s*([^%=]+)%s*======\n", "\n!Anfang6!%1!6Ende!\n") | |||
return content | |||
end | end | ||
function | function onllyheaders(content) | ||
content = markheaders(content) | |||
content = string.gsub(content,"!.Ende!\n.-\n!Anfang", "\n\n") | |||
content = string.gsub(content,".*!Anfang", "") | |||
content = string.gsub(content,"!.Ende!.*", "") | |||
return content | |||
end | end | ||
function | function headertotable(content) | ||
testvar="" | |||
content = onllyheaders(content) | |||
if (string. | firsthead=1 | ||
if (string.find(content, "1!")== nil) then | |||
firsthead=firsthead+1 | |||
if (string.find(content, "2!")== nil) then | |||
firsthead=firsthead+1 | |||
if (string.find(content, "3!")== nil) then | |||
firsthead=firsthead+1 | |||
if (string.find(content, "4!")== nil) then | |||
firsthead=firsthead+1 | |||
if (string.find(content, "5!")== nil) then | |||
firsthead=firsthead+1 | |||
end | |||
end | |||
end | |||
end | |||
end | end | ||
iiiiii={1,2,2,2,2,1} | |||
content="puffer\n"..content.."\n\n2!Puffer" | |||
iall=0 | |||
headersplit={} | |||
headersplit[1] = split(content,tostring(firsthead).."!") | |||
currenthead={} | |||
finaltable={} | |||
while (iiiiii[1]<tablelength(headersplit[1])-1) do--tablelength(headersplit[1]) | |||
iall=iall+1 | |||
currenthead[1] = string.gsub(gmatchtable(headersplit[1][iiiiii[1]+1], ".-\n")[1],"\n","") | |||
finaltable[iall]={currenthead[1]..testvar} | |||
headersplit[2] = split(headersplit[1][iiiiii[1]+1],tostring(firsthead+1).."!") | |||
while (iiiiii[2]<=tablelength(headersplit[2])) do | |||
iall=iall+1 | |||
currenthead[2] = string.gsub(gmatchtable(headersplit[2][iiiiii[2]], ".-\n")[1],"\n","") | |||
finaltable[iall]={currenthead[1],currenthead[2]} | |||
headersplit[3] = split(headersplit[2][iiiiii[2]],tostring(firsthead+2).."!") | |||
while (iiiiii[3]<=tablelength(headersplit[3])) do | |||
iall=iall+1 | |||
currenthead[3] = string.gsub(gmatchtable(headersplit[3][iiiiii[3]], ".-\n")[1],"\n","") | |||
finaltable[iall]={currenthead[1],currenthead[2],currenthead[3]} | |||
headersplit[4] = split(headersplit[3][iiiiii[3]],tostring(firsthead+3).."!") | |||
while (iiiiii[4]<=tablelength(headersplit[4])) do | |||
iall=iall+1 | |||
currenthead[4] = string.gsub(gmatchtable(headersplit[4][iiiiii[4]], ".-\n")[1],"\n","") | |||
finaltable[iall]={currenthead[1],currenthead[2],currenthead[3],currenthead[4]} | |||
headersplit[5] = split(headersplit[4][iiiiii[4]],tostring(firsthead+4).."!") | |||
while (iiiiii[5]<=tablelength(headersplit[5])) do | |||
iall=iall+1 | |||
currenthead[5] = string.gsub(gmatchtable(headersplit[5][iiiiii[5]], ".-\n")[1],"\n","") | |||
finaltable[iall]={currenthead[1],currenthead[2],currenthead[3],currenthead[4],currenthead[5]} | |||
iiiiii[5]=iiiiii[5]+1 | |||
end | |||
iiiiii[5]=2 | |||
iiiiii[4]=iiiiii[4]+1 | |||
end | |||
iiiiii[4]=2 | |||
iiiiii[3]=iiiiii[3]+1 | |||
end | |||
iiiiii[3]=2 | |||
iiiiii[2]=iiiiii[2]+1 | |||
end | end | ||
iiiiii[2]=2 | |||
iiiiii[1]=iiiiii[1]+1 | |||
end | end | ||
return finaltable | |||
end | |||
function turnstring (stringtoturn) | |||
turnedstring = "" | |||
while (string.len(stringtoturn)>0) do | |||
turnedstring = string.sub(stringtoturn,1,1)..turnedstring | |||
stringtoturn = string.sub(stringtoturn,2) | |||
end | end | ||
return turnedstring | |||
end | |||
function turntable (tabletoturn) | |||
turnedtable = {} | |||
intexi = tablelength(tabletoturn) | |||
intexinnorm = 1 | |||
while (intexi>0) do | |||
turnedtable[intexi] = tabletoturn[intexinnorm] | |||
intexi = intexi-1 | |||
intexinnorm = intexinnorm+1 | |||
end | |||
return turnedtable | |||
end | |||
function relevanttags( tttagstate ) | |||
aaltags = schlagwortliste() | |||
endtags = {} | |||
iindexii = 1 | |||
realiindexii = 1 | |||
while (iindexii<=string.len(tttagstate)) do | |||
if (string.sub(tttagstate,iindexii,iindexii)=="1") then | |||
endtags[realiindexii] = aaltags[iindexii] | |||
realiindexii = realiindexii+1 | |||
end | |||
iindexii = iindexii+1 | |||
end | end | ||
return endtags | |||
end | |||
function relevantcats( cccatstate ) | |||
-- cccatstate = turnstring(cccatstate) | |||
aallcats = categorylist() | |||
endcats = {} | |||
--endcats["log"] = "" | |||
iiindexiii = string.len(cccatstate) | |||
for scatname, ssubcatnames in pairs(aallcats) do | |||
--endcats["log"] = endcats["log"]..scatname..": \n\n" | |||
for subcatindex, ssubcatname in pairs(turntable(ssubcatnames)) do | |||
if (string.sub(cccatstate,iiindexiii,iiindexiii)=="1") then | |||
if (endcats[scatname] == nil) then | |||
endcats[scatname] = {} | |||
end | |||
table.insert(endcats[scatname], ssubcatname) | |||
--endcats["log"] = endcats["log"]..ssubcatname.." "..string.sub(cccatstate,iiindexiii,iiindexiii).."\n\n" | |||
end | |||
iiindexiii = iiindexiii-1 | |||
end | |||
cccatstate = string.sub(cccatstate,1, iiindexiii) | |||
iiindexiii = string.len(cccatstate) | |||
end | |||
return endcats | |||
end | end | ||
function getpartapi(ttagstate, ccatstate) | |||
nosorttlist, cattlist = gegapi() | |||
reltags = relevanttags(ttagstate) | |||
relcats = relevantcats(ccatstate) | |||
dieqtter = {} | |||
dieqtter["Name"] = "Dieter" | |||
newnosortlist = {dieqtter} | |||
newcattlist = {} | |||
for numbergti, curretne in pairs(nosortlist) do | |||
--if (tabcontainstab(nosortlist[numbergti]["Schlagwörter"],reltags)==true) then | |||
--if(relcats[nosortlist[numbergti]["Category"]]~=nil) then | |||
--if(relcats[nosortlist[numbergti]["Category"]][nosortlist[numbergti]["Subcategory"]]~=nil) then | |||
table.insert(newnosortlist,nosortlist[numbergti]) | |||
--end | |||
--end | |||
--end | |||
end | |||
-- relcats = relevantcats(ccatstate) | |||
-- for catnubini, currini in pairs(relcats) do | |||
-- for subnubiniz, curriniz in pairs(currini) do | |||
-- for namenubbez, contcurrez in pairs(cattlist[catnubini][subnubiniz]) do | |||
-- if (tabcontainstab(cattlist[catnubini][subnubiniz][namenubbez]["Schlagwörter"],reltags)==true) then | |||
-- if (newcattlist[catnubini]==nil) then | |||
-- newcattlist[catnubini] = {} | |||
-- end | |||
-- if (newcattlist[catnubini][subnubiniz]==nil) then | |||
-- newcattlist[catnubini][subnubiniz] = {} | |||
-- end | |||
-- newcattlist[catnubini][subnubiniz][namenubbez] = contcurrez | |||
-- end | |||
-- end | |||
-- end | |||
-- end | |||
return newnosortlist--,newcattlist | |||
return | |||
end | end | ||
Version vom 18. Juni 2020, 14:48 Uhr
Die Dokumentation für dieses Modul kann unter Modul:X/Doku erstellt werden
function split (inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(string.gsub(inputstr,sep, "\0"),"%Z+") do
table.insert(t, str)
end
return t
end
function copy(obj, seen)
if type(obj) ~= 'table' then return obj end
if seen and seen[obj] then return seen[obj] end
local s = seen or {}
local res = setmetatable({}, getmetatable(obj))
s[obj] = res
for k, v in pairs(obj) do res[copy(k, s)] = copy(v, s) end
return res
end
function tabContains(tableasd, keaaay)
solution = nil --"key: "..keaaay.."\n\n"
for numgasbr,crreasdnt in pairs(tableasd) do
if (tableasd[numgasbr] == keaaay) then
solution = numgasbr
end
--solution = solution..numgasbr..": "..crreasdnt[numgasbr].."\n\n"
end
return solution
end
function tablelength(T)
local count = 0
if (T==nil or T[1]==nil) then
return 0
end
for _ in pairs(T) do count = count + 1 end
return count
end
function tabcontainstab(tableoneooop, tabletwoooop)
seanwsrer = true
if (tabletwoooop[1]~=nil) then
for numberindexthingiu, currenttableslothi in pairs(tabletwoooop) do
if (tabContains(tableoneooop,currenttableslothi) == nil) then
seanwsrer = false
end
end
end
return seanwsrer
end
function displaytablevert(taable)
endresutl=""
if (taable==nil or taable[1]==nil) then
return endresutl
end
for nnnn,entri in pairs(taable) do
endresutl=endresutl..entri.."\n"
end
return endresutl
end
function displaytablehor(taaable)
endresutal=""
if (taaable==nil or taaable[1]==nil) then
return endresutal
end
for nn,entria in pairs(taaable) do
endresutal=endresutal..entria.." - "
end
return endresutal
end
function displaytabletwo(taaaable)
endresutaal=""
if (taaaable==nil or taaaable[1]==nil) then
return endresutaal
end
for nnn,entriaa in pairs(taaaable) do
endresutaal=endresutaal..displaytablehor(entriaa).."\n\n"
end
return endresutaal
end
function gmatchtable(text, pattern)
ztable={}
for word in string.gmatch(text, pattern) do
table.insert(ztable,word)
end
return ztable
end
function getindexformat()
title = mw.title.new( "Indexformat", "Yggdrasil" )
content = title:getContent()
content = string.gsub(content, "</pre>.-<pre>" , "!!!")
content = string.gsub(content, "</pre>.*" , "")
content = string.gsub(content, ".*<pre>" , "")
content = string.gsub(content, "|" , "\n|")
content = split(content,"!!!")
return content
end
function getheader( title, namespace )
title = mw.title.new( title, namespace )
content = title:getContent()
content = string.gsub(content, "%=%=+", "§§§")
content = split("hallo"..content, "§§§")
iiii = 2
iiiii = 1
length = tablelength(content)
finaltext={}
while (iiii<=length) do
finaltext[iiiii] = content[iiii]
iiii = iiii + 2
iiiii = iiiii + 1
end
return finaltext
end
function getheaderlimit( title, namespace )
limiit = tonumber(string.sub(title, string.len(title)))
title = string.sub(title, 1, string.len(title)-2)
title = mw.title.new( title, namespace )
content = title:getContent()
curhead=""
while (0<=limiit) do
curhead = curhead.."%="
limiit = limiit-1
end
curhead = curhead.."+"
content = string.gsub(content, curhead, "no")
content = string.gsub(content, "%=%=+", "§§§")
content = split("hallo"..content, "§§§")
iiii = 2
iiiii = 1
length = tablelength(content)
endtext={}
while (iiii<=length) do
endtext[iiiii] = content[iiii]
iiii = iiii + 2
iiiii = iiiii + 1
end
return endtext
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 headertotablelimit(title, namespace)
limiiiit = tonumber(string.sub(title, string.len(title)))-1
title = string.sub(title, 1, string.len(title)-2)
title = mw.title.new( title, namespace )
content = title.getContent(title)
original = headertotable(content)
neworiginal = {}
for nnnnn,entriii in ipairs(original) do
if (tablelength(entriii)<=limiiiit) then
neworiginal[nnnnn] = entriii
end
end
return neworiginal
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 gethighest( tabhle )
highest = tabhle[1]
for numgbr,crregnt in ipairs(tabhle) do
if (highest<tabhle[numgbr]) then
highest=tabhle[numgbr]
end
end
return highest
end
function duptable( tabhdhle )
dupe = {}
nothertab = {}
for nuamgbr,craregnt in pairs(tabhdhle) do
reallycontains = tabContains(nothertab,craregnt)
if (reallycontains==nil) then
nothertab[nuamgbr] = craregnt
else
tempdupetable = {reallycontains,nuamgbr}
table.insert(dupe,tempdupetable)
end
end
return dupe
end
function schlagwortliste()
tiasdtasdfle = mw.title.new( "Schlagwortliste", "Yggdrasil" )
contegfgdfndasdat = tiasdtasdfle:getContent()
schlagworttable = {}
for thingis in string.gmatch(contegfgdfndasdat, "%{%{o%|.-%|") do
iuadiuh = string.sub(thingis,5,string.len(thingis)-1)
if (iuadiuh~="Name") then
table.insert(schlagworttable,iuadiuh)
end
end
return schlagworttable
end
function gegvorapi()
listxy = {}
gegtitle = mw.title.new( "Gegenstände", "Yggdrasil" )
gegcontent = gegtitle:getContent()
tabbbb = headertotable(gegcontent)
headerewnds = {}
tempzwweites = {}
tempzudreites = 0
tempzudreitasdafsaes = 0
for eiwnes,zwwweites in pairs(tabbbb) do
if (tablelength(zwwweites) == 3) then
tempzwweites = copy(zwwweites)
x,tempzudreites = string.find(gegcontent,"===="..tempzwweites[3].."====")
tempzudreitasdafsaes,x = string.find(gegcontent,"\n=", tempzudreites)
if (tempzudreitasdafsaes==nil) then
tempzudreitasdafsaes = string.len(gegcontent)
end
tempzwweites[4] = string.gsub(string.sub(gegcontent,tempzudreites+1,tempzudreitasdafsaes-1),"<.->","")
table.insert(listxy,tempzwweites)
end
end
return listxy -- 1:Category 2: Subcategory 3: Name 4:content
end
function zeros(intedhfgjdgkztger)
resdgsgst = ""
while (intedhfgjdgkztger>0) do
resdgsgst=resdgsgst.."0"
intedhfgjdgkztger=intedhfgjdgkztger-1
end
return resdgsgst
end
function ones(intedhfgjdfasgkztger)
resdgsasdgst = ""
while (intedhfgjdfasgkztger>0) do
resdgsasdgst=resdgsasdgst.."1"
intedhfgjdfasgkztger=intedhfgjdfasgkztger-1
end
return resdgsasdgst
end
function gegapi()
catlist = {}
nosortlist = {}
unforlist = gegvorapi()
temptable = {}
temprest = ""
tempsplittable = {}
nothertempsplittable = {}
tempimg = nil
for numd, keyd in pairs(unforlist) do
temptable = {}
if (catlist[keyd[1]] == nil) then
catlist[keyd[1]] = {}
end
if (catlist[keyd[1]][keyd[2]] == nil) then
catlist[keyd[1]][keyd[2]] = {}
end
if (catlist[keyd[1]][keyd[2]][numd] == nil) then
catlist[keyd[1]][keyd[2]][numd] = {}
end
temptable["Category"] = keyd[1]
temptable["Subcategory"] = keyd[2]
temptable["Name"] = keyd[3]
catlist[keyd[1]][keyd[2]][numd]["Name"] = keyd[3]
temptable["Text"] = string.gsub(string.gsub(split(keyd[4], "\n%|\n")[2],"%}%}",""),"\n\n","")
catlist[keyd[1]][keyd[2]][numd]["Text"] = temptable["Text"]
temprest = split(keyd[4], "\n%|\n")[1]
tempimg = string.match(temprest,"img=.-\n")
anothertemp = ""
if (tempimg~= nil) then
temptable["Img"] = string.sub(tempimg,5)
catlist[keyd[1]][keyd[2]][numd]["Img"] = temptable["Img"]
end
temprest = string.gsub(string.gsub(temprest,"\n",""), "{{YggTab.-|!", "")
temprest = string.gsub(temprest, "{{YggTab|!", "|-|!")
temprest = split(temprest,"|%-|!")
for tri,asdf in pairs(temprest) do
tempsplittable = split(asdf,"|")
intindex = 2
nothertempsplittable = {}
while (intindex<=tablelength(tempsplittable)) do
anothertemp = tempsplittable[intindex]
if (string.find(anothertemp,"/")==1) then
anothertemp = string.sub(anothertemp,2)
elseif (string.find(anothertemp,":")~=nil) then
anothertemp = "[[Yggdrasil:"..split(anothertemp,":")[1].."|"..split(anothertemp,":")[2].."]]"
end
table.insert(nothertempsplittable,anothertemp)
intindex = intindex + 1
end
temptable[tempsplittable[1]] = copy(nothertempsplittable)
catlist[keyd[1]][keyd[2]][numd][tempsplittable[1]] = temptable[tempsplittable[1]]
if (tempsplittable[1]=="Schlagwörter") then
temptable[tempsplittable[1]] = split(temptable[tempsplittable[1]][1],", ")
catlist[keyd[1]][keyd[2]][numd][tempsplittable[1]] = temptable[tempsplittable[1]]
end
end
table.insert(nosortlist,temptable)
end
return nosortlist, catlist
end
function changebin(binaasdasfgggary, integeeer)
binaaasdfhry = binaasdasfgggary
tochange = string.sub(binaaasdfhry, integeeer, integeeer)
if(tochange == "1") then
binaaasdfhry = string.sub(binaaasdfhry,1,integeeer-1).."0"..string.sub(binaaasdfhry,integeeer+1)
elseif(tochange == "0") then
binaaasdfhry = string.sub(binaaasdfhry,1,integeeer-1).."1"..string.sub(binaaasdfhry,integeeer+1)
end
return binaaasdfhry
end
function multchangebin(binaaghdfghsdgggary, integeeerstart, integeeerend)
while (integeeerstart<=integeeerend) do
binaaghdfghsdgggary = changebin(binaaghdfghsdgggary,integeeerstart)
integeeerstart = integeeerstart+1
end
return binaaghdfghsdgggary
end
function multset(binaafgdhjhsdgggary, numbertoset, integerstart, integerend)
if (numbertoset == "1") then
binaafgdhjhsdgggary = string.sub(binaafgdhjhsdgggary, 0, integerstart-1)..ones(integerend-integerstart+1)..string.sub(binaafgdhjhsdgggary, integerend+1)
elseif(numbertoset == "0") then
binaafgdhjhsdgggary = string.sub(binaafgdhjhsdgggary, 0, integerstart-1)..zeros(integerend-integerstart+1)..string.sub(binaafgdhjhsdgggary, integerend+1)
end
return binaafgdhjhsdgggary
end
function multchangebinall(binaasdgggary, integerstart, integerend)
izgovouv = string.sub(binaasdgggary, integerstart, integerend)
if (izgovouv~=ones(integerend-integerstart+1)) then
binaasdgggary = multset(binaasdgggary, "1",integerstart, integerend)
else
binaasdgggary = multset(binaasdgggary, "0",integerstart, integerend)
end
return binaasdgggary
end
function tran(integedasfr)
integerotut = integedasfr
if (integedasfr=="1") then
integerotut = "tagselected"
elseif (integedasfr=="0") then
integerotut = "tagunselected"
end
return integerotut
end
function trancat(integdfghedasfr)
integerdfghotut = integdfghedasfr
if (integdfghedasfr=="1") then
integerdfghotut = "catselected"
elseif (integdfghedasfr=="0") then
integerdfghotut = "catunselected"
end
return integerdfghotut
end
function tranlinkopen(integasdedasfr)
integerasdotut = integasdedasfr
if (integasdedasfr=="1") then
integerasdotut = '<span class="linkwhite">'
elseif (integasdedasfr=="0") then
integerasdotut = '<span class="linkred">'
end
return integerasdotut
end
function multtran(intedfgsdggedasfr)
integerodfghdfghtut = intedfgsdggedasfr
if (intedfgsdggedasfr==ones(string.len(intedfgsdggedasfr))) then
integerodfghdfghtut = "tagselected"
else
integerodfghdfghtut = "tagunselected"
end
return integerodfghdfghtut
end
function multtranlinkopen(intedsdfgsdfgfgsdggedasfr)
asdfintegerodfghdfghtut = intedsdfgsdfgfgsdggedasfr
if (intedsdfgsdfgfgsdggedasfr==ones(string.len(intedsdfgsdfgfgsdggedasfr))) then
asdfintegerodfghdfghtut = '<span class="linkwhite">'
else
asdfintegerodfghdfghtut = '<span class="linkred">'
end
return asdfintegerodfghdfghtut
end
function getint(binnnarry, ineetger)
return string.sub(binnnarry,ineetger,ineetger)
end
function getmultint(binnnarry, ineetgerstarti, inteegerendi)
return string.sub(binnnarry,ineetgerstarti,inteegerendi)
end
function numtran(binsnnafsffarry, ineeggsdgtger)
return tran(getint(binsnnafsffarry, ineeggsdgtger))
end
function numtrancat(binsnsdfnafsffarry, ineegfdfggsdgtger)
return trancat(getint(binsnsdfnafsffarry, ineegfdfggsdgtger))
end
function numtranlinkopen(binhfghsnnarry, ineegdfsdhgtger)
return tranlinkopen(getint(binhfghsnnarry, ineegdfsdhgtger))
end
function nummulttran(binsnwrtzeghnarry, ineegsgdfsdhftgereins, ineegsgdfsdhftgerzwei)
return multtran(getmultint(binsnwrtzeghnarry, ineegsgdfsdhftgereins, ineegsgdfsdhftgerzwei))
end
function nummulttranlinkopen(binsnnarry, ineegtgereins, ineegtgerzwei)
return multtranlinkopen(getmultint(binsnnarry, ineegtgereins, ineegtgerzwei))
end
function categorylist()
gegasdtitle = mw.title.new( "Gegenstände", "Yggdrasil" )
gegconfsatent = gegasdtitle:getContent()
tabbfghbb = headertotable(gegconfsatent)
lastlist = {}
for eiwnes,zwwweites in pairs(tabbfghbb) do
if (tablelength(zwwweites) == 1) then
lastlist[zwwweites[1]] = {}
end
if (tablelength(zwwweites) == 2) then
table.insert(lastlist[zwwweites[1]],zwwweites[2])
end
end
return lastlist --Kategorie-->stringlist:subcategories
end
function doubletablelength(taaabaaabaal)
seendlength = 0
for iaubgs,aousbd in pairs(taaabaaabaal) do
seendlength = seendlength+tablelength(aousbd)
end
return seendlength
end
function markheaders(content)
content = content.."\npuffercontent\n"
content = string.gsub(content, "=\n", "=\npuffercontent\n")
content = string.gsub(content, "\n=%s*([^%=]+)%s*=\n", "\n")
content = string.gsub(content, "\n==%s*([^%=]+)%s*==\n", "\n!Anfang2!%1!2Ende!\n")
content = string.gsub(content, "\n===%s*([^%=]+)%s*===\n", "\n!Anfang3!%1!3Ende!\n")
content = string.gsub(content, "\n====%s*([^%=]+)%s*====\n", "\n!Anfang4!%1!4Ende!\n")
content = string.gsub(content, "\n=====%s*([^%=]+)%s*=====\n", "\n!Anfang5!%1!5Ende!\n")
content = string.gsub(content, "\n======%s*([^%=]+)%s*======\n", "\n!Anfang6!%1!6Ende!\n")
return content
end
function onllyheaders(content)
content = markheaders(content)
content = string.gsub(content,"!.Ende!\n.-\n!Anfang", "\n\n")
content = string.gsub(content,".*!Anfang", "")
content = string.gsub(content,"!.Ende!.*", "")
return content
end
function headertotable(content)
testvar=""
content = onllyheaders(content)
firsthead=1
if (string.find(content, "1!")== nil) then
firsthead=firsthead+1
if (string.find(content, "2!")== nil) then
firsthead=firsthead+1
if (string.find(content, "3!")== nil) then
firsthead=firsthead+1
if (string.find(content, "4!")== nil) then
firsthead=firsthead+1
if (string.find(content, "5!")== nil) then
firsthead=firsthead+1
end
end
end
end
end
iiiiii={1,2,2,2,2,1}
content="puffer\n"..content.."\n\n2!Puffer"
iall=0
headersplit={}
headersplit[1] = split(content,tostring(firsthead).."!")
currenthead={}
finaltable={}
while (iiiiii[1]<tablelength(headersplit[1])-1) do--tablelength(headersplit[1])
iall=iall+1
currenthead[1] = string.gsub(gmatchtable(headersplit[1][iiiiii[1]+1], ".-\n")[1],"\n","")
finaltable[iall]={currenthead[1]..testvar}
headersplit[2] = split(headersplit[1][iiiiii[1]+1],tostring(firsthead+1).."!")
while (iiiiii[2]<=tablelength(headersplit[2])) do
iall=iall+1
currenthead[2] = string.gsub(gmatchtable(headersplit[2][iiiiii[2]], ".-\n")[1],"\n","")
finaltable[iall]={currenthead[1],currenthead[2]}
headersplit[3] = split(headersplit[2][iiiiii[2]],tostring(firsthead+2).."!")
while (iiiiii[3]<=tablelength(headersplit[3])) do
iall=iall+1
currenthead[3] = string.gsub(gmatchtable(headersplit[3][iiiiii[3]], ".-\n")[1],"\n","")
finaltable[iall]={currenthead[1],currenthead[2],currenthead[3]}
headersplit[4] = split(headersplit[3][iiiiii[3]],tostring(firsthead+3).."!")
while (iiiiii[4]<=tablelength(headersplit[4])) do
iall=iall+1
currenthead[4] = string.gsub(gmatchtable(headersplit[4][iiiiii[4]], ".-\n")[1],"\n","")
finaltable[iall]={currenthead[1],currenthead[2],currenthead[3],currenthead[4]}
headersplit[5] = split(headersplit[4][iiiiii[4]],tostring(firsthead+4).."!")
while (iiiiii[5]<=tablelength(headersplit[5])) do
iall=iall+1
currenthead[5] = string.gsub(gmatchtable(headersplit[5][iiiiii[5]], ".-\n")[1],"\n","")
finaltable[iall]={currenthead[1],currenthead[2],currenthead[3],currenthead[4],currenthead[5]}
iiiiii[5]=iiiiii[5]+1
end
iiiiii[5]=2
iiiiii[4]=iiiiii[4]+1
end
iiiiii[4]=2
iiiiii[3]=iiiiii[3]+1
end
iiiiii[3]=2
iiiiii[2]=iiiiii[2]+1
end
iiiiii[2]=2
iiiiii[1]=iiiiii[1]+1
end
return finaltable
end
function turnstring (stringtoturn)
turnedstring = ""
while (string.len(stringtoturn)>0) do
turnedstring = string.sub(stringtoturn,1,1)..turnedstring
stringtoturn = string.sub(stringtoturn,2)
end
return turnedstring
end
function turntable (tabletoturn)
turnedtable = {}
intexi = tablelength(tabletoturn)
intexinnorm = 1
while (intexi>0) do
turnedtable[intexi] = tabletoturn[intexinnorm]
intexi = intexi-1
intexinnorm = intexinnorm+1
end
return turnedtable
end
function relevanttags( tttagstate )
aaltags = schlagwortliste()
endtags = {}
iindexii = 1
realiindexii = 1
while (iindexii<=string.len(tttagstate)) do
if (string.sub(tttagstate,iindexii,iindexii)=="1") then
endtags[realiindexii] = aaltags[iindexii]
realiindexii = realiindexii+1
end
iindexii = iindexii+1
end
return endtags
end
function relevantcats( cccatstate )
-- cccatstate = turnstring(cccatstate)
aallcats = categorylist()
endcats = {}
--endcats["log"] = ""
iiindexiii = string.len(cccatstate)
for scatname, ssubcatnames in pairs(aallcats) do
--endcats["log"] = endcats["log"]..scatname..": \n\n"
for subcatindex, ssubcatname in pairs(turntable(ssubcatnames)) do
if (string.sub(cccatstate,iiindexiii,iiindexiii)=="1") then
if (endcats[scatname] == nil) then
endcats[scatname] = {}
end
table.insert(endcats[scatname], ssubcatname)
--endcats["log"] = endcats["log"]..ssubcatname.." "..string.sub(cccatstate,iiindexiii,iiindexiii).."\n\n"
end
iiindexiii = iiindexiii-1
end
cccatstate = string.sub(cccatstate,1, iiindexiii)
iiindexiii = string.len(cccatstate)
end
return endcats
end
function getpartapi(ttagstate, ccatstate)
nosorttlist, cattlist = gegapi()
reltags = relevanttags(ttagstate)
relcats = relevantcats(ccatstate)
dieqtter = {}
dieqtter["Name"] = "Dieter"
newnosortlist = {dieqtter}
newcattlist = {}
for numbergti, curretne in pairs(nosortlist) do
--if (tabcontainstab(nosortlist[numbergti]["Schlagwörter"],reltags)==true) then
--if(relcats[nosortlist[numbergti]["Category"]]~=nil) then
--if(relcats[nosortlist[numbergti]["Category"]][nosortlist[numbergti]["Subcategory"]]~=nil) then
table.insert(newnosortlist,nosortlist[numbergti])
--end
--end
--end
end
-- relcats = relevantcats(ccatstate)
-- for catnubini, currini in pairs(relcats) do
-- for subnubiniz, curriniz in pairs(currini) do
-- for namenubbez, contcurrez in pairs(cattlist[catnubini][subnubiniz]) do
-- if (tabcontainstab(cattlist[catnubini][subnubiniz][namenubbez]["Schlagwörter"],reltags)==true) then
-- if (newcattlist[catnubini]==nil) then
-- newcattlist[catnubini] = {}
-- end
-- if (newcattlist[catnubini][subnubiniz]==nil) then
-- newcattlist[catnubini][subnubiniz] = {}
-- end
-- newcattlist[catnubini][subnubiniz][namenubbez] = contcurrez
-- end
-- end
-- end
-- end
return newnosortlist--,newcattlist
end