Module:Iteminfo/datagen

-- to gen data slice. 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.name = "(unknown)" 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.UseSound = "" this.useTime = 100 this.useAnimation = 100 this.value = 0 this.useTurn = false this.buy = false this.uniqueStack = false --this.favorited = false this.internalName = 'None' this.type = Type return this end

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

---

local p = { a = function(itemid) return mw.dumpObject(data[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 = resetStats(9999)

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 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, }

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

return p