The VNDev Wiki underwent maintenance on March 14th, 2025, which is now complete. Semantic MediaWiki and associated extensions have been updated, and Scribunto and Semantic Scribunto have been installed. If you encounter any bugs or unexpected behavior, especially with VN jam statistics pages, please let the wiki admins know via the DevTalk Discord server.
Module:Jam series detailed stats: Difference between revisions
From VNDev Wiki
okay, let's try the custom version |
m protect against nils |
||
Line 56: | Line 56: | ||
for i=1,#groups do | for i=1,#groups do | ||
local subQ = { '[[Jam occurrence:+]]', '[[Has ' .. statType .. '::>' .. groups[i][1] .. ']]', '[[Has ' .. statType .. '::<' .. groups[i][2] ..']]' } | if groups[i] ~= nil then | ||
local subQ = { '[[Jam occurrence:+]]', '[[Has ' .. statType .. '::>' .. groups[i][1] .. ']]', '[[Has ' .. statType .. '::<' .. groups[i][2] ..']]' } | |||
subQ.format = 'count' | |||
local resultI = mw.smw.subobject ( { 'Has sort order=' .. i, 'Has label=' .. groups[i][1] .. '-' .. groups[i][2], 'Has count=' .. mw.smw.ask( subQ ) } ) | |||
if resultI ~= true then resultFinal = false end | |||
end | |||
end | end | ||
Revision as of 14:22, 16 March 2025
Documentation for this module may be created at Module:Jam series detailed stats/doc
local p = {}
function p.prepHistData( frame )
local statType = frame.args['statType']
local width = frame.args['width']
local q = { '[[Jam occurrence:+]]', '?Has ' .. statType .. '=count' }
q.sort = 'Has ' .. statType
q.order = 'descending'
q.limit = 1
q.mainheader = '-'
local maxCount = mw.smw.ask( q )
local numIntervals = math.ceil( maxCount[1].count / width )
local zeroSubQ = { '[[Jam occurrence:+]]', '[[Has ' .. statType .. '::0]]' }
zeroSubQ.format = 'count'
local zeroCount = mw.smw.ask( zeroSubQ )
local zeroCol = { 'Has sort order=0', 'Has label=None', 'Has count=' .. mw.smw.ask( zeroSubQ ) }
local resultZero = mw.smw.subobject( zeroCol )
local resultFinal = false
if resultZero == true then resultFinal = true end
for i=1,numIntervals do
local subQ = { '[[Jam occurrence:+]]', '[[Has ' .. statType .. '::>' .. (width * (i-1)) + 1 .. ']]', '[[Has ' .. statType .. '::<' .. width * i ..']]' }
subQ.format = 'count'
local resultI = mw.smw.subobject ( { 'Has sort order=' .. i, 'Has label=' .. (width * (i-1)) + 1 .. '-' .. width * i, 'Has count=' .. mw.smw.ask( subQ ) } )
if resultI ~= true then resultFinal = false end
end
return resultFinal
end
function p.prepHistDataCustom( frame )
local statType = frame.args['statType']
local groups = {}
for i,arg in pairs( frame.args ) do
if i ~=1 then
table.insert(groups, mw.text.split(arg, '-', true ) )
end
end
local zeroSubQ = { '[[Jam occurrence:+]]', '[[Has ' .. statType .. '::0]]' }
zeroSubQ.format = 'count'
local zeroCount = mw.smw.ask( zeroSubQ )
local zeroCol = { 'Has sort order=0', 'Has label=None', 'Has count=' .. mw.smw.ask( zeroSubQ ) }
local resultZero = mw.smw.subobject( zeroCol )
local resultFinal = false
if resultZero == true then resultFinal = true end
for i=1,#groups do
if groups[i] ~= nil then
local subQ = { '[[Jam occurrence:+]]', '[[Has ' .. statType .. '::>' .. groups[i][1] .. ']]', '[[Has ' .. statType .. '::<' .. groups[i][2] ..']]' }
subQ.format = 'count'
local resultI = mw.smw.subobject ( { 'Has sort order=' .. i, 'Has label=' .. groups[i][1] .. '-' .. groups[i][2], 'Has count=' .. mw.smw.ask( subQ ) } )
if resultI ~= true then resultFinal = false end
end
end
return resultFinal
end
return p