Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Blood and Honor API Script

I did some googling from a list of "must have" API scripts that I saw in the forums and came across the Blood and Honor script that I thought was pretty cool. I've been fiddling around with it, and got it to work for a few minutes (changing it read from bar 1 etc), but it spit out random map tiles that I'd accidentally uploaded into the script. I had a look at the image URLs, but I'm having trouble working out how to get the URLs from the chrome developer tools. There only seems to be 1 item in the list of the prerequisite URL form, and it changes when I hover over the uploaded images in the side bar. Am I supposed to use these in the script? Because I thought that I'd done this, but now its not throwing up any images when the script runs (or its not running!). If you have any ideas, please let me know.
1534965100

Edited 1534965130
The Aaron
Pro
API Scripter
The easiest way to do this is to drop the image on the table top, then click the graphic, hit the 'Z' key to zoom the image, then right click the zoomed version and copy the URL. You'll need to be sure these are in a User Library (likely yours).  You'll also need to make sure the URL refers to the thumb version. You can also use this script, by selecting the graphics and running this command: !user-image This will print out the right URLs for each user library images.  If you don't see the image and url show up, it means it's not in a user library. Script: on('ready',function(){ 'use strict'; var getCleanImgsrc = function (imgsrc) { var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|original|max)(.*)$/); if(parts) { return parts[1]+'thumb'+parts[3]; } return; }; on('chat:message',function(msg){ if('api' === msg.type && msg.content.match(/^!user-image/) && playerIsGM(msg.playerid) ){ let who=getObj('player',msg.playerid).get('_displayname'), output = _.chain(msg.selected) .map( s => getObj('graphic',s._id)) .reject(_.isUndefined) .map( o => o.get('imgsrc') ) .map( getCleanImgsrc ) .reject(_.isUndefined) .map(u => `<div><img src="${u}" style="max-width: 3em;max-height: 3em;border:1px solid #333; background-color: #999; border-radius: .2em;"><code>${u}</code></div>`) .value() .join('') || `<span style="color: #aa3333; font-weight:bold;">No selected tokens have images in a user library.</span>` ; sendChat('UserImage',`/w "${who}" <div>${output}</div>`); } }); });
Thanks. I'll give it a go