Модуль:Exclusive/data

Материал из Terraria Wiki
Перейти к: навигация, поиск

Для документации этого модуля может быть создана страница Модуль:Exclusive/data/doc

-- create data cache from cargo 
-- The cached version is not much faster then query directly, but its running speed varies in a much smaller range, avoid accidental timeout.
local cargo = mw.ext.cargo
local result = mw.ext.cargo.query('Exclusive', 'pagename, desktop, console, oldgen, mobile, 3ds, japanese', {
	orderBy = "cached DESC",
	groupBy = "pagenamemd5",  -- group by is case insensitive, so use group by pagenamemd5 instead of group by pagename.
	limit = 5000, -- may be not enough in future.
})
local info = {}
for _, row in ipairs(result) do
	-- all are strings
	local str = 
		((row['desktop'] ~= '')  and 'd' or '') ..
		((row['console'] ~= '')  and 'c' or '') ..
		((row['oldgen'] ~= '')   and 'o' or '') ..
		((row['mobile'] ~= '')   and 'm' or '') ..
		((row['3ds'] ~= '')      and '3' or '') ..
		((row['japanese'] ~= '') and 'j' or '')
	if str ~= 'dcom3' and str ~= 'dcom3j' and str ~= '' then
		info[row['pagename']] = str
	end
end
return info