
This script was superseded by Campaign Survey.
Lister is a scriptlet that looks through your campaign and lists characters, handouts, pages, rollable tables and players. I created it for some administrative accounting reasons, but thought I would share. No guarantees this won't break. :)
Syntax:
!makelist --[characters,handouts,pages,tables,players,makehandout]
You can use multiple arguments, separated by spaces, ex: !makelist --characters handouts
In the case of characters, handouts, and tables the list is in the form of links. If you click on a character or handout name, it will open the journal item. If you click on a table, it will roll the table.
In the case of players, it will give you a list of players and their playerids, which can be a few steps to find otherwise. If you click on the name, this will take you to the profile page of the player as an external link. This can be useful if you need to send them an out-of-game PM, for instance. If you click on the color box next to the player name, it will issue a reporter macro to give you a list of all characters in the campaign that the player controls. (It does not account for "all players" or multiple controllers. the player must be the first controller listed on the character)
makehandout updates a handout called "Lister Report" and sends the output there instead of to chat. If no handout exists by that name it will create one. If you by some bizarre chance have a handout called "Lister Report", this script will overwrite the contents.
Handout screenshot:
Player screenshot:
Clicking on player color (if you have installed Reporter—otherwise nothing will happen)
Code:
on('chat:message', (msg_orig) => {
let msg = _.clone(msg_orig);
if (!/^!makelist/.test(msg.content)) {
return;
}
function makeButton(name, link) {
return '<a style = ' + buttonStyle + ' href="' + link + '">' + name + '</a>';
}
function reporterMacro(id) {
return '<a style = ' + buttonStyle + ' href="' + link + '">' + name + '</a>';
}
function makeBox(color, id, name) {
return `<a href = '!report||+|c|controlledby|${id} -- --- ----compact|true showheader|false showfooter|false title|Characters of ${name}|' style= 'float: left; height: 30px; width: 10px; margin-top: 2px; margin-right: 2px; background-color:${color}; border: 1px solid black; clear: both;'</a>`;
}
function makeTableLink(name) {
log('name is ' + name);
return `<a href = '! /gmroll 1t[${name}]'>${name}</a>`;
}
const closeReport = '</div>';
const openReport = "<div style='color: #000; border: 1px solid #000; background-color: #fff; box-shadow: 0 0 3px #000; display: block; text-align: left; font-size: 13px; padding: 5px; margin-bottom: 0.25em; font-family: sans-serif; white-space: pre-wrap;'>";
const openHeader = "<div style='font-weight:bold; color:#fff; background-color:#404040; margin-right:3px; padding:3px;'>"
const closeHeader = '</div>';
const buttonStyle = "'background-color: transparent;padding: 0px;color: #ce0f69;display: inline-block;border: none; !important'";
if (!msg.content.includes('--') && playerIsGM(msg.playerid)) {
sendChat('Lister', `${openReport}The !makelist command must be followed by " --" and one or more of the following keywords<br>characters<br>handouts<br>pages<br>tables${closeReport}`, null, {
noarchive: true
});
return;
}
let lines = '';
let sheetURL = 'http://journal.roll20.net/character/';
let handoutURL = 'http://journal.roll20.net/handout/';
let profileURL = 'https://app.roll20.net/users/';
let tableURL = `! /roll 1t[`;
let characters = findObjs({
type: 'character'
});
let handouts = findObjs({
type: 'handout'
});
let pages = findObjs({
type: 'page'
});
let tables = findObjs({
type: 'rollabletable'
});
let players = findObjs({
type: 'player'
});
let characterList = '';
let handoutList = '';
let pageList = '';
let tableList = '';
let playerList = '';
let args = msg.content.split(/\s--/);
let commands = args[1].split(/\s+/);
log('commands = ' + commands);
commands.forEach(c => {
switch (c) {
case 'characters':
characterList = (characterList === '') ? `${openHeader}Characters:${closeHeader}${characters.map((obj)=>{return makeButton(obj.get('name'),sheetURL + obj.get('_id'))}).join('<br>')}<br>` : '';
lines = lines + characterList;
break;
case 'handouts':
handoutList = (handoutList === '') ? `${openHeader}Handouts:${closeHeader}${handouts.map((obj)=>{return makeButton(obj.get('name'),handoutURL + obj.get('_id'))}).join('<br>')}<br>` : '';
//handoutList = (handoutList === '') ? `${openHeader}Handouts:${closeHeader}${handouts.map((obj)=>{return '[' + obj.get('name')+']('+handoutURL + obj.get('_id')+')'}).join('<br>')}<br>` : '';
lines = lines + handoutList;
break;
case 'pages':
pageList = (pageList === '') ? `${openHeader}Pages:${closeHeader}${pages.map((obj)=>{return obj.get('name')}).join('<br>')}<br>` : '';
lines = lines + pageList;
break;
case 'tables':
tableList = (tableList === '') ? `${openHeader}Rollable Tables:${closeHeader}${tables.map((obj)=>{return makeTableLink(obj.get('name'))}).join('<br>')}<br>` : '';
lines = lines + tableList;
break;
case 'players':
//playerList = (playerList === '') ? `Players:<br>${players.map((obj)=>{return obj.get('_displayname')+'<BR>id: '+obj.get('_id')}).join('<br>')}<br>` : '';
playerList = (playerList === '') ? `${openHeader}Players:${closeHeader}${players.map((obj)=>{return makeBox(obj.get('color'),obj.get('_id'),obj.get('_displayname')) + makeButton(obj.get('_displayname'),profileURL + obj.get('_d20userid'))+'<br>id: '+(obj.get('_id'))}).join('<br>')}<br>` : '';
lines = lines + playerList;
break;
default:
}
});
if (lines) {
if (commands.includes('makehandout')) {
let reportHandout = findObjs({
type: 'handout',
name: 'Lister Report'
});
reportHandout = reportHandout ? reportHandout[0] : undefined;
if (!reportHandout) {
reportHandout = createObj('handout', {
name: 'Lister Report',
archived: false
});
let reportHandoutid = reportHandout.get("_id");
sendChat('Lister', '/w gm ' + openReport + `Reporter has created a handout named <b>Lister Report</b>. <BR>Click <a href="http://journal.roll20.net/handout/${reportHandoutid}">here</a> to open.` + closeReport, null, {
noarchive: true
});
}
if (reportHandout) {
if (reportHandout) {
reportHandout.get("notes", function(notes) {
reportHandout.set("notes", lines)
});
}
} else {
sendChat('Lister', '/w gm ' + openReport + `No handout named Makelist Report was found.` + closeReport, null, {
noarchive: true
});
}
} else {
sendChat("Lister", `/w gm ${openReport}${lines}${closeReport}`, null, {
noarchive: true
});
}
}
});