I'm sure other people will have better/more efficient ways to do this, but here's what worked for me: First, you have to bring your new markers into your game. That would be through the Token Marker Sets option on the bottom-right side of the main page for your campaign. Once they're in your game (and give them some time -- Roll20 is weirdly slow allowing those markers to show up), install the libTokenMarkers script from the one-click. Then paste in the find token markers code as a separate script and restart your API: on("ready", () => {
const tokenMarkers = JSON.parse(Campaign().get("token_markers"));
const getChatMessageFromTokenMarkers = markers => {
let chatMessage = '';
_.each(markers, marker => {
chatMessage += `<p><img src='${marker.url}'> ${marker.id}: ${marker.name}</p>`;
});
return chatMessage;
};
on("chat:message", msg => {
if(msg.content.split(" ")[0].toLowerCase() === '!markernames') {
let chatMessage = getChatMessageFromTokenMarkers(tokenMarkers);
sendChat("Token Markers", chatMessage);
} else if(msg.content.split(" ")[0].toLowerCase() === '!markerids') {
const markerName = msg.content.split(" ")[1].toLowerCase();
let results = [];
_.each(tokenMarkers, marker => {
if(marker.name.toLowerCase() === markerName) results.push(marker);
});
log(results);
let chatMessage = getChatMessageFromTokenMarkers(results);
chatMessage = chatMessage || 'Unable to find any matching token markers'
sendChat("Token Markers", chatMessage);
} else if(msg.content.split(" ")[0].toLowerCase() === '!settokenmarker') {
const markerName = msg.content.split(" ")[1].toLowerCase();
if (!msg.selected && msg.selected[0]._type == "graphic") return;
obj = getObj(msg.selected[0]._type, msg.selected[0]._id);
currentMarkers = obj.get("statusmarkers").split(',');
currentMarkers.push(markerName);
obj.set("statusmarkers", currentMarkers.join(','));
} else if(msg.content.split(" ")[0].toLowerCase() === '!gettokenmarkers') {
if (!msg.selected) return;
if (msg.selected[0]._type !== "graphic") return;
obj = getObj(msg.selected[0]._type, msg.selected[0]._id);
currentMarkers = obj.get("statusmarkers");
sendChat("Token Markers", currentMarkers);
}
});
});
Load your game and run the !markernames command. It should spit out a list of all your token marks with image, name, and id. Copy the ID of the marker you want into the DeathTracker script, relatively near the top: markers = ['none', 'blue', 'brown', 'green', 'pink', 'purple', 'red', 'yellow', '-', 'KnockedOut::1173545', 'StatusBlood::1172799'],