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

[Request] Placing specific images from your database to your board via a saved database of sorts?

Yes, I know its me again asking for scripts I am incapable of doing but its more of an addition and strange combination. I'm sure there are many DMs who like to have special templates/effects for their spells in certain games and what not. I was looking for a script that would pull it from your image library/character sheet and resize said image to a saved preset value. For example if I typed !ES Fireball. It would create a 20 by 20 image of a fireball on selected target and resize the image to the map layer appropriately. The idea of this came from Grow it Script! <a href="https://app.roll20.net/forum/post/1689767/script-g" rel="nofollow">https://app.roll20.net/forum/post/1689767/script-g</a>... I was wondering if there was anything with this sort of function? Or at least dropping specific images to the board?
1443002015
Lithl
Pro
Sheet Author
API Scripter
The API can only create tokens using images from someone's art library. (Neither art from the marketplace nor the web works.) The API has no means of searching &nbsp;your art library. Therefore, the only way to have the API generate a specific token is to find the URL of the image you want from your art library, which requires inspecting a token with that particular image with the API's logging capabilities. This is the script I use for doing exactly that! on('ready', function() { &nbsp; &nbsp; on('add:graphic', function(obj) { &nbsp; &nbsp; &nbsp; &nbsp; log(obj.get('imgsrc')); &nbsp; &nbsp; }); }); When you drop an image on the VTT, it will log the URL for the image. Depending on where you drag the image from, this script may log the med.png/gif/jpg version of the image, and you'll have to change that to thumb.png/etc. for token creation. Once you have the URL you need, you can create some static data to save the relevant information. Here's a snippet from one of my own scripts (full URLs removed for clear reading): var bshields = bshields || {}; bshields.carddata = { &nbsp; &nbsp; weapon: { &nbsp; &nbsp; &nbsp; &nbsp; 'Chellan, Sword of Greed': &nbsp; { name: 'Chellan, Sword of Greed', imgsrc: '...' }, &nbsp; &nbsp; &nbsp; &nbsp; 'Karzoug\'s Burning Glaive': { name: 'Karzoug\'s Burning Glaive', imgsrc: '...' }, &nbsp; &nbsp; &nbsp; &nbsp; 'Fanged Falchion': &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { name: 'Fanged Falchion', imgsrc: '...' } &nbsp; &nbsp; }, &nbsp; &nbsp; spell: { &nbsp; &nbsp; &nbsp; &nbsp; 'Summon Monster': { name: 'Summon Monster', imgsrc: '...' } &nbsp; &nbsp; }, &nbsp; &nbsp; armor: { &nbsp; &nbsp; &nbsp; &nbsp; 'Snakeskin Tunic': { name: 'Snakeskin Tunic', imgsrc: '...' } &nbsp; &nbsp; }, back: '...' }; Dropping the graphic you want is then just a matter of creating a new graphic object with the appropriate properties (including the imgsrc value you've saved). Here's where that script lays out the player's hand of cards on the table: &nbsp; &nbsp; function layoutHand(index, playerid) { &nbsp; &nbsp; &nbsp; &nbsp; var character = getCharacterForPlayer(playerid), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; handPos = bshields.locations.players[index].hand, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; existingCards = _.reject(findObjs({ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: 'graphic', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layer: 'objects', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; controlledby: playerid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }), function(graphic) { return graphic.get('name').indexOf('freeze') &gt;= 0; }), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; existingCardNames = _.map(existingCards, function(graphic) { return graphic.get('name'); }), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fullHand = state.bshields.pfacg.charData[playerid].hand, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cardsToCreate = _.reject(fullHand, function(card) { return _.contains(existingCardNames, card.name); }); &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _.each(cardsToCreate, function(card) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var newCard = createObj('graphic', { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left: handPos.left, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top: handPos.top, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width: 128, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height: 180, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imgsrc: card.imgsrc, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageid: Campaign().get('playerpageid'), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layer: 'objects', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: '"' + card.name + '"', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; controlledby: playerid, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; playersedit_name: false, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; playersedit_bar1: false, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; playersedit_bar2: false, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; playersedit_bar3: false, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; playersedit_aura1: false, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; playersedit_aura2: false &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; existingCards.push(newCard); &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; existingCards = _.sortBy(existingCards, function(card) { return card.get('name'); }); &nbsp; &nbsp; &nbsp; &nbsp; _.each(existingCards, function(card, i) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; card.set({ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left: handPos.left + i * 130, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top: handPos.top &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; }
Thanks, Brian.
You may want to check out the Animation script.&nbsp; It sounds like you want the tokens to stick around, rather than being auto-pruned, which would require that you remove/comment out the call to tok.remove() in the removeRunningAnimation function, but it should otherwise do what you want.
Ah that is true! Thank you Manveti. Thats actually really helpful :)