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 = {} do 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 end

local AmmoID = {} do 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; end

local ItemRarityColor = {} do ItemRarityColor.AmberMinus11 = -11 ItemRarityColorTrashMinus1 = -1 ItemRarityColorWhite0 = 0 ItemRarityColorBlue1 = 1 ItemRarityColorGreen2 = 2 ItemRarityColorOrange3 = 3 ItemRarityColorLightRed4 = 4 ItemRarityColorPink5 = 5 ItemRarityColorLightPurple6 = 6 ItemRarityColorLime7 = 7 ItemRarityColorYellow8 = 8 ItemRarityColorCyan9 = 9 ItemRarityColorStrongRed10 = 10 ItemRarityColorPurple11 = 11 end

local SoundID = {} for i = 1, 172 do	SoundID['Item'..i] = 'Item_'..i end

local this = {}

local function SetShopValues(rarity, coinValue) this.rare = rarity; this.value = coinValue; end

local function ResetStats(Type) this.tooltipContext = -1 this.sentry = false this.canBePlacedInVanityRegardlessOfConditions = false this.DD2Summon = false this.shopSpecialCurrency = -1 this.shopCustomPrice = false 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.craftable = 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 = '' 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

SetDefaults = function (Type) if Type < 0 then netDefaults(Type) return end ResetStats(Type) if this.type >= 5043 then this.type = 0 end if this.type == 0 then this.netID = 0 this.stack = 0 elseif ItemIdSets('IsFood',this.type) then SetFoodDefaults(this.type) elseif this.type <= 1000 then SetDefaults1(this.type) elseif this.type <= 2001 then SetDefaults2(this.type) elseif this.type <= 3000 then SetDefaults3(this.type) elseif this.type > 3989 then SetDefaults5(this.type) else SetDefaults4(this.type) end --this.dye = GetShaderIdFromItemId(this.type) --if this.hairDye ~= 0 then -- -1 by default --	this.hairDye = GameShaders.Hair.GetShaderIdFromItemId(this.type) --end if this.type == 2015 then this.value = Item.sellPrice(0, 0, 5, 0) end if this.type == 2016 then this.value = Item.sellPrice(0, 0, 7, 50) end if this.type == 2017 then this.value = Item.sellPrice(0, 0, 7, 50) end if this.type == 2019 then this.value = Item.sellPrice(0, 0, 5, 0) end if this.type == 2018 then this.value = Item.sellPrice(0, 0, 5, 0) end if this.type == 3563 then this.value = Item.sellPrice(0, 0, 5, 0) end if this.type == 261 then this.value = Item.sellPrice(0, 0, 7, 50) end if this.type == 2205 then this.value = Item.sellPrice(0, 0, 12, 50) end if this.type == 2123 then this.value = Item.sellPrice(0, 0, 7, 50) end if this.type == 2122 then this.value = Item.sellPrice(0, 0, 7, 50) end if this.type == 2003 then this.value = Item.sellPrice(0, 0, 10, 0) end if this.type == 2156 then this.value = Item.sellPrice(0, 0, 15, 0) end if this.type == 2157 then this.value = Item.sellPrice(0, 0, 15, 0) end if this.type == 2121 then this.value = Item.sellPrice(0, 0, 15, 0) end if this.type == 1992 then this.value = Item.sellPrice(0, 0, 3, 0) end if this.type == 2004 then this.value = Item.sellPrice(0, 0, 5, 0) end if this.type == 2002 then this.value = Item.sellPrice(0, 0, 5, 0) end if this.type == 2740 then this.value = Item.sellPrice(0, 0, 2, 50) end if this.type == 2006 then this.value = Item.sellPrice(0, 0, 10, 0) end if this.type == 3191 then this.value = Item.sellPrice(0, 0, 20, 0) end if this.type == 3192 then this.value = Item.sellPrice(0, 0, 2, 50) end if this.type == 3193 then this.value = Item.sellPrice(0, 0, 5, 0) end if this.type == 3194 then this.value = Item.sellPrice(0, 0, 10, 0) end if this.type == 2007 then this.value = Item.sellPrice(0, 0, 50, 0) end if this.type == 2673 then this.value = Item.sellPrice(0, 10, 0, 0) end if this.bait > 0 then if this.bait >= 50 then this.rare = 3 elseif this.bait >= 30 then this.rare = 2 elseif this.bait >= 15 then this.rare = 1 end end if this.type >= 1994 and this.type <= 2001 then local num = this.type - 1994 if num == 0 then this.value = Item.sellPrice(0, 0, 5, 0) end if num == 4 then this.value = Item.sellPrice(0, 0, 10, 0) end if num == 6 then this.value = Item.sellPrice(0, 0, 15, 0) end if num == 3 then this.value = Item.sellPrice(0, 0, 20, 0) end if num == 7 then this.value = Item.sellPrice(0, 0, 30, 0) end if num == 2 then this.value = Item.sellPrice(0, 0, 40, 0) end if num == 1 then this.value = Item.sellPrice(0, 0, 75, 0) end if num == 5 then this.value = Item.sellPrice(0, 1, 0, 0) end end if this.type == 2663 or this.type == 1720 or this.type == 2137 or this.type == 2155 or this.type == 2151 or this.type == 1704 or this.type == 2143 or this.type == 1710 or this.type == 2238 or this.type == 2133 or this.type == 2147 or this.type == 2405 or this.type == 1716 or this.type == 1705 then this.value = Item.sellPrice(0, 2, 0, 0) end if ProjectileInfo(this.shoot).aiStyle == 7 then --if Main.projHook[this.shoot] then this.useStyle = 0 this.useTime = 0 this.useAnimation = 0 end if ItemIdSets('IsDrill', this.type) or ItemIdSets('IsChainsaw', this.type) then this.useTime = math.floor(this.useTime * 0.6) if this.useTime < 1 then this.useTime = 1 end this.useAnimation = math.floor(this.useAnimation * 0.6) if this.useAnimation < 1 then this.useAnimation = 1 end this.tileBoost = this.tileBoost - 1 end if ItemIdSets('IsFood', this.type) then this.holdStyle = 1 end if this.type >= 1803 and this.type <= 1807 then SetDefaults(1533 + this.type - 1803) end if this.dye > 0 then this.maxStack = 99 end if this.createTile == 19 then this.maxStack = 999 end this.netID = this.type -- this.material = ItemID.Sets.IsAMaterial[this.type] // use

