Modul:Xfunc: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
(42 dazwischenliegende Versionen derselben Benutzerin werden nicht angezeigt) | |||
Zeile 39: | Zeile 39: | ||
for _ in pairs(T) do count = count + 1 end | for _ in pairs(T) do count = count + 1 end | ||
return count | return count | ||
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 | end | ||
Zeile 387: | Zeile 400: | ||
end | end | ||
return schlagworttable | return turntable(schlagworttable) | ||
end | end | ||
Zeile 470: | Zeile 483: | ||
temprest = string.gsub(string.gsub(temprest,"\n",""), "{{YggTab.-|!", "") | temprest = string.gsub(string.gsub(temprest,"\n",""), "{{YggTab.-|!", "") | ||
temprest = string.gsub(temprest, "{{YggTab|!", "|-|!") | temprest = string.gsub(temprest, "{{YggTab|!", "|-|!") | ||
temprest = split(temprest,"|%-|!") | temprest = turntable(split(temprest,"|%-|!")) | ||
for tri,asdf in pairs(temprest) do | for tri,asdf in pairs(temprest) do | ||
tempsplittable = split(asdf,"|") | tempsplittable = split(asdf,"|") | ||
Zeile 617: | Zeile 630: | ||
gegasdtitle = mw.title.new( "Gegenstände", "Yggdrasil" ) | gegasdtitle = mw.title.new( "Gegenstände", "Yggdrasil" ) | ||
gegconfsatent = gegasdtitle:getContent() | gegconfsatent = gegasdtitle:getContent() | ||
tabbfghbb = headertotable(gegconfsatent) | tabbfghbb = turntable(headertotable(gegconfsatent)) | ||
lastlist = {} | lastlist = {} | ||
for eiwnes,zwwweites in pairs(tabbfghbb) do | for eiwnes,zwwweites in pairs(tabbfghbb) do | ||
if (tablelength(zwwweites) == 2) then | if (tablelength(zwwweites) == 2) then | ||
if(lastlist[zwwweites[1]] == nil) then | |||
lastlist[zwwweites[1]] = {} | |||
end | |||
table.insert(lastlist[zwwweites[1]],zwwweites[2]) | table.insert(lastlist[zwwweites[1]],zwwweites[2]) | ||
end | end | ||
end | end | ||
return lastlist --Kategorie-->stringlist:subcategories | return lastlist --Kategorie-->stringlist:subcategories | ||
end | |||
function getdes() | |||
gegasdtditle = mw.title.new( "Gegenstände", "Yggdrasil" ) | |||
gegcodnfsatent = gegasdtditle:getContent() | |||
ccctkist = categorylist() | |||
newendftie = {} | |||
for aszg,gouh in pairs(ccctkist) do | |||
tmpstringe = split(string.match(gegcodnfsatent, "%=%="..aszg.."%=%=.-%<%/big%>%<%/big%>"),"%<big%>%<big%>")[2] | |||
newendftie[aszg] = tmpstringe | |||
for asszg,gsouh in pairs(gouh) do | |||
tmpstringe = split(string.match(gegcodnfsatent, "%=%=%="..gsouh.."%=%=%=.-%<%/big%>%<%/big%>"),"%<big%>%<big%>")[2] | |||
newendftie[gsouh] = tmpstringe | |||
end | |||
end | |||
return newendftie | |||
end | end | ||
Zeile 756: | Zeile 786: | ||
return turnedstring | return turnedstring | ||
end | end | ||
Zeile 815: | Zeile 834: | ||
reltags = relevanttags(ttagstate) | reltags = relevanttags(ttagstate) | ||
relcats = relevantcats(ccatstate) | relcats = relevantcats(ccatstate) | ||
newnosortlist = {} | |||
newnosortlist = { | |||
newcattlist = {} | newcattlist = {} | ||
for numbergti, curretne in pairs( | for numbergti, curretne in pairs(nosorttlist) do | ||
if (tabcontainstab( | if (tabcontainstab(nosorttlist[numbergti]["Schlagwörter"],reltags)==true) then | ||
if(relcats[ | if(relcats[nosorttlist[numbergti]["Category"]]~=nil) then | ||
if(tabContains(relcats[ | if(tabContains(relcats[nosorttlist[numbergti]["Category"]],nosorttlist[numbergti]["Subcategory"])~=nil) then | ||
table.insert(newnosortlist, | table.insert(newnosortlist,nosorttlist[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][curriniz]) do | |||
if (tabcontainstab(cattlist[catnubini][curriniz][namenubbez]["Schlagwörter"],reltags)==true) then | |||
if (newcattlist[catnubini]==nil) then | |||
newcattlist[catnubini] = {} | |||
end | |||
if (newcattlist[catnubini][curriniz]==nil) then | |||
newcattlist[catnubini][curriniz] = {} | |||
end | |||
newcattlist[catnubini][curriniz][namenubbez] = contcurrez | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
return newnosortlist--, | return newnosortlist, newcattlist | ||
end | |||
function getyggtabapi(ttaegtstate, ccatsetatte) | |||
sorrrrt, cattttt = getpartapi(ttaegtstate, ccatsetatte) | |||
yggtabapi = {} | |||
for nue, cue in pairs(turntable(sorrrrt)) do | |||
if (yggtabapi[cue["Category"]]==nil) then | |||
yggtabapi[cue["Category"]] = {} | |||
end | |||
if (yggtabapi[cue["Category"]][cue["Subcategory"]]==nil) then | |||
yggtabapi[cue["Category"]][cue["Subcategory"]] = {} | |||
end | |||
TabID = "" | |||
for cuenum, cuecur in pairs(cue) do | |||
if (cuenum~="Img" and cuenum~="Category" and cuenum~="Subcategory" and cuenum~="Text" and cuenum~="Name") then | |||
TabID = TabID.."!"..cuenum.."§§§" | |||
for asfaf, asdfsd in pairs(cuecur) do | |||
TabID = TabID.."/"..asdfsd.."§§§" | |||
end | |||
TabID = TabID.."-§§§" | |||
end | |||
end | |||
TabID = string.sub(TabID,1,string.len(TabID)-7).."\n"..cue["Text"] | |||
yggtabapi[cue["Category"]][cue["Subcategory"]][cue["Name"]] = {["Img"]=cue["Img"], ["TabID"]=TabID} | |||
end | |||
return yggtabapi | |||
end | end |
Aktuelle Version vom 18. Juni 2020, 18:20 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Xfunc/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 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 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 turntable(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 = turntable(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 = turntable(headertotable(gegconfsatent))
lastlist = {}
for eiwnes,zwwweites in pairs(tabbfghbb) do
if (tablelength(zwwweites) == 2) then
if(lastlist[zwwweites[1]] == nil) then
lastlist[zwwweites[1]] = {}
end
table.insert(lastlist[zwwweites[1]],zwwweites[2])
end
end
return lastlist --Kategorie-->stringlist:subcategories
end
function getdes()
gegasdtditle = mw.title.new( "Gegenstände", "Yggdrasil" )
gegcodnfsatent = gegasdtditle:getContent()
ccctkist = categorylist()
newendftie = {}
for aszg,gouh in pairs(ccctkist) do
tmpstringe = split(string.match(gegcodnfsatent, "%=%="..aszg.."%=%=.-%<%/big%>%<%/big%>"),"%<big%>%<big%>")[2]
newendftie[aszg] = tmpstringe
for asszg,gsouh in pairs(gouh) do
tmpstringe = split(string.match(gegcodnfsatent, "%=%=%="..gsouh.."%=%=%=.-%<%/big%>%<%/big%>"),"%<big%>%<big%>")[2]
newendftie[gsouh] = tmpstringe
end
end
return newendftie
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 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)
newnosortlist = {}
newcattlist = {}
for numbergti, curretne in pairs(nosorttlist) do
if (tabcontainstab(nosorttlist[numbergti]["Schlagwörter"],reltags)==true) then
if(relcats[nosorttlist[numbergti]["Category"]]~=nil) then
if(tabContains(relcats[nosorttlist[numbergti]["Category"]],nosorttlist[numbergti]["Subcategory"])~=nil) then
table.insert(newnosortlist,nosorttlist[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][curriniz]) do
if (tabcontainstab(cattlist[catnubini][curriniz][namenubbez]["Schlagwörter"],reltags)==true) then
if (newcattlist[catnubini]==nil) then
newcattlist[catnubini] = {}
end
if (newcattlist[catnubini][curriniz]==nil) then
newcattlist[catnubini][curriniz] = {}
end
newcattlist[catnubini][curriniz][namenubbez] = contcurrez
end
end
end
end
return newnosortlist, newcattlist
end
function getyggtabapi(ttaegtstate, ccatsetatte)
sorrrrt, cattttt = getpartapi(ttaegtstate, ccatsetatte)
yggtabapi = {}
for nue, cue in pairs(turntable(sorrrrt)) do
if (yggtabapi[cue["Category"]]==nil) then
yggtabapi[cue["Category"]] = {}
end
if (yggtabapi[cue["Category"]][cue["Subcategory"]]==nil) then
yggtabapi[cue["Category"]][cue["Subcategory"]] = {}
end
TabID = ""
for cuenum, cuecur in pairs(cue) do
if (cuenum~="Img" and cuenum~="Category" and cuenum~="Subcategory" and cuenum~="Text" and cuenum~="Name") then
TabID = TabID.."!"..cuenum.."§§§"
for asfaf, asdfsd in pairs(cuecur) do
TabID = TabID.."/"..asdfsd.."§§§"
end
TabID = TabID.."-§§§"
end
end
TabID = string.sub(TabID,1,string.len(TabID)-7).."\n"..cue["Text"]
yggtabapi[cue["Category"]][cue["Subcategory"]][cue["Name"]] = {["Img"]=cue["Img"], ["TabID"]=TabID}
end
return yggtabapi
end