◆少前百科是非盈利性、非官方的少女前线维基百科。
◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科
◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科
◆To foreigners,You can use twitter to contact us.
Icon Nyto Silver.png

“模块:Gun info/time”的版本间的差异

来自少前百科GFwiki
跳转至: 导航搜索
(创建页面,内容为“local p = {} local data = {} local timeList = {} local function formatTime(seconds) local minutes = math.floor(seconds/60) local hour = math.floor(minutes/60) mi…”)
 
第23行: 第23行:
 
local tr = root:tag('tr')
 
local tr = root:tag('tr')
 
tr:tag('td'):wikitext(formatTime(seconds))
 
tr:tag('td'):wikitext(formatTime(seconds))
tr:tag('td'):wikitext()
 
 
table.sort(data[seconds], sortById)
 
table.sort(data[seconds], sortById)
 
local links = {}
 
local links = {}

2024年5月11日 (六) 01:44的版本

此模块的文档可以在模块:Gun info/time/doc创建

local p = {}
local data = {}
local timeList = {}

local function formatTime(seconds)
	local minutes = math.floor(seconds/60)
	local hour = math.floor(minutes/60)
	minutes = minutes - hour*60
	return string.format('%02d:%02d:00', hour, minutes)
end

local function sortById(a, b)
	return a.id < b.id
end

local function list()
	local root = mw.html.create('table'):addClass('wikitable sortable filterable')
	local thead = root:tag('tr')
	thead:tag('th'):addClass('filterable-head'):wikitext('建造时间')
	thead:tag('th'):wikitext('战术人形')
	thead:tag('th'):wikitext('备注')
	for _, seconds in ipairs(timeList) do
		local tr = root:tag('tr')
		tr:tag('td'):wikitext(formatTime(seconds))
		table.sort(data[seconds], sortById)
		local links = {}
		local isHeavyOnly = false
		for _, row in ipairs(data[seconds]) do
			table.insert(links, '[[' .. row.name .. ']]')
			if row.obtain[0] == 2 then
				isHeavyOnly = true
			end
		end
		tr:tag('td'):wikitext(table.concat(links, '/'))
		tr:tag('td'):wikitext(isHeavyOnly and '重型制造限定' or '')
	end
	return tostring(root)
end

local function filterManufacturable()
	for i = 0, 4 do
		local dataN = mw.loadData('Module:Gun info/data ' .. tostring(i))
		for id, row in pairs(dataN) do
			if row.obtain[1] == 1 or row.obtain[1] == 2 then
				if data[row.produce_time] == nil then
					data[row.produce_time] = {}
					table.insert(timeList, row.produce_time)
				end
				table.insert(data[row.produce_time], row)
			end
		end
	end
end

function p.list()
	filterManufacturable()
	table.sort(timeList)
	return list()
end
return p