Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
Use printError function
(getMonsterDrops: Fix weight sorting & add secondary sort on item name)
(Use printError function)
Line 65: Line 65:
local monster = p.getMonster(MonsterName)
local monster = p.getMonster(MonsterName)
if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 97: Line 97:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 114: Line 114:
return math.floor((p._getMonsterHP(monster)/(1 - p._getMonsterStat(monster, 'damageReduction')/100)) + 0.5)
return math.floor((p._getMonsterHP(monster)/(1 - p._getMonsterStat(monster, 'damageReduction')/100)) + 0.5)
else
else
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end
end
end
Line 124: Line 124:
return p._getMonsterHP(monster)
return p._getMonsterHP(monster)
else
else
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end
end
end
Line 142: Line 142:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 177: Line 177:
return p._getMonsterAttackSpeed(monster)
return p._getMonsterAttackSpeed(monster)
else
else
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end
end
end
Line 194: Line 194:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 217: Line 217:
bonus = p.getEquipmentStat(monster, 'stabAttackBonus')
bonus = p.getEquipmentStat(monster, 'stabAttackBonus')
else
else
return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]"
return Shared.printError('This monster has an invalid attack type somehow')
end
end


Line 228: Line 228:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 248: Line 248:
bonus = p.getEquipmentStat(monster, 'magicDefenceBonus')
bonus = p.getEquipmentStat(monster, 'magicDefenceBonus')
else
else
return "ERROR: Must choose Melee, Ranged, or Magic[[Category:Pages with script errors]]"
return Shared.printError('Must choose Melee, Ranged, or Magic')
end
end


Line 261: Line 261:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 303: Line 303:


if monster == nil then
if monster == nil then
return "ERROR: No monster with name "..monsterName.." found[[Category:Pages with script errors]]"
return Shared.printError('No monster with name ' .. monsterName .. ' found')
end
end


Line 337: Line 337:


if monster == nil then
if monster == nil then
return "ERROR: No monster with name "..monsterName.." found[[Category:Pages with script errors]]"
return Shared.printError('No monster with name ' .. monsterName .. ' found')
end
end


Line 445: Line 445:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 507: Line 507:
result = max
result = max
else
else
return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]"
return Shared.printError('This monster has an invalid attack type somehow')
end
end


Line 518: Line 518:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 529: Line 529:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 615: Line 615:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end
Line 626: Line 626:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 645: Line 645:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 674: Line 674:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 715: Line 715:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 842: Line 842:
function p._getMonsterLootValue(monster)
function p._getMonsterLootValue(monster)
if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 905: Line 905:
if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end
if item == nil then
if item == nil then
return "ERROR: No item with that name found[[Category:Pages with script errors]]"
return Shared.printError('No item with that name found')
end
end
Line 937: Line 937:


if chest == nil then
if chest == nil then
return "ERROR: No item named "..chestName..' found[[Category:Pages with script errors]]'
return Shared.printError('No item named ' .. chestName .. ' found')
end
end
local result = ''
local result = ''


if chest.dropTable == nil then
if chest.dropTable == nil then
return "ERROR: "..chestName.." does not have a drop table[[Category:Pages with script errors]]"
return Shared.printError(chestName .. ' does not have a drop table')
else
else
local lootValue = 0
local lootValue = 0
Line 995: Line 995:
local area = Areas.getArea(areaName)
local area = Areas.getArea(areaName)
if area == nil then
if area == nil then
return "ERROR: Could not find an area named "..areaName..'[[Category:Pages with script errors]]'
return Shared.printError('Could not find an area named ' .. areaName)
end
end


Line 1,027: Line 1,027:
local area = Areas.getArea(areaName)
local area = Areas.getArea(areaName)
if area == nil then
if area == nil then
return "ERROR: Could not find a dungeon named "..areaName..'[[Category:Pages with script errors]]'
return Shared.printError('Could not find a dungeon named ' .. areaName)
end
end


Line 1,160: Line 1,160:
local area = Areas.getArea(areaName)
local area = Areas.getArea(areaName)
if area == nil then
if area == nil then
return "ERROR: Could not find a dungeon named "..areaName..'[[Category:Pages with script errors]]'
return Shared.printError('Could not find a dungeon named ' .. areaName)
end
end
local totalHP = 0
local totalHP = 0
Line 1,235: Line 1,235:
local area = Areas.getArea(areaName)
local area = Areas.getArea(areaName)
if area == nil then
if area == nil then
return "ERROR: Could not find an area named "..areaName..'[[Category:Pages with script errors]]'
return Shared.printError('Could not find an area named ' .. areaName)
end
end


Line 1,308: Line 1,308:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end


Line 1,334: Line 1,334:


if tier == nil then
if tier == nil then
return "ERROR: No tier specified[[Category:Pages with script errors]]"
return Shared.printError('No tier specified')
end
end


Line 1,344: Line 1,344:


if slayerTier == nil then
if slayerTier == nil then
return "ERROR: Invalid slayer tier[[Category:Pages with script errors]]"
return Shared.printError('Invalid slayer tier')
end
end


Line 1,647: Line 1,647:


if monster == nil then
if monster == nil then
return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
return Shared.printError('No monster with that name found')
end
end