Module:Characters

local p = {} local characters = mw.loadData('Module:Characters/data') local f = require('Module:Functions')

function p.other(frame) if frame.args[1] == "" then return end return frame.args[1] end

function check(num,c) if (num == nil or num == "")==true then return 'Add data here.' else return num end end

function p.infobox(frame) local name = mw.title.getCurrentTitle.text local char_data=characters[name] if char_data == nil then return " Please insert data to Module:Characters/data." end local count = 0 for i, j in pairs(char_data.facts) do       if j ~= nil then count = count+1 end end if count == 0 then return " Please insert data to Module:Characters/data." end local data = {} local infobox = { image = name..'.png', color=check(char_data.facts.color), age=check(char_data.facts.age), cupsize=check(char_data.facts.cupSize), height=check(char_data.facts.height), toys=check(char_data.facts.toys), anal=check(char_data.facts.anal), masturbation=check(char_data.facts.masturbation), born=check(char_data.facts.born), compliment=check(char_data.facts.compliment), talent=check(char_data.facts.talent), hometown=check(char_data.facts.hometown), pubic=check(char_data.facts.pubic), }   table.insert(data, frame:expandTemplate { title = 'Character info', args = infobox }) return table.concat(data, '\n') end

function p.questions(frame) local name = mw.title.getCurrentTitle.text if characters[name] == nil then return end local data = { '==Q&A==', '{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',       '! Question', '! Answer', '|-'   }    for a, s in pairs(qa) do         c=0 if s[name]~=nil then table.insert(data, '| '..s.q)           for b, d in pairs(s) do                if string.match(b,name) then c = c+1 if c == 1 then table.insert(data, '| '..d)                    else table.insert(data, " or ") table.insert(data, d)           end end end table.insert(data, '|-') end end table.insert(data, "|colspan=2|Add questions here") table.insert(data, '|}') for i, d in pairs(data) do mw.log(d) end return table.concat(data, "\n") end

function p.table(frame) local data = { '==Character List==', '{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',       '! Name', '! Picture', '! data-sort-type="number" | Available', '|-'   }    for a, s in pairs(characters) do        z = nil table.insert(data, '| '..a..'') table.insert(data, '| ') table.insert(data, '|'..check(s.chapter)) table.insert(data, '|-') end table.insert(data, '|}') for i, d in pairs(data) do mw.log(d) end return table.concat(data, "\n") end return p