Modul:TagDetails: Unterschied zwischen den Versionen

Aus Eco - Deutsches Wiki
Wechseln zu:Navigation, Suche
[unmarkierte Version][unmarkierte Version]
Avaren (Diskussion | Beiträge)
Back port from EN
 
Avaren (Diskussion | Beiträge)
Copying from EN
 
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 2: Zeile 2:


local Utils = require('Module:Utils')
local Utils = require('Module:Utils')
local L = require('Module:Localization')


local p = {}
local p = {}
local function icon_frame(name, link, bg, text, expensive)
    local icon = Utils.build_icon(name, link, nil, bg, nil, expensive)
    return '<div style="border: 5px outset #A9A9A9; background: #DCDCDC; display:inline-block; width: auto; padding: 10px; margin: 10px; text-align: center; vertical-align: middle;">' .. icon .. text ..'</div>'
end


-- build tag list
-- build tag list
function p.tagList(frame)
function p.tagList(frame)
  local args = Utils.normaliseArgs(frame)
    local args = Utils.normaliseArgs(frame)
 
 
  -- check that all necessary arguments are passed correctly
    -- check that all necessary arguments are passed correctly
  if args.name == nil or args.name == '' then
    if args.name == nil or args.name == '' then
    return '\'name\' must be specified.'
        return '\'name\' must be specified.'
  end
    end
 
 
  local tagName = args.name
    local tagName = args.name
 
 
  local itemData = require("Module:ItemData")
    local itemData = mw.loadData("Module:ItemData")
 
 
  local tagList = itemData.tags
    local tagList = itemData.tags
 
 
  local itemList = tagList[tagName]
    local itemList = tagList[tagName]
 
 
  if (itemList == nil) then
    if (itemList == nil) then
    return tagName .. " could not be found in Module:ItemData"
        return tagName .. " could not be found in Module:ItemData"
  end
    end
 
 
  local text = ""
    local text = ""
 
 
  text = text .. frame:expandTemplate{
    local tagLink = L.t('%s Tag'):format(tagName)
    title = 'IconFrame',
 
     args = {
     text = text .. icon_frame(L.tag(tagName) .. 'Tag', tagLink, 'iconWhite', '<h3>[[' .. tagLink .. ']]</h3>', false)
      file = string.gsub(tagName, ' ', '') .. '_Icon.png', link = tagName .. 'Tag',
 
      text = '<h3>[[' .. tagName .. 'Tag]]</h3>', style = 'iconWhite'
     local tagCount = Utils.tableLen(itemList)
    }
     if tagCount > 98 then
  }
        expensive = true
      
    else
  text = text .. '\n\n\nItems with the ' .. tagName .. ' Tag:\n'
         expensive = false
 
  for k, item in pairs(itemList) do
      
    text = text .. frame:expandTemplate{
      title = 'IconFrame',
      args = {
        file = string.gsub(item, ' ', '') .. '_Icon.png', link = item,
         text = '<h3>[[' .. item .. ']]</h3>', style = 'iconBlue'
      }}
     
     end
     end
      
 
     text = text .. '\n\n\n' .. string.format(L.t('Item with the %s Tag:', tagCount), tagName) .. '\n'
 
    for _, item in pairs(itemList) do
        text = text .. icon_frame(item, item, nil, '<h3>[[' .. item .. ']]</h3>', expensive)
    end
 
     return text
     return text
  end
end
 
 
  return p
return p

Aktuelle Version vom 16. März 2021, 18:24 Uhr

Die Dokumentation für dieses Modul kann unter Modul:TagDetails/Doku erstellt werden

-- Credit: User:Avaren

local Utils = require('Module:Utils')
local L = require('Module:Localization')

local p = {}

local function icon_frame(name, link, bg, text, expensive)
    local icon = Utils.build_icon(name, link, nil, bg, nil, expensive)
    return '<div style="border: 5px outset #A9A9A9; background: #DCDCDC; display:inline-block; width: auto; padding: 10px; margin: 10px; text-align: center; vertical-align: middle;">' .. icon .. text ..'</div>'
end

-- build tag list
function p.tagList(frame)
    local args = Utils.normaliseArgs(frame)

    -- check that all necessary arguments are passed correctly
    if args.name == nil or args.name == '' then
        return '\'name\' must be specified.'
    end

    local tagName = args.name

    local itemData = mw.loadData("Module:ItemData")

    local tagList = itemData.tags

    local itemList = tagList[tagName]

    if (itemList == nil) then
        return tagName .. " could not be found in Module:ItemData"
    end

    local text = ""

    local tagLink = L.t('%s Tag'):format(tagName)

    text = text .. icon_frame(L.tag(tagName) .. 'Tag', tagLink, 'iconWhite', '<h3>[[' .. tagLink .. ']]</h3>', false)

    local tagCount = Utils.tableLen(itemList)
    if tagCount > 98 then
        expensive = true
    else
        expensive = false
    end

    text = text .. '\n\n\n' .. string.format(L.t('Item with the %s Tag:', tagCount), tagName) .. '\n'

    for _, item in pairs(itemList) do
        text = text .. icon_frame(item, item, nil, '<h3>[[' .. item .. ']]</h3>', expensive)
    end

    return text
end

return p