Anonymous

Module:Navboxes: Difference between revisions

From Melvor Idle
made farming navbox collapsible. maybe.
mNo edit summary
(made farming navbox collapsible. maybe.)
Line 11: Line 11:


function p.getFarmingNavbox(frame)
function p.getFarmingNavbox(frame)
   local allotmentSeeds = {}
   local allotmentSeedsTable = {}
   local herbSeeds = {}
   local allotmentProduceTable = {}
   local treeSeeds = {}
   local herbSeedsTable = {}
   local allotmentProduce = {}
   local herbProduceTable = {}
   local herbProduce = {}
   local treeSeedsTable = {}
   local treeProduce = {}
   local treeProduceTable = {}


  -- my kingdom for a switch statement
   for i, item in Shared.skpairs(ItemData.Items) do
   for i, item in Shared.skpairs(ItemData.Items) do
     if i == 2 or i == 3 or i == 5 or i == 7 or i == 8 then
     if item.tier == 'Allotment' then
       table.insert(treeProduce, Icons.Icon({item.name, type='item'}))
       table.insert(allotmentSeedsTable, Icons.Icon({item.name, type='item'}))
     elseif i >= 144 and i < 152 then
     elseif item.type == 'Harvest' then
       table.insert(allotmentSeeds, Icons.Icon({item.name, type='item'}))
       table.insert(allotmentProduceTable, Icons.Icon({item.name, type='item'}))
     elseif i >= 152 and i < 160 then
     elseif item.tier == 'Herb' then
       table.insert(allotmentProduce, Icons.Icon({item.name, type='item'}))
       table.insert(herbSeedsTable, Icons.Icon({item.name, type='item'}))
     elseif i >= 161 and i < 166 then
     elseif item.type == 'Herb' then
       table.insert(treeSeeds, Icons.Icon({item.name, type='item'}))
       table.insert(herbProduceTable, Icons.Icon({item.name, type='item'}))
     elseif i >= 520 and i < 528 then
     elseif item.tier == 'Tree' then
       table.insert(herbProduce, Icons.Icon({item.name, type='item'}))
       table.insert(treeSeedsTable, Icons.Icon({item.name, type='item'}))
     elseif i >= 528 and i < 536 then
     elseif i == 2 or i == 3 or i == 5 or i == 7 or i == 8 then
       table.insert(herbSeeds, Icons.Icon({item.name, type='item'}))
       table.insert(treeProduceTable, Icons.Icon({item.name, type='item'}))
     end
     end
   end
   end
  table.insert(allotmentSeeds, Icons.Icon({'Carrot Seeds', type='item'}))
  table.insert(allotmentProduce, Icons.Icon({'Carrot', type='item'}))


  local allotmentSeeds = table.concat(allotmentSeedsTable, ' • ')
  local allotmentProduce = table.concat(allotmentProduceTable, ' • ')
  local herbSeeds = table.concat(herbSeedsTable, ' • ')
  local herbProduce = table.concat(herbProduceTable, ' • ')
  local treeSeeds = table.concat(treeSeedsTable, ' • ')
  local treeProduce = table.concat(treeProduceTable, ' • ')
  local pagename = ''
  local allotment = 'mw-collapsible mw-collapsed'
  local herb = 'mw-collapsible mw-collapsed'
  local tree = 'mw-collapsible mw-collapsed'
  if frame.args ~= nil and frame.args[1] then
    pagename = frame.args[1]
    if Shared.contains(allotmentSeeds, pagename) or Shared.contains(allotmentProduce, pagename) then
      allotment = 'mw-collapsible'
    elseif Shared.contains(herbSeeds, pagename) or Shared.contains(herbProduce, pagename) then
      herb = 'mw-collapsible'
    elseif Shared.contains(treeSeeds, pagename) or Shared.contains(treeProduce, pagename) then
      tree = 'mw-collapsible'
    end
  end
   
   local result = '{| class="wikitable" style="margin:auto; clear:both; width: 100%"'
   local result = '{| class="wikitable" style="margin:auto; clear:both; width: 100%"'
   result = result..'\r\n!colspan="3"|'..Icons.Icon({'Farming', type='skill'})
   result = result..'\r\n!'..Icons.Icon({'Farming', type='skill'})
   result = result..'\r\n|-\r\n!scope="row" colspan="3"|Allotments'
   result = result..'{| class="wikitable '..allotment..'" style="margin:auto; clear:both; width: 100%"'
  result = result..'\r\n!colspan="2"|Allotments'
   result = result..'\r\n|-\r\n!scope="row"|Seeds'
   result = result..'\r\n|-\r\n!scope="row"|Seeds'
   result = result..'\r\n|style="text-align:center;|'..table.concat(allotmentSeeds, ' • ')
   result = result..'\r\n|style="text-align:center;|'..allotmentSeeds
   result = result..'\r\n|-\r\n!scope="row"|Produce'
   result = result..'\r\n|-\r\n!scope="row"|Produce'
   result = result..'\r\n|style="text-align:center;|'..table.concat(allotmentProduce, ' • ')
   result = result..'\r\n|style="text-align:center;|'..allotmentProduce
   result = result..'\r\n|-\r\n!scope="row" colspan="3"|Herbs'
   result = result..'\r\n|}'
  result = result..'{| class="wikitable '..herb..'" style="margin:auto; clear:both; width: 100%"'
  result = result..'\r\n!colspan="2"|Herbs'
   result = result..'\r\n|-\r\n!scope="row"|Seeds'
   result = result..'\r\n|-\r\n!scope="row"|Seeds'
   result = result..'\r\n|style="text-align:center;|'..table.concat(herbSeeds, ' • ')
   result = result..'\r\n|style="text-align:center;|'..herbSeeds
   result = result..'\r\n|-\r\n!scope="row"|Produce'
   result = result..'\r\n|-\r\n!scope="row"|Produce'
   result = result..'\r\n|style="text-align:center;|'..table.concat(herbProduce, ' • ')
   result = result..'\r\n|style="text-align:center;|'..herbProduce
   result = result..'\r\n|-\r\n!scope="row" colspan="3"|Trees'
   result = result..'\r\n|}'
  result = result..'{| class="wikitable '..tree..'" style="margin:auto; clear:both; width: 100%"'
  result = result..'\r\n!scope="row" colspan="2"|Trees'
   result = result..'\r\n|-\r\n!scope="row"|Seeds'
   result = result..'\r\n|-\r\n!scope="row"|Seeds'
   result = result..'\r\n|style="text-align:center;|'..table.concat(treeSeeds, ' • ')
   result = result..'\r\n|style="text-align:center;|'..treeSeeds
   result = result..'\r\n|-\r\n!scope="row"|Produce'
   result = result..'\r\n|-\r\n!scope="row"|Produce'
   result = result..'\r\n|style="text-align:center;|'..table.concat(treeProduce, ' ')
   result = result..'\r\n|style="text-align:center;|'..treeProduce
  result = result..'\r\n|}'
  result = result..'\r\n|}'


   return result
   return result
444

edits