Module:Infobox/Item

--Get Required Modules local loadLib = require('Module:LoadLib')

loadLib(_G, {	infobox='Infobox',	mRarity='RarityTier',	yesno='Yesno',	mLink='Link',	mOdds='Odds',	mInvSlot='Inventory slot', })

mw.html.create = require('Module:Html').create local curTitle = mw.title.getCurrentTitle

--Begin Exports local p = {}

local function yesnodefault(val, yes, no, def) local bool = yesno(val); if bool == nil then return def or val elseif bool then return yes else return no	end end

function p.infoboxItem(frame) local args = getArgs(frame) local pagename = curTitle.text or "Diamond" local title = args.title or pagename local sections = {} for j = 1,10,1 do		local sectionExists = j==1 or args["tab"..j]		if sectionExists then -- section one does have numbers after params; on 2+ do that local i = j==1 and "" or j			sections[#sections+1] = { -- Top level infobox values tab= args["tab"..j] or args["tab"..i], -- purposefully use "j" here since default section does actually use "tab1" image= args["image"..i] or pagename..".png", caption= args["caption"..i] or args["imagecaption"..i], slot_item= yesno(args["slot_item"..i], true) and " "..string.gsub(mInvSlot.slot{ args["slot_item"..i] or pagename }, "\n", "").." " or nil, type= args["type"..i] or "Item", id= args["id"..i] and " ", aka= args["aka"..i], rarity= args["rarity"..i] and mRarity.link{ args["rarity"..i], addcategory=true }, collection= args["collection"..i] and mLink.collectionLink{ args["collection"..i], showIcon=true }, source= args["source"..i], obtained= args["obtained"..i] or args["obtain"..i], drop_chance= args["drop_chance"..i] or args["odds"..i] and mOdds.odds{ args["drop_chance"..i] or args["odds"..i], big=true }, uses= args["uses"..i], minion_xp= args["minion_xp"..i] and "", lore= args["lore"..i], item_slots= args["item_slots"..i], -- Block Form group location= args["location"..i] and "", tool= args["tool"..i] and "", skill_xp_given= args["skill_xp_given"..i] and "", experience_given= args["experience_given"..i], normal_drop= args["normal_drop"..i], silk_touch_drop= args["silk_touch_drop"..i], smelting_touch_drop= args["smelting_touch_drop"..i], -- Stats group stats= args["stats"..i], effects= args["effects"..i], duration= args["duration"..i], mana_cost= args["mana_cost"..i] or args["mana.cost"..i] or args["manacost"..i], item_ability= args["item_ability"..i], -- Material Tiers group prev_material= args["prev_material"..i] and "" or (args["next_material"..i] and "None (lowest tier material)"), next_material= args["next_material"..i] and "" or (args["prev_material"..i] and "None (top tier material)"), -- Upgrades group upgrades_from= args["upgrades_from"..i] and "" or (args["upgrades_to"..i] and "None (lowest tier item)"), upgrades_to= args["upgrades_to"..i] and "" or (args["upgrades_from"..i] and "None (top tier item)"), -- Properties group enchant= yesnodefault(args["enchant"..i] or args["enchantable"..i], "true", "true"), reforge= yesnodefault(args["reforge"..i] or args["reforgeable"..i], "true", "true"), salable= yesnodefault(args["salable"..i] or true, "true", "true"), auctionable= yesnodefault(args["auctionable"..i] or true, "true", "true"), -- Shop merchant= args["merchant"..i] and "", daily_limit= args["daily_limit"..i], buy= args["buy"..i] and "US$"..args["buy"..i].."", sell= args["sell"..i] and "US$"..args["sell"..i].."", -- Bazaar daily_limit= args["bazaar"..i], -- Materials raw_materials= args["raw_materials"..i] and "", material_cost= args["material_cost"..i] and "", bazaar_not_including = args["bazaar_not_including"..i], mat_cost_bazaar= args["mat_cost_bazaar"..i] and "", raw_materials_upgr= args["raw_materials_upgr"..i] and "", bazaar_not_including_upgr = args["bazaar_not_including_upgr"..i], mat_cost_bazaar_upgr= args["mat_cost_bazaar_upgr"..i] and "", -- Trade trade_requirement= "", trade_from= args["trade_from"..i] or args["trade.from"..i], trade_to= args["trade_to"..i] or args["trade.to"..i], }		end end

-- Make infobox local ibox = infobox.create ibox:addTitle{ title } local panel = ibox:addPanel for i,sdata in ipairs(sections) do       local section = panel:addSection{ label=sdata.tab } section :addImage{ sdata.image, caption={ sdata.caption } } :addData{ sdata.slot_item } :addData{ sdata.type, label="Type" } :addData{ sdata.id, label="Item ID" } :addData{ sdata.aka, label="Also known as" } :addData{ sdata.rarity, label="Rarity" } :addData{ sdata.collection, label="Collection" } :addData{ sdata.source, label="Source" } :addData{ sdata.obtained, label="Obtained via" } :addData{ sdata.drop_chance, label="Drop Chance" } :addData{ sdata.uses, label="Uses" } :addData{ sdata.minion_xp, label='Minion XP ' } :addData{ sdata.lore, label="Lore" } :addData{ sdata.item_slots, label="Item Slots" } :addGroup{ header="Block Form" } :addData{ sdata.location, label="Location" } :addData{ sdata.tool, label="Tool" } :addData{ sdata.skill_xp_given, label="Skill XP Given" } :addData{ sdata.experience_given, label="Experience Given" } :addGroup{ layout="horizontal", ['row-items']=3 } :addData{ sdata.normal_drop, label="Normal drop" } :addData{ sdata.silk_touch_drop, label="Silk Touch drop" } :addData{ sdata.smelting_touch_drop, label="Smelting Touch Drop" } :done :done :addGroup{ header="Stats" } :addData{ sdata.stats } :addData{ sdata.effects, label="Effects" } :addData{ sdata.duration, label="Duration" } :addData{ sdata.mana_cost, label="" } :addData{ sdata.item_ability, label="" } :done :addGroup{ header="Material Tiers", layout="horizontal" } :addData{ sdata.prev_material, label="← Previous" } :addData{ sdata.next_material, label="Next →" } :done :addGroup{ header="Upgrades", layout="horizontal" } :addData{ sdata.upgrades_from, label="← Previous" } :addData{ sdata.upgrades_to, label="Next →" } :done :addGroup{ header="Properties", layout="horizontal", ['row-items']=2 } :addData{ sdata.enchant, label="Enchantable" } :addData{ sdata.reforge, label="Reforgeable" } :addData{ sdata.salable, label="Salable" } :addData{ sdata.auctionable, label="Auctionable" } :done :addGroup{ header="Shop", layout="horizontal", ['row-items']=2 } :addData{ sdata.merchant, label="Merchant"..(sdata.merchant and sdata.merchant:find("%s*%*%s*") and "s" or "") } :addData{ sdata.daily_limit, label='Daily Limit ' } :addData{ sdata.buy, label="Buy" } :addData{ sdata.sell, label="Sell" } :done addBazaarGroup(sdata.bazaar, section) section :addGroup{ header="Materials" } :addData{ sdata.raw_materials, label='Raw Materials ' } :addData{ sdata.material_cost, label='Material cost ' } :addData{ sdata.mat_cost_bazaar, label='Bazaar Material cost ' } :addData{ sdata.raw_materials_upgr, label='Raw Materials to upgrade ' } :addData{ sdata.mat_cost_bazaar_upgr, label='Bazaar Material cost to upgrade ' } :done :addGroup{ header="Trade", layout="horizontal" } :addData{ sdata.trade_requirement, label="Requires" } :addData{ sdata.trade_from, label="From" } :addData{ sdata.trade_to, label="To" } :done end mw.log(ibox) return ibox:preprocess end

function addBazaarGroup(id, parent) if sdata.bazaar then parent :addGroup{ header='ⓘ<', layout="horizontal", ['row-items']=2 } :addData{ label="Buy", "" } :addData{ label="Sell", "" } :addData{ label="Buy (stack)", "" } :addData{ label="Sell (stack)", "" } :addGroup{ ['row-items']=1 } :addData{ label=" Price Spread ", " " } :done :addData{ "", label='Buy Price Changeⓘ' } :addData{ "", label='Sell Price Changeⓘ' } :done end end

--Finish Module/Exports return p