Module:Gems

From Dota 2 Wiki
Jump to: navigation, search

Documentation for Module:Gems Jump to code ↴ [ edit | purge ]

Reality Rift icon.png
▶️ Planeshift.
The documentation for this module can be found at Template:Gems.
You may be forwarded to another wiki language, in case a translation is not available.


Dependencies

local p = {}
local cosmetic = require( 'Module:Cosmetic' )._main
local getArgs = require( 'Module:Arguments' ).getArgs


function p.main(frame)
  local args = getArgs(frame, {
    wrappers = {
      'Template:Gems'
    }
  })
  return p._main( args )
end

function p._main(args)
  local i, rows = 1, {}
  while args['item' .. i] do
    local item = tostring(cosmetic({ args['item' .. i] }))
    
    local gems = {}
    
    for _,type in ipairs({ 'gem', 'spectator', 'kinetic' }) do
      local n = 1
      while args['item' .. i .. type .. n] do
        table.insert( gems, tostring(cosmetic({ args['item' .. i .. type .. n] })) )
        n = n + 1
      end
    end
    gems = table.concat( gems )
    
    table.insert( rows, string.format( '| style="vertical-align:top;" | %s || [[File:Gemarrow.png|100px]] || style="vertical-align:top;" | %s', gems, item ) )
    
    i = i + 1
  end
  
  return string.format( '{| style="text-align:right;"\n%s\n|}', table.concat( rows, '\n|-\n' ) )
end


return p