Anonymous

Module:Skills/Agility: Difference between revisions

From Melvor Idle
Added p.getObstaclesForItem (which will be needed for Items/UseTables
(testing solid borders)
(Added p.getObstaclesForItem (which will be needed for Items/UseTables)
Line 9: Line 9:
local ItemSourceTables = require('Module:Items/SourceTables')
local ItemSourceTables = require('Module:Items/SourceTables')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
function p.getObstacleByID(obstID)
  local result = Shared.clone(SkillData.Agility.Obstacles[obstID + 1])
  return result
end
function p.getObstacle(name)
  for i, obst in Shared.skpairs(SkillData.Agility.Obstacles) do
    if obst.name == name then
      local result = Shared.clone(obst)
      result.id = i - 1
      return result
    end
  end
  return nil
end


function p.getObstacleCourseTable(frame)
function p.getObstacleCourseTable(frame)
Line 121: Line 137:


   result = result..'\r\n|}'
   result = result..'\r\n|}'
  return result
end
function p.getObstaclesForItem(itemID)
  local result = {}
  for i, obst in Shared.skpairs(SkillData.Agility.Obstacles) do
    for j, costLine in Shared.skpairs(obst.cost.items) do
      if costLine[1] == itemID then
        table.insert(result, obst)
      end
    end
  end
  for i, obst in Shared.skpairs(SkillData.Agility.Pillars) do
    for j, costLine in Shared.skpairs(obst.cost.items) do
      if costLine[1] == itemID then
        table.insert(result, obst)
      end
    end
  end


   return result
   return result