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 noPage(pagename, content) return ..a..frame:expandTemplate{title = "createpageifnotex", args={       	NS_MAIN = pagename,        	NS_TEMPLATE = content        }}.. end function getRelationships(list,pixels) characters = "" for a, s in pairs(list) do		characters = characters..noPage(s,"Hello") end return characters 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', }   table.insert(data, frame:expandTemplate { title = 'Character info', args = infobox }) 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', '! Relationships', '|-'   }    for a, s in pairs(characters) do        table.insert(data, '|'..noPage(a,"Hello")) table.insert(data, '| ') table.insert(data, '|'..check(s.available)) table.insert(data, '|'..getRelationships) 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