Module:Attack type clickpic

-- local p = {}

local onmain = require('Module:Mainonly').on_main

local styles = { ['magic'] = { image = 'Magic weakness icon.png', link = 'Magic'}, ['mage'] = { image = 'Magic weakness icon.png', link = 'Magic'}, ['melee'] = { image = 'Melee weakness icon.png', link = 'Melee'}, ['ranged'] = { image = 'Ranged weakness icon.png', link = 'Ranged'}, ['range'] = { image = 'Ranged weakness icon.png', link = 'Ranged'}, ['ranging'] = { image = 'Ranged weakness icon.png', link = 'Ranged'}, ['dragonfire'] = { image = 'Dragonfire icon.png', link = 'Dragonfire'}, ['dragonbreath'] = { image = 'Dragonfire icon.png', link = 'Dragonfire'}, ['dragon'] = { image = 'Dragonfire icon.png', link = 'Dragonfire'}, ['none'] = { image = 'Zero weakness icon.png', text = 'N/A'}, ['n/a'] = { image = 'Zero weakness icon.png', text = 'N/A'}, ['nothing'] = { image = 'Zero weakness icon.png', text = 'N/A'}, ['typeless'] = { image = 'Zero weakness icon.png', text = 'No style'} }

function p.main(frame) local args = frame:getParent.args local split_list = mw.text.split(args[1],',') -- iterate through and create a parameters -- look at only the first word for styles local params = {} for i, v in ipairs(split_list) do		v = mw.text.trim(v) :lower :gsub('(%w+)%s.*','%1') :gsub('[][]','') table.insert(params, v)	end return p._main(params) end

function p._main(sargs) -- Create a list of good and bad args local good_args = {} local bad_args = {} -- Return string local ret = '' -- Category list for i, v in ipairs(sargs) do		local stls = styles[v] if stls then table.insert(good_args, stls) else table.insert(bad_args, v)		end end for i, v in ipairs(good_args) do		image = '' local link if v.link then if v.text then link = ..v.text.. else link = ..v.link.. end else link = v.text end ret = ret..image..' '..link if i < (#good_args + #bad_args) then ret = ret..' ' end end if #bad_args > 0 then local bad_list = '' for i, v in ipairs(bad_args) do bad_list = bad_list .. '&quot;' .. v .. '&quot;' if i < #bad_args then bad_list = bad_list..', ' end end ret = ret..'Bad argument ' if onmain then ret = ret..'' end end return ret end

return p