Module:Test

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

local trim = mw.text.trim

local AmmoID = { ['None'] = 0, ['Gel'] = 23, ['Arrow'] = 40, ['Coin'] = 71, ['FallenStar'] = 75, ['Bullet'] = 97, ['Sand'] = 169, ['Dart'] = 283, ['Rocket'] = 771, ['Solution'] = 780, ['Flare'] = 931, ['Snowball'] = 949, ['StyngerBolt'] = 1261, ['CandyCorn'] = 1783, ['JackOLantern'] = 1785, ['Stake'] = 1836, ['NailFriendly'] = 3108, }

-- 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 resetStats = function(Type) local this = {} this.sentry = false this.DD2Summon = false -- this.shopSpecialCurrency = -1 this.expert = false this.expertOnly = false --this.instanced = false this.thrown = false this.questItem = false this.fishingPole = 0 this.bait = 0 this.hairDye = -1 this.makeNPC = 0 this.dye = 0 this.paint = 0 this.tileWand = -1 this.notAmmo = false --this.netID = 0 --this.prefix = 0 this.crit = 0 this.mech = false this.flame = false this.reuseDelay = 0 this.melee = false this.magic = false this.ranged = false this.summon = false this.placeStyle = 0 this.buffTime = 0 this.buffType = 0 this.mountType = -1 this.cartTrack = false this.material = false this.noWet = false this.vanity = false this.mana = 0 --this.wet = false --this.wetCount = 0 --this.lavaWet = false this.channel = false --this.manaIncrease = 0 --this.release = 0 this.noMelee = false this.noUseGraphic = false this.lifeRegen = 0 this.shootSpeed = 0.0 this.active = true --this.alpha = 0 this.ammo = AmmoID.None this.useAmmo = AmmoID.None this.autoReuse = false this.accessory = false this.axe = 0 this.healMana = 0 --this.bodySlot = -1 --this.legSlot = -1 --this.headSlot = -1 this.potion = false this.consumable = false this.createTile = -1 this.createWall = -1 this.damage = -1 this.defense = 0 this.hammer = 0 this.healLife = 0 this.holdStyle = 0 this.knockBack = 0.0 this.maxStack = 1 this.pick = 0 this.rare = 0 this.scale = 1 this.shoot = 0 --this.stack = 1 this.ToolTip = nil this.tileBoost = 0 this.useStyle = 0 this.useTime = 100 this.useAnimation = 100 this.value = 0 this.useTurn = false this.buy = false this.uniqueStack = false --this.favorited = false this.type = Type return this end

---

local p = { a = function(itemid) return mw.dumpObject(data[itemid]) end, test = function (frame) currentFrame = frame -- cache local min = tonumber(getArg(1)) or 0 local max = tonumber(getArg(2)) or 0 local output = '' local reset = resetStats(9999)

for itemid = min, max do			local d = data[itemid] local t = {} if itemid ~= 0 then for k,v in pairs(reset) do					if d[k] and d[k] ~= reset[k] then t[k] = d[k] end end else t = d			end local t = mw.dumpObject(t) t = string.gsub(t, "table#1 ", "") t = string.gsub(t, "metatable = table#2", "") t = string.gsub(t, " +", "") t = string.gsub(t, "\n+", "\n") output = output .. '\n[' .. itemid .. '] = ' .. t .. ',\n' end return output end, getInfo = function (frame) currentFrame = frame -- cache

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

if itemid >= 3930 or itemid <= 0 then itemid = 0 end local result = data[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,

}

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

return p