--RebuildTooltip // use or 	if this.type > 0 and this.type < 5043 and ItemIdSets('Deprecated', this.type) then this.netID = 0 this.type = 0 this.stack = 0 end 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) local info if ItemIdSets('IsFood',itemid) then info = require('Module:Iteminfo/datagen4').getInfo(itemid) -- food items in datagen4 elseif itemid <= 1000 then info = require('Module:Iteminfo/datagen1').getInfo(itemid) elseif itemid <= 2001 then info = require('Module:Iteminfo/datagen2').getInfo(itemid) elseif itemid <= 3000 then info = require('Module:Iteminfo/datagen3').getInfo(itemid) elseif itemid > 3989 then info = require('Module:Iteminfo/datagen5').getInfo(itemid) else info = require('Module:Iteminfo/datagen4').getInfo(itemid) end -- other stats: info.dye = require('Module:Iteminfo/idSets').getValue('dyes', itemid) and 1 or 0 info.hairDye = require('Module:Iteminfo/idSets').getValue('hairDyes', itemid) local frame = mw.getCurrentFrame info.internalName = frame:expandTemplate{ title = 'ItemInternalNameFromId', args = {itemid} } info.name = frame:expandTemplate{ title = 'gameText', args = { ('ItemName.' .. info.internalName), lang = 'en' } }

-- crafting: info.material = (frame:expandTemplate{ title = 'recipes/exist', args = { ingredient = info.name } } ~= '') and true or false info.craftable = (frame:expandTemplate{ title = 'recipes/exist', args = { result = info.name } } ~= '') and true or false

-- DD2shop if itemid == 3813 then info.shopCustomPrice = 75 end if itemid == 3818 then info.shopCustomPrice = 5 end if itemid == 3824 then info.shopCustomPrice = 5 end if itemid == 3832 then info.shopCustomPrice = 5 end if itemid == 3829 then info.shopCustomPrice = 5 end if itemid == 3819 then info.shopCustomPrice = 25 end if itemid == 3825 then info.shopCustomPrice = 25 end if itemid == 3833 then info.shopCustomPrice = 25 end if itemid == 3830 then info.shopCustomPrice = 25 end if itemid == 3820 then info.shopCustomPrice = 100 end if itemid == 3826 then info.shopCustomPrice = 100 end if itemid == 3834 then info.shopCustomPrice = 100 end if itemid == 3831 then info.shopCustomPrice = 100 end if itemid == 3800 then info.shopCustomPrice = 25 end if itemid == 3801 then info.shopCustomPrice = 25 end if itemid == 3802 then info.shopCustomPrice = 25 end if itemid == 3797 then info.shopCustomPrice = 25 end if itemid == 3798 then info.shopCustomPrice = 25 end if itemid == 3799 then info.shopCustomPrice = 25 end if itemid == 3803 then info.shopCustomPrice = 25 end if itemid == 3804 then info.shopCustomPrice = 25 end if itemid == 3805 then info.shopCustomPrice = 25 end if itemid == 3806 then info.shopCustomPrice = 25 end if itemid == 3807 then info.shopCustomPrice = 25 end if itemid == 3808 then info.shopCustomPrice = 25 end if itemid == 3871 then info.shopCustomPrice = 75 end if itemid == 3872 then info.shopCustomPrice = 75 end if itemid == 3873 then info.shopCustomPrice = 75 end if itemid == 3874 then info.shopCustomPrice = 75 end if itemid == 3875 then info.shopCustomPrice = 75 end if itemid == 3876 then info.shopCustomPrice = 75 end if itemid == 3877 then info.shopCustomPrice = 75 end if itemid == 3878 then info.shopCustomPrice = 75 end if itemid == 3879 then info.shopCustomPrice = 75 end if itemid == 3880 then info.shopCustomPrice = 75 end if itemid == 3881 then info.shopCustomPrice = 75 end if itemid == 3882 then info.shopCustomPrice = 75 end -- expert item: if info.expert then info.rarity = info.rare info.rare = -12 end -- unset unused field. info.expertOnly = nil info.favorited = nil info.stack = nil info.shadowOrbPrice = nil info.dungeonPrice = nil info.queenBeePrice = nil info.hellPrice = nil info.eclipsePrice = nil info.eclipsePostPlanteraPrice = nil info.eclipseMothronPrice = nil return info 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 = '' SetDefaults(0) local reset = { name = , internalName =  } for k,v in pairs(this) do			reset[k] = v		end for itemid = min, max do			local d = iteminfo(itemid) local t = {} if itemid ~= 0 then for k,v in pairs(d) do					if d[k] ~= reset[k] then t[k] = d[k] end end else t = d			end t.type = nil output = output .. '\n[' .. itemid .. '] = ' .. export(t) .. ',\n' end return output end, } return p