Module:Iteminfo/datagen

-- to gen data slice.

-- 1.4.0.2

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 ItemIdSets = require('Module:Iteminfo/idSets').getValue

local ProjectileInfo = require('Module:Projectileinfo').getProjectileInfo

local Item = {} Item.buyPrice = function(platinum, gold, silver, copper) return copper + silver * 100 + gold * 100 * 100 + platinum * 100 * 100 * 100 end Item.sellPrice = function(platinum, gold, silver, copper) return (copper + silver * 100 + gold * 100 * 100 + platinum * 100 * 100 * 100) * 5 end

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

local this = {}

local function ResetStats(Type) this.tooltipContext = -1 this.BestiaryNotes = null this.sentry = false this.canBePlacedInVanityRegardlessOfConditions = false this.DD2Summon = false this.shopSpecialCurrency = -1 this.shopCustomPrice = null this.expert = false this.isAShopItem = false this.expertOnly = false this.instanced = 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.timeSinceTheItemHasBeenReservedForSomeone = 0 this.noMelee = false this.noUseGraphic = false this.lifeRegen = 0 this.shootSpeed = 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.color = new_Color this.glowMask = -1 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 this.maxStack = 1 this.pick = 0 this.rare = 0 this.scale = 1 this.shoot = 0 this.stack = 1 --this.ToolTip = null this.tileBoost = 0 this.useStyle = 0 this.UseSound = null this.useTime = 100 this.useAnimation = 100 this.value = 0 this.useTurn = false this.buy = false this.handOnSlot = -1 this.handOffSlot = -1 this.backSlot = -1 this.frontSlot = -1 this.shoeSlot = -1 this.waistSlot = -1 this.wingSlot = -1 this.shieldSlot = -1 this.neckSlot = -1 this.faceSlot = -1 this.balloonSlot = -1 this.uniqueStack = false this.favorited = false this.type = Type end

