Module:Iteminfo

local data = mw.loadData( 'Module:iteminfo/data' ) -- loading data table. (What a hell!)

local trim = mw.text.trim

-- cache local currentFrame

local getArg = function(key) local value = currentFrame.args[key] if not value then return nil end value = trim(value) if value == '' then return nil else return value end end

local function getStats(itemid) local stats = data[itemid] local result if stats and stats['_base'] then result = getStats(stats['_base']) else result = { ['type'] = false, ['sentry'] = false, ['DD2Summon'] = false, ['expert'] = false, ['expertOnly'] = false, ['thrown'] = false, ['questItem'] = false, ['fishingPole'] = 0, ['bait'] = 0, ['hairDye'] = -1, ['makeNPC'] = 0, ['dye'] = 0, ['paint'] = 0, ['tileWand'] = -1, ['notAmmo'] = false, ['crit'] = 0, ['mech'] = false, ['flame'] = false, ['reuseDelay'] = 0, ['melee'] = false, ['magic'] = false, ['ranged'] = false, ['summon'] = false, ['placeStyle'] = 0, ['buffTime'] = 0, ['buffType'] = 0, ['mountType'] = -1, ['cartTrack'] = false, ['noWet'] = false, ['vanity'] = false, ['mana'] = 0, ['channel'] = false, ['noMelee'] = false, ['noUseGraphic'] = false, ['lifeRegen'] = 0, ['shootSpeed'] = 0, ['alpha'] = 0, ['ammo'] = 0, ['useAmmo'] = 0, ['autoReuse'] = false, ['accessory'] = false, ['axe'] = 0, ['healMana'] = 0, ['bodySlot'] = -1, ['legSlot'] = -1, ['headSlot'] = -1, ['potion'] = false, ['glowMask'] = -1, ['consumable'] = false, ['createTile'] = -1, ['createWall'] = -1, ['damage'] = -1, ['defense'] = 0, ['hammer'] = 0, ['healLife'] = 0, ['holdStyle'] = 0, ['knockBack'] = 0, ['maxStack'] = 1, ['pick'] = 0, ['rare'] = 0, ['scale'] = 1, ['shoot'] = 0, ['stack'] = 0, ['ToolTip'] = false, ['tileBoost'] = 0, ['useStyle'] = 0, ['useTime'] = 100, ['useAnimation'] = 100, ['value'] = 0, ['useTurn'] = false, ['handOnSlot'] = -1, ['handOffSlot'] = -1, ['backSlot'] = -1, ['frontSlot'] = -1, ['shoeSlot'] = -1, ['waistSlot'] = -1, ['wingSlot'] = -1, ['shieldSlot'] = -1, ['neckSlot'] = -1, ['faceSlot'] = -1, ['balloonSlot'] = -1, ['uniqueStack'] = false, ['width'] = false, ['height'] = false, ['stringColor'] = false, }	end -- out of range and Deprecated ID. if itemid >= 3930 or itemid <= 0 or (itemid >= 2772 and itemid <= 2785 and itemid ~= 2776 and itemid ~= 2781) or itemid == 2881 or itemid == 3273 or (itemid >= 3340 and itemid <= 3346) or (itemid >= 3462 and itemid <= 3465) or itemid == 3750 or (itemid >= 3847 and itemid <= 3851) or itemid == 3861 or itemid == 3862 then return result end

for k,v in pairs(stats) do		result[k] = v	end

--this.dye = (byte) GameShaders.Armor.GetShaderIdFromItemId(this.type); Bind at DyeInitializer.cs: LoadArmorDyes if (itemid >= 1007 and itemid <=1018) or (itemid >= 1007+12 and itemid <= 1018+12) or (itemid >= 1007+31 and itemid <= 1018+31) or (itemid >= 1007+44 and itemid <= 1018+44) or (itemid >= 2874 and itemid <=2877) then result['dye'] = 1 -- basic dyes elseif (itemid >= 1031 and itemid <= 1037) or itemid == 1050 or (itemid >= 1063 and itemid <= 1070) or itemid == 1969 or itemid == 2864 or (itemid >= 2869 and itemid <= 2873) or itemid == 2878 or itemid == 2879 or (itemid >= 2883 and itemid <= 2885) or (itemid >= 3024 and itemid <= 3028) or (itemid >= 3038 and itemid <= 3042) or itemid == 3190 or (itemid >= 3526 and itemid <= 3530) or (itemid >= 3533 and itemid <= 3535) or (itemid >= 3550 and itemid <= 3562) or (itemid >= 3597 and itemid <= 3600) then result['dye'] = 2 -- ext dyes end

