Modul:RO
Die Dokumentation für dieses Modul kann unter Modul:RO/Doku erstellt werden
local p = {} function p.next(frame) local page = frame.args[1] title = mw.title .new(page) pt = title:getContent() local match = os.date('%y')..'%-%d%d%-(%d%d+)' local new = 1 for w in string.gmatch(pt, match) do local num = tonumber(w) if num >= new then new = num + 1 end end local lv = tonumber(string.match(page, '%d+')) local out = os.date('%y')..'-'..string.format("%02i", lv)..'-'..string.format("%02i", new) return out end function p.punktesumme(frame) return p.punktesumme2(frame.args[1], frame.args[2], frame.args[3]) end function p.punktesumme2(ro,jahr,typ) local page = 'RO:' .. ro if jahr == nil or jahr == "" then jahr = '%w+' end if typ == nil or typ == "" then typ = '%wW' end title = mw.title .new(page) pt = title:getContent() local punkte = 0 for w in string.gmatch(pt, '| Punkte%s+'..typ..'%s+'..jahr..'%s+=%s+(%d+)') do local num = tonumber(w) punkte = punkte + num end return punkte end function p.bgcolor(frame) local ro = frame.args[1] local j = tonumber(frame.args[2]) local ret = '' local jahr = os.date('%Y') local vier = tonumber(p.punktesumme2(ro,jahr-4)) local drei = tonumber(p.punktesumme2(ro,jahr-3)) local zwei = tonumber(p.punktesumme2(ro,jahr-2)) local eins = tonumber(p.punktesumme2(ro,jahr-1)) local null = tonumber(p.punktesumme2(ro,jahr)) if (j == 0 and null > 0) then if ( null > 5 and eins > 5 and zwei > 5 and drei > 5 or null+eins+zwei+drei >= 20) then return 'style="background:#00ff00" |' else return 'style="background:#fffa00" |' end elseif null == 0 and eins == 0 and zwei == 0 then if (j == 1 or j == 2) then return 'style="background:#ff0000" |' end elseif eins+zwei+drei+vier < 20 then return 'style="background:#fffa00" |' end return '' end return p