模块:Collection

来自乐园数据管理室
ヒカリ​(留言 | 贡献)2018年12月14日 (五) 16:40的版本

此模块的文档可以在模块:Collection/doc创建

local p = {}
local getArgs = require("Module:Arguments").getArgs

function p.test()
  return mw.title.getCurrentTitle()
end

function p.popList(frame)
  local title = mw.title.getCurrentTitle()
  local result =
    mw.smw.ask {
    "[[采集地域::" .. tostring(title) .. "]]",
    "?单次采集数量",
    "?采集道具1",
    "?采集概率1",
    "?采集道具2",
    "?采集概率2",
    "?采集道具3",
    "?采集概率3",
    "?采集道具4",
    "?采集概率4",
    "limit=200",
    "sort=CollectionTableId"
  }

  local body = ""
  for i, v in ipairs(result) do
    local page = mw.ustring.gsub(v[1], "|.+/", "|")
    body =
      body ..
      mw.ustring.format(
        [[|-
          | %s || %s || %s || %s || %s || %s || %s || %s || %s || %s
          ]],
        page,
        v["单次采集数量"],
        v["采集道具1"] or "",
        v["采集概率1"] or "",
        v["采集道具2"] or "",
        v["采集概率2"] or "",
        v["采集道具3"] or "",
        v["采集概率3"] or "",
        v["采集道具4"] or "",
        v["采集概率4"] or ""
      )
  end

  return [[{| class="wikitable sortable"
  |-
  ! 采集点类型 !! 数量 !! 道具 !! 概率 !! 道具 !! 概率 !! 道具 !! 概率 !! 道具 !! 概率
  ]] ..
    body .. [[
  |}]]
end

return p