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

API to change image

In every campaign I have a splash page that acts as a landing for the players.  It's simply a thematic image associated with the campaign. My thought though was to add a bit more pop to this by having multiple different images (on the map layer), that when moving the player ribbon to this page it would randomize the image. So is there an event that triggers when the player ribbon is moved to a page?  If I setup the images to be part of a Rolltable, can I trigger that to roll when this event occurs?
1476027011
Jakob
Sheet Author
API Scripter
You-re looking for ' change:campaign:playerpageid' ( <a href="https://wiki.roll20.net/API:Events" rel="nofollow">https://wiki.roll20.net/API:Events</a> ). I don't know if there's a built-in command to trigger a roll on a rollable table, but even if there isn't, you could build that in the API by finding all elements of a certain table and randomly choosing one of them.
1476064877
The Aaron
Pro
API Scripter
There isn't a way to roll a rollable table token from the API. However, a Rollable Table Token has all the images in an array on the property 'sides'. You can use something like this to set a random one: img.set('ingsrc',_.sample(img.get('sides')); you'll probably want to verify that the img has a sides property.&nbsp; Note: I wrote this on my phone, so some debugging may be needed. :)
Thanks, this was helpful. It let me create a quick and dirty script to accomplish what I wanted with some hard coded values specific to my campaign. I thought about making it more generic, but there are several idiosyncrasies that an amateur like me couldn't quite wrap my head around, mainly how to define the initial graphic and or maintain sets.
1476102460
The Aaron
Pro
API Scripter
I'd be happy to walk you through any of that, if you're interested. =D
The Aaron said: I'd be happy to walk you through any of that, if you're interested. =D I appreciate that! &nbsp;I have to start on my next campaign prep, but I might try to work in some scripting time as well, so will reach out when I start working on it.
This may or may not be related but I was wondering if it is possible for background images to change automatically at intervals like a slideshow?
1476203645
The Aaron
Pro
API Scripter
Backgrounds, as in the lowest level image of a map ? &nbsp;Yes. &nbsp;Would be pretty much the same thing Kevin is talking about.
So in addition to using this for "Background Images" (i.e. lowest level image of the map), I have been using this to randomize battlemaps as well, so that as soon as I move the player ribbon to a particular map, it will randomly select a map that is part of that particular roll table.