So, I've been working away at ideas on how I could move forward with my campaign building... I thought I would just manually type out all of the macros using PowerCards and attach them to handouts. I quickly learned making tons of handouts is a huge pain (no duplicate or copy options it seems)! I'm not sure if anyone else has made something similar all ready, but I scrapped together a "Handout Creator" script to aid in this: // Look for a pre-made Handout called 'Handout Importer'
// Inside the Notes section of this Handout, have a list of new Handout names to be created,
// with each new name on the next line... ie:
// HandoutName1
// HandoutName2
// HandoutName3
// etc...
// Once the Handout Importer handout has been created,
// type !handout in the chat to generate all of the new handouts.
on("chat:message", function(msg) {
// listen for the !handout chat call
if (msg.type === "api" && msg.content.indexOf("!handout") !== -1){
// find the handout named 'Handout Importer'
var handoutImports = findObjs({
_type: "handout",
name: "Handout Importer"
});
if (handoutImports.length !== 1 || typeof(handoutImports[0]) === "undefined"){
sendChat("Failed to locate import handout! No handout named Handout Importer exists (Or more than one handout matching this name was found).");
return;
}
handoutImports = handoutImports[0];
// Retrieve the text from the Notes section of Handout Importer
handoutImports.get("notes", function(text){
// Create a new entry for each new line <br>
var lines = text.split("<br>");
for(var i=0;i<lines.length;i++){
//Create a new Handout available to all players
var handout = createObj("handout", {
name: lines[i],
inplayerjournals: "all",
archived: false
});
}
});
}
}); Here's an example of it in use ( animated gif): Once I had all of my handouts made with permissions set for All Player's, I used some home-made card graphics I had uploaded and manually attached them all. It wasn't so bad once I realized I could just left-click to open all 100+ handouts and THEN go to my Art Library tab to more easily search and drag my images onto the Handouts. Then I was thinking I could use the Handouts themselves as a sort of visual database, and use the Info section to place the PowerCards macro text.This would allow a player or myself to fairly quickly copy/paste that code and make the macro manually. I have done a hard-coded test that looks at the Info section of a Handout and it creates and attaches a PowerCards Ability macro to a targeted character token. This seems to work... mostly. The macro code being put into the ability seems to have some strange initial formatting issue, causing the PowerCard macro output to be a bit off (no avatar, weird spacing and breaks). The moment I manually open the Ability macro for editing in the character sheet, change nothing, but hit ok the Ability macro becomes fine. It's even worse if I have the text formatted as Code in the Handout info section. I'm guessing it has something to do with formatting and it could be stripped out more cleanly before creating the Ability macro? Example ( animated gif) : Here's the really bad code from my DrawCard test: on("chat:message", function(msg) {
// listen for the !handout chat call
if (msg.type === "api" && msg.content.indexOf("!drawcard") !== -1){
// get the character
var charid = msg.content.split(' ')[1];
var c = getObj('character',charid);
// get the passed in name
var cardName = msg.content.split(' ')[2];
if(c) {
// Find the Card
var cardLookup = findObjs({
_type: "handout",
name: "Animatronic Toy"
});
cardLookup = cardLookup[0];
cardLookup.get("notes", function(text){
// Create the Ability
var cardAbility = createObj("ability", {
name: cardLookup.get("name"),
action: text,
istokenaction: true,
characterid: c.get("_id")
});
});
}
}
}); What I ultimately want is to have a macro that will randomly or manually draw a "power" or "card" - in this case I'm using PowerCards macros as character powers, traits, actual game cards, etc. I will eventually be using the internal URLs of the Handouts to make the PowerCards name text link to the Handout, as well. Now I'm curious if there would be a clean way to have my DrawCard API script look at something like a Card Deck or a Rollable Table's entire contents (all with a list of names matching the previously created handouts - something I would generate or make), and have that give me a pull-down menu for the ability to manually assign cards or powers to a token/sheet? I'd like the functionality to be somewhat similar to this (even though this is just a huge blob of PowerCard macros in one single call). animated gif: Essentially, I would be able to call my API function and pass in a flag for random or manual assignment - randomly draw a card or power (like from a Deck), or manually pick and assign them as I please.