4,951
edits
Falterfire (talk | contribs) (Added getItemByID) |
Falterfire (talk | contribs) (Added p.getPotionTable) |
||
Line 26: | Line 26: | ||
end | end | ||
function p. | function p._getItemStat(item, StatName, ZeroIfNil) | ||
local result = item[StatName] | local result = item[StatName] | ||
--Special Overrides: | --Special Overrides: | ||
Line 55: | Line 47: | ||
result = item.attackBonus[3] | result = item.attackBonus[3] | ||
end | end | ||
elseif StatName == 'attackType' then | |||
result = p._getWeaponAttackType(item) | |||
end | end | ||
if result == nil and ZeroIfNil then result = 0 end | if result == nil and ZeroIfNil then result = 0 end | ||
Line 60: | Line 54: | ||
end | end | ||
function p. | function p.getItemStat(frame) | ||
local | local args = frame.args ~= nil and frame.args or frame | ||
local item = p.getItem( | 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 | if item == nil then | ||
return "ERROR: No item named "..ItemName.." exists in the data module" | return "ERROR: No item named "..ItemName.." exists in the data module" | ||
end | end | ||
return p._getItemStat(item, StatName, ZeroIfNil) | |||
end | |||
function p._getWeaponAttackType(item) | |||
if item.type == 'Weapon' then | if item.type == 'Weapon' then | ||
return Icons.Icon({'Melee'}) | return Icons.Icon({'Melee'}) | ||
Line 75: | Line 76: | ||
return "Invalid" | return "Invalid" | ||
end | end | ||
end | |||
function p.getWeaponAttackType(frame) | |||
local itemName = frame.args ~= nil and frame.args[1] or frame | |||
local item = p.getItem(itemName) | |||
if item == nil then | |||
return "ERROR: No item named "..ItemName.." exists in the data module" | |||
end | |||
return p._getWeaponAttackType(item) | |||
end | |||
function p.getPotionTable(frame) | |||
local potionName = frame.args ~= nil and frame.args[1] or frame | |||
local tiers = {'I', 'II', 'III', 'IV'} | |||
local result = '{| class="wikitable"' | |||
result = result..'\r\n!Potion!!Tier!!Charges!!Effect' | |||
for i, tier in pairs(tiers) do | |||
local tierName = potionName..' '..tier | |||
local potion = p.getItem(tierName) | |||
if potion == nil then | |||
mw.log("Failed to get tier "..tier) | |||
else | |||
result = result..'\r\n|-' | |||
result = result..'\r\n|'..Icons.Icon({tierName, notext='true', size='60'})..'||'..tier | |||
result = result..'||'..potion.potionCharges..'||'..potion.description | |||
end | |||
end | |||
result = result..'\r\n|}' | |||
return result | |||
end | end | ||
return p | return p |