Difference between revisions of "Module:Events"
From Blaseball Wiki
(Created page with "local p = {} local cargo = mw.ext.cargo local seasons = 17 function p.incinerations( frame ) local output = {} local tables = 'IncinerationEvents,Players=Players1,Pl...") |
|||
Line 7: | Line 7: | ||
local output = {} | local output = {} | ||
local tables = 'IncinerationEvents,Players=Players1,Players=Players2,Teams' | local tables = 'IncinerationEvents,Players=Players1,Players=Players2,Teams' | ||
− | local fields = [=[ | + | local fields = [=[ |
Day=sort, | Day=sort, | ||
IF(game IS NOT NULL, | IF(game IS NOT NULL, | ||
Line 29: | Line 29: | ||
table.insert(output, '{{Table|{{TableHeader|Day|Player|Replaced by|Team}}') | table.insert(output, '{{Table|{{TableHeader|Day|Player|Replaced by|Team}}') | ||
for r = 1, #results do | for r = 1, #results do | ||
− | local row = { | + | result = results[r] |
+ | local row = { result['day'], result['out_player'], result['in_player'], result['team'] } | ||
table.insert(output, '|-\n|' .. table.concat(row, '||')) | table.insert(output, '|-\n|' .. table.concat(row, '||')) | ||
end | end |
Revision as of 18:32, 4 May 2021
This module generates tables of game events per season.
{{#invoke:Events|<type>}}
- Output tables for all seasons with an <h3>
header for each
{{#invoke:Events|<type>|<season>}}
- Output table for a single season with no header, or output nothing if there are no events for the given season
<type>
can be incinerations
, feedback
, or shuffle
.
local p = {}
local cargo = mw.ext.cargo
local seasons = 17
function p.incinerations( frame )
local output = {}
local tables = 'IncinerationEvents,Players=Players1,Players=Players2,Teams'
local fields = [=[
Day=sort,
IF(game IS NOT NULL,
CONCAT('[https://reblase.sibr.dev/game/', Game, ' ', Day, ']'),
IF(Day IS NULL, 'EL', Day)
)=day,
CONCAT('[[', Players1.Name, ']]')=out_player,
CONCAT('[[', Players2.Name, ']]')=in_player,
CONCAT('[[', Teams.Name, ']]')=team
]=]
for i = 1, seasons do
table.insert(output, '===Season ' .. i .. '===')
local args = {
where = 'Season = ' .. i,
join = 'IncinerationEvents.OutPlayer=Players1.UUID,IncinerationEvents.InPlayer=Players2.UUID,IncinerationEvents.Team=Teams.UUID',
orderBy = 'day',
}
local results = cargo.query( tables, fields, args )
if results then
table.insert(output, '{{Table|{{TableHeader|Day|Player|Replaced by|Team}}')
for r = 1, #results do
result = results[r]
local row = { result['day'], result['out_player'], result['in_player'], result['team'] }
table.insert(output, '|-\n|' .. table.concat(row, '||'))
end
table.insert(output, '}}')
else
table.insert(output, 'None')
end
end
return table.concat(output, '\n')
end
return p