4,951
edits
Falterfire (talk | contribs) (Added support for stab/slash/block bonuses) |
Falterfire (talk | contribs) (Added getWeaponAttackType) |
||
Line 24: | Line 24: | ||
local ZeroIfNil = args.ForceZero ~= nil and args.ForceZero ~= '' and args.ForceZero ~= 'false' | local ZeroIfNil = args.ForceZero ~= nil and args.ForceZero ~= '' and args.ForceZero ~= 'false' | ||
local item = p.getItem(ItemName) | local item = p.getItem(ItemName) | ||
if item | if item == nil then | ||
local result = item[StatName] | return "ERROR: No item named "..ItemName.." exists in the data module" | ||
end | |||
local result = item[StatName] | |||
--Special Overrides: | |||
if StatName == 'stabAttackBonus' then | |||
if item.attacBonus == nil then | |||
result = nil | |||
else | |||
result = item.attackBonus[1] | |||
end | |||
elseif StatName == 'slashAttackBonus' then | |||
if item.attackBonus == nil then | |||
result = nil | |||
else | |||
result = item.attackBonus[2] | |||
end | |||
elseif StatName == 'blockAttackBonus' then | |||
if item.attackBonus == nil then | |||
result = nil | |||
else | |||
result = item.attackBonus[3] | |||
end | end | ||
end | |||
if result == nil and ZeroIfNil then result = 0 end | |||
return result | |||
end | |||
function p.getWeaponAttackType(frame) | |||
if | local itemName = frame.args ~= nil and frame.args[1] or frame | ||
return | local item = p.getItem(itemName) | ||
if item == nil then | |||
return "ERROR: No item named "..ItemName.." exists in the data module" | |||
end | |||
if item.type == 'Weapon' then | |||
return Icons.Icon({'Melee'}) | |||
elseif item.type == 'Ranged Weapon' then | |||
return Icons.Icon({'Ranged', type='skill'}) | |||
elseif item.type == 'Magic Staff' or item.type == 'Magic Wand' then | |||
return Icons.Icon({'Magic', type='skill'}) | |||
else | else | ||
return " | return "Invalid" | ||
end | end | ||
end | end | ||
return p | return p |