Difference between revisions of "Module:Equipment"

From BTAWiki
Jump to navigation Jump to search
Line 17: Line 17:
 
   local tableList= mw.html.create('ul')
 
   local tableList= mw.html.create('ul')
 
    
 
    
   for k,v in pairs(value) do
+
   for k,v in pairs(mechs) do
 
     tableList:tag('li'):wikitext(string.format("%s:%s  %s:%s", type(k), tostring(k), type(v), tostring(v)))
 
     tableList:tag('li'):wikitext(string.format("%s:%s  %s:%s", type(k), tostring(k), type(v), tostring(v)))
 
   end
 
   end

Revision as of 11:19, 7 December 2021

Documentation for this module may be created at Module:Equipment/doc

-- Module:Equipment is my attempt to create a list of mechs that use a particular 
-- bit of equipment with the idea being you can see what mechs to hunt for particular bits of gear.

local p = {}

local mechs = require('Module:Mech').core
local getArgs = require('Module:Arguments').getArgs


function p.equipmentMechs(frame)
  local tpl_args = getArgs(frame, {parentFirst=true})

  local equipment = tpl_args[1]

  local key, value = next(mechs)

  local tableList= mw.html.create('ul')
  
  for k,v in pairs(mechs) do
    tableList:tag('li'):wikitext(string.format("%s:%s  %s:%s", type(k), tostring(k), type(v), tostring(v)))
  end

  return tableList

  -- return mw.html.create('div').wikitext(string.format("%s:%s  %s:%s", type(key), tostring(key), type(value), tostring(value)))
end

function p.mechEquipment(frame)
  local tpl_args = getArgs(frame, {parentFirst=true})
  gearpiece = tpl_args[1]

  local mech = mechs.mech_inventory.componentDefID(gearpiece)

  if mech == nil then
    return mw.html.create('div').wikitext("''Mech not found''")
  end

  local equip = {}

  local mechList = mw.html.create('ul')

  for _, tag in ipairs(mech.equip) do
    if p.componentID[equip] ~= nil then
      table.insert(equip, p.componentID[tag])
    end
  end

  table.sort(tags)
  for _, tag in ipairs(equip) do
    factionList:tag('li'):wikitext(tag)
  end
  
  return mechList
end

return p