16,985
edits
mNo edit summary |
(Correct Slayer function issues) |
||
Line 420: | Line 420: | ||
slayerLevel = 99 -- this might upgrade to 120 in some update | slayerLevel = 99 -- this might upgrade to 120 in some update | ||
end | end | ||
if | if type(tierID) ~= 'number' then | ||
return nil | return nil | ||
elseif ConstantData.Slayer.Tiers[tierID + 1] == nil then | elseif ConstantData.Slayer.Tiers[tierID + 1] == nil then | ||
Line 430: | Line 430: | ||
result.maxQuantity = 10*(tierID+1) + 4*slayerLevel | result.maxQuantity = 10*(tierID+1) + 4*slayerLevel | ||
return result | return result | ||
end | |||
end | |||
function p.getSlayerTier(name) | |||
local tierID = ConstantData.slayerTier[name] | |||
if tierID == nil then | |||
return nil | |||
else | |||
return p.getSlayerTierByID(tierID) | |||
end | end | ||
end | end | ||
Line 439: | Line 448: | ||
for i, tier in ipairs(ConstantData.Slayer.Tiers) do | for i, tier in ipairs(ConstantData.Slayer.Tiers) do | ||
if tier.minLevel <= level | if tier.minLevel <= level and (tier.maxLevel == nil) or (tier.maxLevel >= level) then | ||
return p.getSlayerTierByID(i - 1) | |||
end | end | ||
end | end | ||
end | end | ||
Line 461: | Line 458: | ||
-- | -- | ||
function p.getSlayerTierName( | function p.getSlayerTierName(tierID, fallback) | ||
return type(tierID) == 'number' and ConstantData.slayerTier[tierID] or "ERROR: Invalid Slayer tier[[Category:Pages with script errors]]" | |||
end | end | ||
function p.getSlayerTierNameByLevel(lvl, fallback) | function p.getSlayerTierNameByLevel(lvl, fallback) | ||
local tier = p.getSlayerTierByLevel(lvl) | local tier = p.getSlayerTierByLevel(lvl) | ||
if tier | if type(tier) == 'table' then | ||
return tier.display | return tier.display | ||
else | else | ||
return fallback or "ERROR: Invalid Slayer tier [[Category:Pages with script errors]]" | return fallback or "ERROR: Invalid Slayer tier[[Category:Pages with script errors]]" | ||
end | end | ||
end | end | ||