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] Script to change an image on the map layer using a rollable table

I'm new to javascripting and after searching for hours I am admitting defeat. I have created a rollable table with the images I want to use for a token on the map layer. I've added the token to the map layer, and the functionality to randomly/selectively change the token image works great (r-click the token and under Multi-sided click either Random Side or Choose Side). However this requires the GM to be on the map layer. What I want to do is use a macro to do the work so a GM/player can just click a button:  /roll 1t[myTable] , but there doesn't seem to be any parameter for specifying which token (such as by token name). So that leaves me with calling a script that finds the token by name, and then applies the image from the rollable table to that token. I found a couple of related scripts ( TokenNameNumber and  RandomToken ), but it's way over my head to even extract what I can use from them. So basically what I'm asking for is to be able to use a macro: !script /roll 1t[myTable] (on myToken) that utilizes a script that: Gets the result of the /roll 1t[myTable] part of the macro Finds the token named "myToken" Changes the token image (applies the result to the token) Either that or perhaps the Roll20 DevTeam might consider adding the ability to specify the token in the macro syntax:  /roll 1t[myTable|myToken] Thanks for your consideration. Cheers!
1442238199
The Aaron
Pro
API Scripter
This isn't 100% possible in the API currently.  A script could be created that has this functionality, but it would only work for a table with images in a User Library, not images from the Market Place.  There are changes coming to the API soon that will allow this to work.
Very good to know...didn't realize there'd be a difference there. By "soon" are you talking another month or two, or further down the road? I would like to see a script in the meantime that simply works with my user library if anyone is willing to help out with that piece.
1442321875
The Aaron
Pro
API Scripter
Soon == The Next Big Push is suppose to have it in there, according to Riley at the GenCon Panel.  =D Something for user libraries could certainly be written.  I'm a bit swamped currently, but maybe someone else can knock this one out.  Otherwise, I'll try to get to it in a bit.  =D
Ok so fairly soon then...very nice. I am not in a huge rush, so whenever you can get to it is fine. Thanks for your assistance! :)
1442406130
The Aaron
Pro
API Scripter
So, how would you expect to target a specific image on the map layer.  Would it be sufficient to just try and change the largest image, or do you need to be able to specify a particular one?
It would need to be a particular one, using the Name field for the token as the identifier. This would allow a user to put a token on the map layer for: A door that has several image versions for type (wood, steel, stone), state (open, closed, broken), etc. Multiple door tokens could be placed on the grid where appropriate, each with its own table and macro. A map tile with several image versions that are appropriate to its spot on the grid. Multiple map tile tokens could be placed on the grid, each with its own separate table and macro. Etc. The GM  (or players I suppose ) then click the macros to generate a fairly random dungeon, for example.