Module:Video game wikidata: Difference between revisions

Content deleted Content added
Repair script error when module runs on a page without a Wikidata item (i.e. talk pages)
Implementing MOS RFC.
 
(13 intermediate revisions by 4 users not shown)
Line 45:
[184839] = 'N64',
[182172] = 'GC', -- Sometimes has been NGC
[19610114] = 'NS', -- Nintendo Switch
[98973368] = 'XSX/S', -- Xbox Series X and Series S (Output label differs from the input parameter, XSXS, per RFC)
[63184502] = 'PS5'
}
 
Line 76 ⟶ 79:
['GC'] = 182172,
['NGC'] = 182172,
['NS'] = 19610114,
['XSXS'] = 98973368, -- This is the template parameter, which cannot contain a / or | character.
['PS5'] = 63184502
}
 
Line 81 ⟶ 87:
local aggregatorAliases = {
[150248] = 'MC',
[40160] = 'GR',
[21039459] = 'OC'
}
 
Line 87 ⟶ 94:
local aggregatorIDs = {
['MC'] = 150248,
['GR'] = 40160,
['OC'] = 21039459
}
 
Line 103 ⟶ 111:
 
local function sortByPlatform(a,b)
local platformA = nil"";
local platformB = nil"";
if(a['qualifiers']['P400'] ~= nil and ba['qualifiers']['P400'][1] ~= nil) then
platformA = p.getSystemAlias(a['qualifiers']['P400'][1]['datavalue']['value']['numeric-id']);
if(platformA == nil) then
Line 261 ⟶ 269:
 
if(reviewscore['references'] ~= nil and reviewscore['references'][1] ~= nil and genRefs) then
local cite = buildCite(reviewscore['references'][1], df);
if(cite ~= nil) then
Line 348 ⟶ 356:
-- Check for a game parameter. If missing, default to current article.
if(iGame ~= nil and iGame ~= "") then
if(entities[iGame] == nil and mw.wikibase ~= nil) then
entities[iGame] = mw.wikibase.getEntity(iGame);
end;
Line 355 ⟶ 363:
else
-- Need to research if we can determine the entity's ID before retrieving it.
entity = if(mw.wikibase.getEntity( ~= nil); then
if( entity ~= nilmw.wikibase.getEntity() then;
entities[if(entity['id']] ~= entity;nil) then
entities[entity['id']] = entity;
end;
end;
end;
Line 409 ⟶ 419:
elseif(updateLinkStyle == "noSub") then
return '[[d:'..entity['id']..'#P444|[±]]]';
elseif(updateLinkStyle == "text and pen") then
return '<span style="position: relative;"><span style="position: absolute; right: 0;">[[File:Blue pencil.svg|10px|baseline|link=|alt=]]</span>[[d:'..entity['id']..'#P444|<span style="position: relative; padding-right: 14px;">Edit on Wikidata</span>]]</span>'
end;
Line 442 ⟶ 454:
if(pubDates) then
for i,pubDate in pairs(pubDates) do
if(pubDate['mainsnak']['datavalue']) then
local timestamp = pubDate['mainsnak']['datavalue']['value']['time'];
local accessdate = Date(timestamp);
table.insert(ret,accessdate);
end;
end;
end;
Line 466 ⟶ 480:
local reviewsToPrint = {}
for i,review in pairs(reviewscores) do
local scoreByif(review['qualifiers'] ~= nil) then
local scoreBy = nil
if(review['qualifiers']['P447'] ~= nil and review['qualifiers']['P447'][1] ~= nil) then
scoreBy = review['qualifiers']['P447'][1]['datavalue']['value']['numeric-id'];
end;
if(scoreBy == reviewer) then
-- If template specified a system, we need to check for the specific system and only output that one.
if(system == nil or system == "") then
-- No system specified, so output each one found.
table.insert(reviewsToPrint,review);
else
-- Get platform if it exists.
if(review['qualifiers']['P400'] ~= nil and review['qualifiers']['P400'][1] ~= nil) then
-- Try to match based on QID.
local reviewSysId = review['qualifiers']['P400'][1]['datavalue']['value']['numeric-id'];
if(systemId == reviewSysId) then
table.insert(reviewsToPrint,review);
else
-- If that failed, try to match based on label.
local systemName = mw.wikibase.label('Q'..reviewSysId);
if(systemName ~= nil and string.upper(systemName) == system) then
table.insert(reviewsToPrint,review);
else
-- If that failed, try to match based on label.
local systemName = mw.wikibase.label('Q'..reviewSysId);
if(systemName ~= nil and string.upper(systemName) == system) then
table.insert(reviewsToPrint,review);
end;
end;
end;