Difference between revisions of "Module:Events"
From Blaseball Wiki
Line 27: | Line 27: | ||
local results = cargo.query( tables, fields, args ) | local results = cargo.query( tables, fields, args ) | ||
if #results > 0 then | if #results > 0 then | ||
− | table.insert(output, '{ | + | table.insert(output, '{| class="wikitable"\n!Day!!Player!!Replaced by!!Team') |
for r = 1, #results do | for r = 1, #results do | ||
result = results[r] | result = results[r] | ||
local row = { result['day'], result['out_player'], result['in_player'], result['team'] } | local row = { result['day'], result['out_player'], result['in_player'], result['team'] } | ||
− | table.insert(output, ' | + | table.insert(output, '|-\n|' .. table.concat(row, '||')) |
end | end | ||
− | table.insert(output, ' | + | table.insert(output, '|}') |
else | else | ||
table.insert(output, 'None') | table.insert(output, 'None') |
Revision as of 18:41, 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 > 0 then
table.insert(output, '{| class="wikitable"\n!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