I'm trying to create a script that will cycle through the PCs and whisper an item from a table to them. This is what I have pieced together from bits in the forum that is supposed to identified the character names of the selected tokens, but I get a function not defined error. // ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level SIMPLE_OPTIMIZATIONS
// @formatting pretty_print
// ==/ClosureCompiler==
/**
* Generates Nightmares for WWC
*
* Syntax: !dreams option
*
* option TBD
*/
var dreams = dreams || {
output: [],
listen: function () {
on('chat:message', function (msg) {
// Exit if not an api command
if (msg.type != "api") {
return;
}
// if (msg.content.indexOf("!dreams ") != -1) {
// var input = msg.content.split(" ");
// if (input[1] == "help") {
// dreams.showHelp();
// } else {
dreams.generate(msg, dreams.printSheet);
// }
// } else if (msg.content.indexOf("!dreams") != -1) {
// dreams.showHelp();
// }
});
},
// showHelp: function () {
// sendChat("API", "/direct <table style='background: #DCD9D5; border-radius: 20px; font-size: 10px;'>" +
// "<thead><tr><th>Help</th></tr></thead>" +
// "<tbody>" +
// "<tr><td><strong>!dreams</strong><br><strong>!dreams help</strong><br>Show this help screen.</td></tr>" +
// "<tr><td> </td></tr>" +
// "</td></tr></tbody></table>");
// },
getNamesFromTokens: function (msg, outputCallback, saveCallback) {
return (selected || []).map(obj => getObj("graphic", obj._id))
.filter(x => !!x)
.map(token => token.get("represents"))
.filter(name => getObj("character", name || ""));
},
generate: function (msg, outputCallback, saveCallback) {
dreams.id = msg.playerid;
dreams.player = msg.who;
let charid = getNamesFromTokens(option)[0];
char = findObjs({
_type: 'character',
_id: charid
})[0];
// dreams.name = msg.who + " #" + (findObjs({
// type: "character",
// controlledby: msg.playerid
// }).length + 1)
dreams.rollDream();
if (typeof outputCallback === "function") {
setTimeout(outputCallback, 2500, msg, saveCallback);
}
},
printSheet: function (msg, saveCallback) {
var styleLabel = "style='font-weight: bold; padding: 5px;'";
var styleVal = "style='padding: 5px;'";
if (typeof dreams.Type != 'undefined') {
dreams.rollNPC();
}
dreams.output['Title'] = "<thead><tr><th colspan='2' style='background: #8C8173; padding: 5px;'>" + dreams.Title + "</th></tr></thead>";
dreams.output['Text'] = "<tr><td style='padding: 5px;'>" + dreams.Text + "</td></tr>";
sendChat(msg.who, "/w gm <table style='background: #DCD9D5; border-radius: 20px; font-size: 10px;'>" + dreams.output['name'] +
"<tbody>" +
dreams.output['Title'] +
dreams.output['Text'] +
"</tbody></table>");
if (typeof saveCallback === "function") {
saveCallback();
}
}
}
on("ready", function () {
dreams.listen();
});
Any suggestions?