Module:Items: Difference between revisions

Added unified 'getItemSources' function
(Added function to show extra text for some item skillboxes)
(Added unified 'getItemSources' function)
Line 171: Line 171:
end
end


function p.getCreationTable(frame)
function p._getCreationTable(item)
  local itemName = frame.args ~= nil and frame.args[1] or frame
  local item = p.getItem(itemName)
  if item == nil then
    return "ERROR: No item named "..itemName.." exists in the data module"
  end
 
   local skill = ''
   local skill = ''
   local specialReq = nil
   local specialReq = nil
Line 303: Line 297:


   if Shared.tableCount(tables) == 0 then
   if Shared.tableCount(tables) == 0 then
     return "Failed to find creation requirements for this (Possibly the module isn't properly updated for this skill)"
     return ""
   else
   else
     return table.concat(tables, '\r\n<br/>')
     return table.concat(tables, '\r\n<br/>')
Line 343: Line 337:


   return result
   return result
end
function p.getCreationTable(frame)
  local itemName = frame.args ~= nil and frame.args[1] or frame
  local item = p.getItem(itemName)
  if item == nil then
    return "ERROR: No item named "..itemName.." exists in the data module"
  end
 
  return p._getCreationTable(item)
end
end


Line 985: Line 989:


   return p._getItemLootSourceTable(item)
   return p._getItemLootSourceTable(item)
end
function p._getItemSources(item)
  local result = ''
  local creationTable = p._getCreationTable(item)
  result = result..creationTable
  local lootTable = p._getItemLootSourceTable(item)
  if string.len(lootTable) > 0 then
    if string.len(result) > 0 then result = result..'<br/>' end
    result = result..lootTable
  end
  return result
end
function p.getItemSources(frame)
  local itemName = frame.args ~= nil and frame.args[1] or frame
  local item = p.getItem(itemName)
  if item == nil then
    return "ERROR: No item named "..itemName.." exists in the data module"
  end
  return p._getItemSources(item)
end
end