Module:Items
Lua module containing all sorts of functions for getting data on items. Pulls data from Module:GameData/data.
Some functions were split to submodules:
local p = {}
local ItemData = mw.loadData('Module:Items/data')
local Shared = require('Module:Shared')
local Icons = require('Module:Icons')
function p.getItem(name)
local result = nil
for i, item in pairs(ItemData) do
if(item.name == name) then
result = Shared.clone(item)
--Make sure every item has an id, and account for Lua being 1-index
result.id = i -1
end
end
return result
end
function p.getItemStat(frame)
local args = frame.args ~= nil and frame.args or frame
local ItemName = args[1]
local StatName = args[2]
local ZeroIfNil = args.ForceZero ~= nil and args.ForceZero ~= '' and args.ForceZero ~= 'false'
local item = p.getItem(ItemName)
if item ~= nil then
local result = item[StatName]
if result == nil and ZeroIfNil then result = 0 end
return result
else
return "ERROR: No item with that name found"
end
end
return p