
Hello everyone,
I've been looking for a way to automatically add a token to the object layer for a cleric player in my party so I'm not having to copy/paste the token we use from another page or creating a new one and having to take the time to edit all of the fields properly. (This has consumed a lot of time already)
I found a very old (6 years old) script by Brandon W. that seems to still work, but I can't manage to set the imgsrc field properly. If anyone can offer assistance I would be highly appreciative.
on("chat:message", function(msg) {
if(msg.type == "api" && msg.content.indexOf("!summon") !== -1) {
var selected = msg.selected;
_.each(selected, function(obj) {
var tok = getObj("graphic", obj._id);
var slice = msg.content.split(" ");
/* commented out because it's not necessary
var augmented = 0;
if (slice[2] != undefined) {
if (slice[2].toLowerCase() == "augment") {
augmented = 1;
}
}
*/
if (slice[1].toLowerCase() == 'sw') {
createObj("graphic", {
name: "Spiritual Weapon",
controlledby: "player name", //player name is not what I actually use.
left: tok.get("left")+70,
top: tok.get("top"),
width: 70,
height: 70,
//bar1_value: 73 + (augmented * 14), commented out from original script because it's not necessary
//bar1_max: 73 + (augmented * 14),
showname: true,
showplayers_name: true,
showplayers_bar1: true,
imgsrc: "player token.png", //this is the name of a generic token that my players know is theirs and not an enemy's/NPC's.
pageid: tok.get("pageid"),
layer: "objects"
});
}
});
}
});