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 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 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 p = { getInfo = function(itemid) --SetDefaults(itemid) if ItemIdSets('IsFood',itemid) then --SetFoodDefaults(this.type) elseif itemid <= 1000 then --SetDefaults1(this.type) return require('Module:Iteminfo/datagen1').getInfo(itemid) elseif itemid <= 2001 then --SetDefaults2(this.type) elseif itemid <= 3000 then --SetDefaults3(this.type) elseif itemid > 3989 then --SetDefaults5(this.type) else --SetDefaults4(this.type) end return export(this) 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 output = output .. '\n[' .. itemid .. '] = ' .. export(t) .. ',\n' end return output end, }

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

return p