local function SetFoodDefaults(type) if type <= 2268 then if type > 1787 then if type <= 1912 then if type == 1911 then DefaultToFood(22, 22, 207, 14400, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 10, 0)) elseif type == 1912 then DefaultToHealingPotion(22, 22, 80, 17) SetShopValues(ItemRarityColor.Blue1, 40) end elseif type == 1919 then DefaultToFood(22, 22, 207, 14400, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 25, 0)) elseif type == 1920 then DefaultToFood(22, 22, 207, 14400, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 25, 0)) else if type == 2266 then DefaultToFood(22, 22, 25, 14400, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 5, 0)) elseif type == 2267 then DefaultToFood(22, 22, 206, 28800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 30, 0)) elseif type == 2268 then DefaultToFood(22, 22, 206, 36000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 50, 0)) end end elseif type <= 357 then if type == 353 then DefaultToFood(22, 22, 25, 7200, true, 17) SetShopValues(ItemRarityColor.White0, 100) this.maxStack = 99 this.holdStyle = 1 this.ammo = 353 this.notAmmo = true elseif type == 357 then DefaultToFood(22, 22, 206, 28800, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) end elseif type == 967 then DefaultToFood(12, 12, 26, 3600, false, 17) SetShopValues(ItemRarityColor.White0, Item.buyPrice(0, 0, 1, 0)) this.useStyle = 9 elseif type == 969 then DefaultToFood(12, 12, 26, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 2, 0)) this.useStyle = 9 elseif type == 1787 then DefaultToFood(22, 22, 206, 28800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 10, 0)) end elseif type <= 4297 then if type <= 3195 then if type == 2425 then DefaultToFood(22, 22, 26, 28800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 25, 0)) elseif type == 2426 then DefaultToFood(22, 22, 206, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 75, 0)) elseif type == 2427 then DefaultToFood(22, 22, 206, 28800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 25, 0)) else if type == 3195 then DefaultToFood(22, 22, 206, 36000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) else end end elseif type == 3532 then DefaultToFood(22, 22, 207, 86400, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 5, 0, 0)) else if type == 4009 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4010 then elseif type == 4011 then DefaultToFood(22, 22, 207, 57600, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 3, 0, 0)) elseif type == 4012 then DefaultToFood(22, 22, 206, 36000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4013 then DefaultToFood(22, 22, 207, 86400, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 5, 0, 0)) elseif type == 4014 then DefaultToFood(22, 22, 26, 36000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4015 then DefaultToFood(22, 22, 207, 28800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4016 then DefaultToFood(22, 22, 206, 50400, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4017 then DefaultToFood(22, 22, 206, 72000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 3, 0, 0)) elseif type == 4018 then DefaultToFood(22, 22, 206, 57600, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4019 then DefaultToFood(22, 22, 206, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4020 then DefaultToFood(22, 22, 206, 50400, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4021 then DefaultToFood(22, 22, 206, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4022 then DefaultToFood(22, 22, 207, 172800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 50, 0, 0)) elseif type == 4023 then DefaultToFood(22, 22, 206, 57600, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4024 then DefaultToFood(22, 22, 26, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4025 then DefaultToFood(22, 22, 206, 72000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 3, 0, 0)) elseif type == 4026 then DefaultToFood(22, 22, 206, 50400, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4027 then DefaultToFood(22, 22, 207, 57600, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 3, 0, 0)) elseif type == 4028 then DefaultToFood(22, 22, 206, 57600, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4029 then DefaultToFood(22, 22, 207, 28800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4030 then DefaultToFood(22, 22, 26, 64800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 50, 0)) elseif type == 4031 then DefaultToFood(22, 22, 26, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4032 then DefaultToFood(22, 22, 206, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4033 then DefaultToFood(22, 22, 206, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4034 then DefaultToFood(22, 22, 207, 14400, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 50, 0)) elseif type == 4035 then DefaultToFood(22, 22, 206, 64800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 50, 0)) elseif type == 4036 then DefaultToFood(22, 22, 207, 28800, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4037 then DefaultToFood(22, 22, 207, 57600, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 3, 0, 0)) else if type == 4282 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4283 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4284 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4285 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4286 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4287 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4288 then DefaultToFood(22, 22, 206, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4289 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4290 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4291 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4292 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4293 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4294 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4295 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4296 then DefaultToFood(22, 22, 26, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4297 then DefaultToFood(22, 22, 206, 18000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) end end end elseif type <= 4625 then if type == 4403 then DefaultToFood(22, 22, 206, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4411 then DefaultToFood(22, 22, 26, 36000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) else if type == 4614 then DefaultToFood(22, 22, 26, 36000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4615 then DefaultToFood(22, 22, 207, 57600, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 4, 0, 0)) elseif type == 4616 then DefaultToFood(22, 22, 26, 36000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4617 then DefaultToFood(22, 22, 26, 54000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4618 then DefaultToFood(22, 22, 26, 36000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 4619 then DefaultToFood(22, 22, 26, 72000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4620 then DefaultToFood(22, 22, 26, 72000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4621 then DefaultToFood(22, 22, 26, 72000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4622 then DefaultToFood(22, 22, 26, 72000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4623 then DefaultToFood(22, 22, 206, 72000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4624 then DefaultToFood(22, 22, 26, 54000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 2, 0, 0)) elseif type == 4625 then DefaultToFood(22, 22, 26, 90000, false, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 3, 0, 0)) end end elseif type == 5009 then DefaultToFood(22, 22, 26, 18000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 0, 0, 20)) elseif type == 5041 then DefaultToFood(22, 22, 26, 54000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) elseif type == 5042 then DefaultToFood(22, 22, 206, 36000, true, 17) SetShopValues(ItemRarityColor.Blue1, Item.buyPrice(0, 1, 0, 0)) end local single = 0 if this.buffType == 207 then single = single + 12 elseif this.buffType ~=206 then single = single + 3 else single = single + 8 end single = single + (this.buffTime / 14400) this.rare = math.floor(single / 4) end

---

local function export(var) local t = mw.dumpObject(var) t = string.gsub(t, "table#1 ", "") t = string.gsub(t, "metatable = table#2", "") t = string.gsub(t, " +", "") t = string.gsub(t, "\n+", "\n") return t end

local function iteminfo(itemid) if ItemIdSets('IsFood',itemid) then SetFoodDefaults(itemid) return this elseif itemid <= 1000 then return require('Module:Iteminfo/datagen1').getInfo(itemid) elseif itemid <= 2001 then return require('Module:Iteminfo/datagen2').getInfo(itemid) elseif itemid <= 3000 then return require('Module:Iteminfo/datagen3').getInfo(itemid) elseif itemid > 3989 then return require('Module:Iteminfo/datagen5').getInfo(itemid) else return require('Module:Iteminfo/datagen4').getInfo(itemid) end end

---

local p = {

getInfo = function(itemid) return iteminfo(itemid) end,

gen = function (frame) currentFrame = frame -- cache local min = tonumber(getArg(1)) or 0 local max = tonumber(getArg(2)) or 0 local output = '' local reset = iteminfo(0)

for itemid = min, max do			local d = iteminfo(itemid) local t = {} if itemid ~= 0 then for k,v in pairs(reset) do					if d[k] ~= reset[k] then t[k] = d[k] end end else t = d			end output = output .. '\n[' .. itemid .. '] = ' .. export(t) .. ',\n' end return output end, } return p