if result['hairDye'] ~= 0 then --this.hairDye = GameShaders.Hair.GetShaderIdFromItemId(this.type); Bind at DyeInitializer.cs: LoadHairDyes if (itemid >= 1977 and itemid <= 1986) or itemid == 2863 or itemid == 3259 then result['hairDye'] = 1 end end

if itemid == 2015 then result['value'] = (0 + 5 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2016 then result['value'] = (50 + 7 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2017 then result['value'] = (50 + 7 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2019 then result['value'] = (0 + 5 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2018 then result['value'] = (0 + 5 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 3563 then result['value'] = (0 + 5 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 261 then result['value'] = (50 + 7 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2205 then result['value'] = (50 + 12 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2123 then result['value'] = (50 + 7 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2122 then result['value'] = (50 + 7 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2003 then result['value'] = (0 + 20 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2156 then result['value'] = (0 + 15 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2157 then result['value'] = (0 + 15 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2121 then result['value'] = (0 + 15 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 1992 then result['value'] = (0 + 3 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2004 then result['value'] = (0 + 5 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2002 then result['value'] = (0 + 5 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2740 then result['value'] = (50 + 2 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2006 then result['value'] = (0 + 20 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 3191 then result['value'] = (0 + 20 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 3192 then result['value'] = (50 + 2 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 3193 then result['value'] = (0 + 5 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 3194 then result['value'] = (0 + 10 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2007 then result['value'] = (0 + 50 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif itemid == 2673 then result['value'] = (0 + 0 * 100 + 10 * 100 * 100 + 0 * 100 * 100 * 100) * 5 end

if result['bait'] > 0 then if result['bait'] >= 50 then result['rare'] = 3 elseif result['bait'] >= 30 then result['rare'] = 2 elseif result['bait'] >= 15 then result['rare'] = 1 end end

if itemid >= 1994 and itemid <= 2001 then local num1 = itemid - 1994 if num1 == 0 then result['value'] = (0 + 5 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif num1 == 4 then result['value'] = (0 + 10 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif num1 == 6 then result['value'] = (0 + 15 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif num1 == 3 then result['value'] = (0 + 20 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif num1 == 7 then result['value'] = (0 + 30 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif num1 == 2 then result['value'] = (0 + 40 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif num1 == 1 then result['value'] = (0 + 75 * 100 + 0 * 100 * 100 + 0 * 100 * 100 * 100) * 5 elseif num1 == 5 then result['value'] = (0 + 0 * 100 + 1 * 100 * 100 + 0 * 100 * 100 * 100) * 5 end end

if itemid == 483 or itemid == 1192 or itemid == 482 or itemid == 1185 or itemid == 484 or itemid == 1199 or itemid == 368 then result['autoReuse'] = true; result['damage'] = math.floor(result['damage'] * 1.15) end

if itemid == 2663 or itemid == 1720 or itemid == 2137 or itemid == 2155 or itemid == 2151 or itemid == 1704 or itemid == 2143 or itemid == 1710 or itemid == 2238 or itemid == 2133 or itemid == 2147 or itemid == 2405 or itemid == 1716 or itemid == 1705 then result['value'] = (0 + 0 * 100 + 2 * 100 * 100 + 0 * 100 * 100 * 100) * 5 end

-- is hook if result['shoot'] == 13 or result['shoot'] == 32 or result['shoot'] == 73 or result['shoot'] == 74 or result['shoot'] == 165 or (result['shoot'] >= 230 and result['shoot'] <= 235) or result['shoot'] == 256 or result['shoot'] == 315 or result['shoot'] == 322 or result['shoot'] == 331 or result['shoot'] == 332 or result['shoot'] == 372 or result['shoot'] == 396 or result['shoot'] == 403 or result['shoot'] == 446 or result['shoot'] == 489 or (result['shoot'] >= 646 and result['shoot'] <= 649) or result['shoot'] == 652 then result['useStyle'] = 0 result['useTime'] = 0 result['useAnimation'] = 0 end -- key molds if itemid >= 1803 and itemid <= 1807 then result = getStats(1533 + itemid - 1803) end

-- if this.dye ... if result['dye'] > 0 then result['maxStack'] = 99 end

if result['createTile'] == 19 then result['maxStack'] = 999 end

--result['RebuildTooltip'];

result['_base'] = nil result['type'] = itemid return result end

---

local p = { getInfo = function (frame) currentFrame = frame -- cache

local itemid = tonumber(getArg('id') or 0) local prefix = getArg('prefix') or '_iteminfo_'

local result = getStats(itemid)

local args = {} for k,v in pairs(result) do table.insert(args, prefix .. k)			table.insert(args, v)		end

frame:callParserFunction{ name = '#dplvar:set', args = args } end,

getStats = getStats }

p.getinfo = p.getInfo p.GetInfo = p.getInfo

return p