Module:Item tooltip

local util_args = require('Module:ArgsUtil') local util_vars = require("Module:VarsUtil")

local cargo = mw.ext.cargo local p = {} local h = {}

function p.Main( frame ) local args = util_args.overwrite return p.makeOutput(args) end

function p.makeOutput(args) local divId = util_vars.getGlobalIndex('divId') .. '-tooltip' local text = (' \n{| class="skill-tooltip"'):format(divId) local result = h.getData(args) if not result then text = text .. "\n|}\n " return text end text = text .. '\n| rowspan="2" | ' text = text .. '\n! '..result["Name"]..'\n|-\n|' if result["Stat1"] and result.Stat1 ~= '' then text = text .. ''..result["Stat1"]..'' end if result["Stat2"] and result.Stat2 ~= '' then text = text .. ''..result["Stat2"]..'' end if result["Stat3"] and result.Stat3 ~= '' then text = text .. ''..result["Stat3"]..'' end if result["Stat4"] and result.Stat4 ~= '' then text = text .. ''..result["Stat4"]..'' end if result["Stat5"] and result.Stat5 ~= '' then text = text .. ''..result["Stat5"]..'</dd></dl>' end if result["Active"] and result.Active ~= '' then text = text .. '<dt>Active Effect</dt>'..result["Active"]..'</dd></dl>' end if result["Activecd"] and result.Activecd ~= '' then text = text .. '<dt>Active Cooldown</dt>'..result["Activecd"]..'</dd></dl>' end if result["Passive"] and result.Passive ~= '' then text = text .. '<dt>Passive Effect</dt>'..result["Passive"]..'</dd></dl>' end if result["Passivecd"] and result.Passivecd ~= '' then text = text .. '<dt>Passive Cooldown</dt>'..result["Passivecd"]..'</dd></dl>' end

text = text .. "\n|}\n " return text end

function h.getData(args) if args.Icon and args.Name then -- these seem to be the only two mandatory parameters return args end if args[1] then h.getDataFromCargo(args[1]) end return nil end

function h.getDataFromCargo(item) tables = 'Items' fields = 'Icon,Name,Stat1,Stat2,Stat3,Stat4,Stat5,Active_effect=Active,Passive_effect=Passive,Active_cooldown=Activecd,Passive_cooldown=Passivecd' local cargoArgs = { where = '_pageName = "' .. item .. '"', limit = 1 }	local result = cargo.query( tables, fields, cargoArgs ) return result[1] end

return p