Anonymous

Module:Sandbox/AuronTest: Difference between revisions

From Melvor Idle
m
getItems: Allow returning IDs only
m (Remove cloning of item tables as ID is provided in source data)
m (getItems: Allow returning IDs only)
Line 72: Line 72:
end
end


function p.getItems(checkFunc)
function p.getItems(checkFunc, IDsOnly)
   local result = {}
   local result = {}
  local returnID = (IDsOnly == nil and false or IDsOnly)
   for i, item in pairs(ItemData.Items) do
   for i, item in pairs(ItemData.Items) do
     if checkFunc(item) then
     if checkFunc(item) then
       table.insert(result, item)
       if returnID then
        table.insert(result, item.id)
      else
        table.insert(result, item)
      end
     end
     end
   end
   end