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

Token Placer Script - How to find imgsrc?

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" }); } });   } });
1576942881
GiGs
Pro
Sheet Author
API Scripter
For imgsrc you need to use the full internet address of the image. As described here, it will look something like '<a href="https://s3.amazonaws.com/files.staging.d20.io/images/123456/thumb.png?12345678" rel="nofollow">https://s3.amazonaws.com/files.staging.d20.io/images/123456/thumb.png?12345678</a>' You can get the address of a token image using a script Aaron wrote ages ago here:&nbsp; <a href="https://app.roll20.net/forum/permalink/4462334/" rel="nofollow">https://app.roll20.net/forum/permalink/4462334/</a>
Thank you! That got it to work (almost). The reason I say "almost" is because control over that token is rather... odd. I, the GM, can move the token but cannot edit any of its attributes, even if I put myself in the "controlledby" line. Why is that? Is it because the token was generated by a script, or are there things that are still incorrect? Do I need to go by player ID instead of names for the "controlledby" field? (I might be able to find those on my own and will try that before checking back. My next session is starting soon and this script is highly unlikely to be ready before it begins.)
1576998718
GiGs
Pro
Sheet Author
API Scripter
Honestly, I don't really understand whats going on. As gm, you should be able to edit all properties of a token regardless of who is set in controlledby. When you say you cant edit the token's attributes - please list one or more of the attributes you have attempted to change that hasnt worked. I need to know we are using the same terminology. Can you also post a screenshot of the created token's settings?
1577020688
The Aaron
Roll20 Production Team
API Scripter
Controlledby is a comma delimited string containing player ids, not names.&nbsp; In our games, we create characters for spell effects (with a correctly set up token) and assign them to all players, then the player drags out the spell effect token when they cast it. That might be easier for you, and it preserves a certain amount of player agency along with providing a bit of surprise and anticipation on the player's turn. Many an "oooh" and a sharp intake of breath when a spell token suddenly drops on the field! =D
Sorry for my slow response. Aaron - Ah, I see. I'll try to obtain the player IDs then and see how that goes. I'll also look into those effects later on, maybe in a new post. That sounds really cool! (If they require the character sheet templates though, that might not be possible as our game doesn't use them and I'm unsure of the templates' ability to conform with our game's content). GiGs - When I click the token, then click the gear Icon, nothing comes up. I'm unable to edit literally anything other than the token's position on the map. (However, this is before using the Player IDs rather than their display names)
So after testing some commands, it seems I have no clue how to find someone's Player ID. How do I go about finding this info? After doing some digging in the Google Chrome developer window [F12], I was able to find the Player ID and implemented it into the script. I am able to edit the token's values as normal and it shows that the proper player has control over the token. The only thing left to test is if the player in question ACTUALLY has control over the token, but I'm confident that I was successful. Thanks again for your help!
1577889935
The Aaron
Roll20 Production Team
API Scripter
You can find the player ids from the API: on('ready', ()=&gt;{ on('chat:message', (msg) =&gt; { if( 'api' === msg.type &amp;&amp; /^!player-ids($|\b)/i.test(msg.content) &amp;&amp; playerIsGM(msg.playerid)) { let who = (getObj('player',msg.playerid)||{get:()=&gt;'API'}).get('_displayname'); let players = findObjs({ type: 'player' }); let playerParts = players.map( p =&gt; `&lt;li&gt;&lt;b&gt;${p.get('displayname')}&lt;/b&gt;: &lt;code&gt;${p.id}&lt;/code&gt;&lt;/li&gt;`); sendChat('',`/w "${who}" &lt;div&gt;&lt;ul&gt;${playerParts.join('')}&lt;/ul&gt;&lt;/div&gt;`); } }); }); Run this to see it work: !player-ids
Nice! That'll be much easier and quicker! I'll hold onto this in case I need it in the future.&nbsp;