Module:Iteminfo

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

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 p = { getInfo = function (frame) currentFrame = frame -- cache

local npcid = tonumber(getArg(frame, 'id') or 0) local prefix = getArg(frame, 'prefix') or '_npcinfo_' local count = tonumber(getArg(frame, 'players') or 1)

-- 76/146/408 not used. if npcid < -65 or npcid > 579 or npcid == 0 or npcid == 76 or npcid == 146 or npcid == 408 then return end

local normal, expert, hardmode, postplantera = NPC(npcid, count) local fields = {"aiStyle", "boss", "buffImmuneAll", "damage", "defense", "dontCountMe", "friendly", "knockBackResist", "lifeMax", "netID", "npcSlots", "playersCount", "rarity", "scale", "townNPC", "type", "value"} local args = {} for i,v in ipairs(fields) do table.insert(args, prefix .. v)			table.insert(args, normal[v]) end fields = {'damage', 'defense', 'lifeMax', 'knockBackResist', 'value'} for i,v in ipairs(fields) do table.insert(args, prefix .. v .. '_expert') table.insert(args, expert[v]) table.insert(args, prefix .. v .. '_hardmode') table.insert(args, hardmode[v]) table.insert(args, prefix .. v .. '_postplantera') table.insert(args, postplantera[v]) end local imm = {} for k,v in pairs(normal.buffImmune) do			if v then table.insert(imm, k)			end end table.sort(imm) table.insert(args, prefix .. 'buffImmune') table.insert(args, table.concat(imm, ', '))

frame:callParserFunction{ name = '#dplvar:set', args = args } end,

clear = function (frame) local prefix = getArg(frame, 'prefix') or '_npcinfo_'

local fields = {"aiStyle", "boss", "buffImmuneAll", "damage", "defense", "dontCountMe", "friendly", "knockBackResist", "lifeMax", "netID", "npcSlots", "playersCount", "rarity", "scale", "townNPC", "type", "value"} local args = {} for i,v in ipairs(fields) do table.insert(args, prefix .. v)			table.insert(args, '') end fields = {'damage', 'defense', 'lifeMax', 'knockBackResist', 'value'} for i,v in ipairs(fields) do table.insert(args, prefix .. v .. '_expert') table.insert(args, '') table.insert(args, prefix .. v .. '_hardmode') table.insert(args, '') table.insert(args, prefix .. v .. '_postplantera') table.insert(args, '') end table.insert(args, prefix .. 'buffImmune') table.insert(args, '')

frame:callParserFunction{ name = '#dplvar:set', args = args } end,

go = function (npcid, count, prefix) local npcid = npcid or 0 local prefix = prefix or '_npcinfo_' local count = count or 1

-- 76/146/408 not used. 403/404 followed 402. if npcid == 76 or npcid == 146 or npcid == 403 or npcid == 404 or npcid == 408 then return end

local normal, expert, hardmode, postplantera = NPC(npcid, count) local fields = {"aiStyle", "boss", "buffImmuneAll", "damage", "defense", "dontCountMe", "friendly", "knockBackResist", "lifeMax", "netID", "npcSlots", "playersCount", "rarity", "scale", "townNPC", "type", "value"} local args = {} for i,v in ipairs(fields) do table.insert(args, prefix .. v)			table.insert(args, normal[v]) end fields = {'damage', 'defense', 'lifeMax', 'knockBackResist', 'value'} for i,v in ipairs(fields) do table.insert(args, prefix .. v .. '_expert') table.insert(args, expert[v]) table.insert(args, prefix .. v .. '_hardmode') table.insert(args, hardmode[v]) table.insert(args, prefix .. v .. '_postplantera') table.insert(args, postplantera[v]) end local imm = '' for k,v in pairs(normal.buffImmune) do			if v then imm = imm .. k .. ','			end end table.insert(args, prefix .. 'buffImmune') table.insert(args, string.sub(imm, 1, -2))

for i,v in ipairs(args) do			mw.log(v) end

return args end, }

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

return p