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 category_to_add = args.category_to_add or "" local sections = {} local idsExistForAllTabs = true for j = 1,16,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			local _i = j==1 and "" or "_"..j -- needed for when a param ends in a number naturally if not args["id"..i] then idsExistForAllTabs = false end 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], combat_level_requirement= args["combat_level_requirement"..i], dungeon_level_requirement= args["dungeon_level_requirement"..i], dungeon_floor_clearing_requirement= args["dungeon_floor_clearing_requirement"..i], other_level_requirement= args["other_level_requirement"..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] or args["usage"..i], minion_xp= args["minion_xp"..i] and "", lore= args["lore"..i], item_slots= args["item_slots"..i], -- Capacity default= args["default"..i], upgrade_1= args["upgrade_1".._i], upgrade_2= args["upgrade_2".._i], upgrade_3= args["upgrade_3".._i], upgrade_4= args["upgrade_4".._i], upgrade_5= args["upgrade_5".._i], upgrade_6= args["upgrade_6".._i], upgrade_7= args["upgrade_7".._i], upgrade_8= args["upgrade_8".._i], upgrade_9= args["upgrade_9".._i], default_name= args["default_name"..i] or "Default", upgrade_1_name= args["upgrade_1_name".._i] or "Upgrade 1", upgrade_2_name= args["upgrade_2_name".._i] or "Upgrade 2", upgrade_3_name= args["upgrade_3_name".._i] or "Upgrade 3", upgrade_4_name= args["upgrade_4_name".._i] or "Upgrade 4", upgrade_5_name= args["upgrade_5_name".._i] or "Upgrade 5", upgrade_6_name= args["upgrade_6_name".._i] or "Upgrade 6", upgrade_7_name= args["upgrade_7_name".._i] or "Upgrade 7", upgrade_8_name= args["upgrade_8_name".._i] or "Upgrade 8", upgrade_9_name= args["upgrade_9_name".._i] or "Upgrade 9", -- 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], health= args["health"..i], defense= args["defense"..i], damage= args["damage"..i], strength= args["strength"..i], crit_chance= args["crit_chance"..i], crit_damage= args["crit_damage"..i], attack_speed= args["attack_speed"..i], intelligence= args["intelligence"..i], speed= args["speed"..i], true_defense= args["true_defense"..i], magic_find= args["magic_find"..i], fishing_speed= args["fishing_speed"..i], sea_creature_chance= args["sea_creature_chance"..i], ferocity= args["ferocity"..i], mining_speed= args["mining_speed"..i], breaking_power= args["breaking_power"..i], -- Special Effects effects= args["effects"..i] or args["special_effect"..i] or args["additional_effects"..i], duration= args["duration"..i], mana_cost= args["mana_cost"..i] or args["mana.cost"..i] or args["manacost"..i] or args["ia_mana_cost"..i], item_ability= args["item_ability"..i] or args["ability"..i], cooldown= args["cooldown"..i] or args["ia_cooldown"..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= (args["trade_requirement"..i] or args["trade.requirement"..i]) and "", 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="Capacity" } :addData{ sdata.default, label=sdata.default_name } :addData{ sdata.upgrade_1, label=sdata.upgrade_1_name } :addData{ sdata.upgrade_2, label=sdata.upgrade_2_name } :addData{ sdata.upgrade_3, label=sdata.upgrade_3_name } :addData{ sdata.upgrade_4, label=sdata.upgrade_4_name } :addData{ sdata.upgrade_5, label=sdata.upgrade_5_name } :addData{ sdata.upgrade_6, label=sdata.upgrade_6_name } :addData{ sdata.upgrade_7, label=sdata.upgrade_7_name } :addData{ sdata.upgrade_8, label=sdata.upgrade_8_name } :addData{ sdata.upgrade_9, label=sdata.upgrade_9_name } :done :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", name="infobox-stats" } :addData{ sdata.health, label="" } :addData{ sdata.defense, label="" } :addData{ sdata.damage, label="" } :addData{ sdata.strength, label="" } :addData{ sdata.crit_chance, label="" } :addData{ sdata.crit_damage, label="" } :addData{ sdata.attack_speed, label="" } :addData{ sdata.intelligence, label="" } :addData{ sdata.speed, label="" } :addData{ sdata.true_defense, label="" } :addData{ sdata.magic_find, label="" } :addData{ sdata.fishing_speed, label="" } :addData{ sdata.sea_creature_chance, label="" } :addData{ sdata.ferocity, label="" } :addData{ sdata.mining_speed, label="" } :addData{ sdata.breaking_power, label="" } :addData{ sdata.stats } :done :addGroup{ header="Special Effects", layout="horizontal" } :addData{ sdata.effects, label="Special Effect" } :addData{ sdata.item_ability, label="" } :addData{ sdata.mana_cost, label="" } :addData{ sdata.duration, label="Duration" } :addData{ sdata.cooldown, label="Cooldown" } :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 table.concat{ ibox:preprocess, curTitle.namespace == 0 and category_to_add or "", curTitle.namespace == 0 and not idsExistForAllTabs and "" or "", } end

function addBazaarGroup(id, parent) if id 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