Anonymous

Module:Attacks: Difference between revisions

From Melvor Idle
Update for v1.1
(Use tabs instead of spaces for indentation)
(Update for v1.1)
Line 3: Line 3:
local p = {}
local p = {}


local AttackData = mw.loadData('Module:Attacks/data')
local GameData = require('Modules:GameData')
 
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')


Line 73: Line 72:


function p.getAttackByID(ID)
function p.getAttackByID(ID)
return AttackData.Attacks[ID + 1]
    return GameData.getEntityByID('attacks', ID)
end
end


Line 80: Line 79:
name = string.gsub(name, "'", "'")
name = string.gsub(name, "'", "'")
name = string.gsub(name, "'", "'")
name = string.gsub(name, "'", "'")
for i, attack in ipairs(AttackData.Attacks) do
    return GameData.getEntityByName('attacks', name)
if name == attack.name then
return attack
end
end
end
end


function p.getAttacks(checkFunc)
function p.getAttacks(checkFunc)
local result = {}
    return GameData.getEntities('attacks', checkFunc)
for i, attack in ipairs(AttackData.Attacks) do
if checkFunc(attack) then
table.insert(result, attack)
end
end
return result
end
end