Module:Featured dragon

local p = {}

-- Formats featured dragon for main page function p.main(frame) local name if frame.args[1] then name = frame.args[1] else return "Cannot parse: Name is required" end local file = getImage(name) local output = " "

if file then output = output .. "link=" .. name .."" else output = output .. "'''No file found for name: " .. name .. "'''" end

output = output .. " « " .. name .. " » " return output end

-- Selects random infobox image for breed function getImage(name) local imageMap = mw.loadData('Module:Featured dragon/Images') local images local image

if imageMap[name] then images = imageMap[name] else return nil end

local imgNum = length(images) if imgNum > 1 then math.randomseed(os.time) image = images[math.random(imgNum)] else image = images[1] end

return image end

-- Get table length function length(tbl) local count = 0 for _ in pairs(tbl) do count = count + 1 end return count end

return p