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

[Script] change token image from rolltable

1446242096

Edited 1447867188
chris b.
Pro
Sheet Author
API Scripter
I could not find a script that just flipped a token from one image to another (a token built using a rollable table to create the different images possible), I found plenty of scripts that were random, especially when you dragged it onto the map, etc. But I just wanted to flip between 2 images when I clicked a button. (This will actually increment through the rolltable if there is more than 2).&nbsp;Why, you ask? Because I am taking my players through a halloween module where after a few minutes in they wake up to discover everyone else is dead, and slowly, after a certain event, the bodies start animating as zombies. My tokens image are multi-sided via rolltable, one side is a dead body on the ground, and the other side is the zombie image. I mainly wanted a script so I could flip the image quickly for many at once. Download it here&nbsp; <a href="https://github.com/Roll20/roll20-api-scripts/tree/master/ChangeTokenImage" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/tree/master/ChangeTokenImage</a> Usage: select tokens and type !change-token-img --flip !change-token-img --help &nbsp;As you can see, I shamelessly copied the structure from TokenMod anyway. Most of Aaron's scripts are so nicely laid out I decided "this is a pattern" and followed it. So I suppose I'm asking: 1. What to do with this to share it (how to get it into github and set the little json files correctly, etc. ) 2. Would it instead work better as another option for TokenMod, and if so how do I go about doing that? ( 3. what improvements are needed (&nbsp;such as picking a side instead of just incrementing the side) thanks to Aaron for TokenMod Matt&nbsp; for figuring out the easy 2 lines of code to change the token image.
1446256012
The Aaron
Pro
API Scripter
Nice contribution! &nbsp;=D Brian calls it the&nbsp; Revealing Module Pattern , I just call it good sense. =D &nbsp;(I highly recommend Javascript: The Good Parts by Douglas Crockford , if you haven't read it yet. =D ) Answers to your questions: 1. &nbsp;There are some nice instructions in the repo's readme: &nbsp; <a href="https://github.com/Roll20/roll20-api-scripts/blob/" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/blob/</a>... The basic summary is Fork their repo and check out your forked copy locally. &nbsp;Put in your files, push them up to your repo, then make a pull request on the original repo. &nbsp;There are a million guides on doing that and links in the readme above; since you need to go there anyway, just jump off to them from there. =D 2. &nbsp;Possibly. &nbsp;I've experimented with it before (I have half of a Druid script written...). &nbsp;The problem I've run into is the inability of the API to set imgsrc to something from the marketplace. &nbsp;Riley has stated that he'll be fixing this limitation in the next release, so It will certainly make it in soon. =D &nbsp;(For the same reason, the sides argument gets ignored.) 3. TO THE STARS!!! &nbsp; =D
1446278389
Lithl
Pro
Sheet Author
API Scripter
The Aaron said: Brian calls it the&nbsp; Revealing Module Pattern , I just call it good sense. =D &nbsp;(I highly recommend Javascript: The Good Parts by Douglas Crockford , if you haven't read it yet. =D ) Douglas Crockford popularized the Module Pattern, although that's not what he called it. The Module Pattern was developed by several people around 2003, including Richard Cornford. The Revealing Module Pattern was developed and named by Christian Heilmann in response to his own frustrations with shortcomings in the Module Pattern. Both patterns have (slightly different) issues with overriding functions, but the Revealing version at least has consistent syntax between public and private members, meaning you can change visibility with a single line of code added or removed without introducing any syntax errors.
Very nice. I do have to wonder though, why it doesn't work exactly as if someone had changed manually. For example, I use a script I wrote for tokens to change size based upon their weight using a change: graphic event handler. The token doesn't resize, even after I move it to another square forcing the system to check. Granted, it's probably something in my own script (since I am like an amateur's janitor's best friend's dog walker in scripting), but it seems to lock that part of the rollable table out or something...
Just found this script today. &nbsp;Been wanting one for months now, but from my own research, it appeared like it couldn't be done. Unfortunately, when I try to use it I get an error in the Console: "ERROR: Please use the 'thumb' size for imgsrc properties." Any suggestions?
1447867104
chris b.
Pro
Sheet Author
API Scripter
Yes even now it only works if the images are in your library (such as downloading then uploading them to the library). Offhand one restriction I don't mention is the images have to be pngs. If it is not, it might not be able to pick the right image when it searches for the name (in line 67)
The extension was the issue. &nbsp;Changed the script from .png to .jpg for now and it works fine. &nbsp;Now I have to decide what's easier: &nbsp;modifying the script to account for different extensions or uploading all my non-png images as png format. edit: &nbsp;to clarify what I changed.
1447871473
The Aaron
Pro
API Scripter
Chris, you can use this function to get a clean image source for use in the API: &nbsp; <a href="https://wiki.roll20.net/API:Cookbook#getCleanImgsr" rel="nofollow">https://wiki.roll20.net/API:Cookbook#getCleanImgsr</a>... var getCleanImgsrc = function (imgsrc) { var parts = imgsrc.match(/(.*\/images\/.*)(thumb|max)(.*)$/); if(parts) { return parts[1]+'thumb'+parts[3]; } return; }; If the image is not in the user library, it will return undefined, otherwise it returns the proper thumb version of the url, preserving the extension.
1447875497
Lithl
Pro
Sheet Author
API Scripter
SeanOG said: Very nice. I do have to wonder though, why it doesn't work exactly as if someone had changed manually. For example, I use a script I wrote for tokens to change size based upon their weight using a change: graphic event handler. The token doesn't resize, even after I move it to another square forcing the system to check. Granted, it's probably something in my own script (since I am like an amateur's janitor's best friend's dog walker in scripting), but it seems to lock that part of the rollable table out or something... Changes to Roll20 objects by the set() function do not trigger change events. I don't believe API actions trigger events when creating or deleting objects, either. sendChat() does &nbsp;trigger chat:message events, though.
1447876795
chris b.
Pro
Sheet Author
API Scripter
thanks Aaron ill use that, it is more generic than my function.
Brian said: SeanOG said: Very nice. I do have to wonder though, why it doesn't work exactly as if someone had changed manually. For example, I use a script I wrote for tokens to change size based upon their weight using a change: graphic event handler. The token doesn't resize, even after I move it to another square forcing the system to check. Granted, it's probably something in my own script (since I am like an amateur's janitor's best friend's dog walker in scripting), but it seems to lock that part of the rollable table out or something... Changes to Roll20 objects by the set() function do not trigger change events. I don't believe API actions trigger events when creating or deleting objects, either. sendChat() does &nbsp;trigger chat:message events, though. I could understand that, but I guess what I'm referring to is that the script I have will automatically change a token's size based upon the weight that appears in the rollable table (representing the number of squares across it is, e.g.: 1 for 1x1, 2 for 2x2, etc.). I guess what I was saying, was that the script merely changes the image of the token according to what is on the rollable table, it doesn't change the side.
1447949281
The Aaron
Pro
API Scripter
Hey Chris, Ziechael is impatient so I went ahead and plugged getCleanImgsrc() into your script. &nbsp;I also cleaned up some things JSLint complains about. &nbsp;I sent you a pull request on your repo: <a href="https://github.com/plutosdad/roll20-api-scripts/pu" rel="nofollow">https://github.com/plutosdad/roll20-api-scripts/pu</a>... Cheers!&nbsp;
1447953845
chris b.
Pro
Sheet Author
API Scripter
great thanks, &nbsp;have been busy :) I merged it and submitted the pull to the master
1447954512
The Aaron
Pro
API Scripter
Hopefully I didn't break it. =D
1448012257
Ziechael
Forum Champion
Sheet Author
API Scripter
Works great with the testing I've done... exactly what I've been needing for that annoying Druid in my game :) Thanks Chris for the initial work and thanks Aaron for indulging an impatient luddite!
1450282326

Edited 1450308665
Ok, I'm a massive noob, so that's probably the issue, but... I put 2 images in a rollable table and added the script to my API scripts. I added a token from the table, selected the token and tried !change-token-img --set 1.&nbsp; This gives a result of: "1 is not a valid value for set parameter." I tried !change-token-img --flip, but that crashes the API with the following error: /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ TypeError: Cannot call method 'substring' of undefined at TrackedObj._validateAttrs ( I don't have a single doubt that I'm doing something simple wrong, but I have no idea what. Help, please?
David M. said: Ok, I'm a massive noob, so that's probably the issue, but... I put 2 images in a rollable table and added the script to my API scripts. I added a token from the table, selected the token and tried !change-token-img --set 1.&nbsp; This gives a result of: "1 is not a valid value for set parameter." I tried !change-token-img --flip, but that crashes the API with the following error: /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ TypeError: Cannot call method 'substring' of undefined at TrackedObj._validateAttrs ( I don't have a single doubt that I'm doing something simple wrong, but I have no idea what. Help, please? I've found a similar issue here , with created images not having fbpath for attributes, but I'm not having much luck integrating it here.&nbsp; I managed to modify and insert what seemed like the key bits of their fix: if (o && !o.fbpath) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o.fbpath = o.changed._fbpath.replace(/([^\/]*\/){4}/, "/"); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return o; above the o.set in the relevant functions, but...although it stopped getting me the error...it also didn't accomplish anything in terms of actually spinning the image.
1450383205
The Aaron
Pro
API Scripter
Hi David! &nbsp;Sorry, I meant to reply to you yesterday but got side tracked. What other scripts are you running? &nbsp;That error message seems to be for a different script, something named TrackedObj perhaps? &nbsp;The example code you found was for fixing a bug with created objects which has sense been cleared up. My guess is that you are using objects from the marketplace in your Rollable Table. &nbsp;The API can't create objects from the marketplace currently.
1450401155
chris b.
Pro
Sheet Author
API Scripter
Don't kill me, are you are first dragging the rolltable to the map, and then manually using the context menu to confirm you can switch between the two images? Your first error "1 is not a valid number" indicates it can only find one "side" of the token, so it can't change. So first I would ensure you can change the sides manually.&nbsp; i haven't tried it since they put out the big update a few days ago, so something also might have broken it.
Well...I'm running A LOT of scripts.&nbsp; TokenMod, CleanAbilities, Shaped Scripts, IsGM, GroupInit, a custom script for populating druid abilities and health bars, and one just to populate some command buttons in chat to simplify my DM's life. but...None of them are called TrackedObj or even contain that string. Regardless, I went through and disabled all of them except ChangeTokenImg, and it fails the same way. I've replaced the images in the Rollable table with 2 fresh uploaded images from my PC.&nbsp; Unfortunately, I'm getting the same error.&nbsp; Any other thoughts? Sorry to be difficult. I'm just stumped.
Hello all. I am a Java script noobie, but I found an issue. I am currently only using the change-token-image script. When I try using the --set option it did not matter what values I used: 0,1,2, a,b,c,etc.&nbsp; Now a, b, c should have given errors about it being not a valid option, but 0, 1, and 2 should have.&nbsp; With the same token, I could use the --flip and --incr without errors.&nbsp; I finally figured out today that something in the code seems to be making valid inputs act as invalid ones for the --set option.&nbsp; I was able to fix my issue by commenting out lines 121-124 of your script. 121 // if (! isInt(setval)) { 122 // showError(msg.playerid,setval,'','ARG'); 123 // return; 124 // } With commenting out the lines indicated above I can now use the --set command with out problems.&nbsp; If I insert an inappropriate value like a, b, or c, it causes the API to bomb out and get disabled.&nbsp; At this point I don't know how to get this to work with the proper error handling, but yal might know how to fix that part quickly since I have identified part of where the issue is coming from. Thanks for the great work on this so far, XiousDs
1450668358
The Aaron
Pro
API Scripter
Damian G. said: Hello all. I am a Java script noobie, but I found an issue. I am currently only using the change-token-image script. When I try using the --set option it did not matter what values I used: 0,1,2, a,b,c,etc.&nbsp; Now a, b, c should have given errors about it being not a valid option, but 0, 1, and 2 should have.&nbsp; With the same token, I could use the --flip and --incr without errors.&nbsp; I finally figured out today that something in the code seems to be making valid inputs act as invalid ones for the --set option.&nbsp; I was able to fix my issue by commenting out lines 121-124 of your script. 121 // if (! isInt(setval)) { 122 // showError(msg.playerid,setval,'','ARG'); 123 // return; 124 // } With commenting out the lines indicated above I can now use the --set command with out problems.&nbsp; If I insert an inappropriate value like a, b, or c, it causes the API to bomb out and get disabled.&nbsp; At this point I don't know how to get this to work with the proper error handling, but yal might know how to fix that part quickly since I have identified part of where the issue is coming from. Thanks for the great work on this so far, XiousDs If you change line 120 to: setval = parseInt(cmds,10); It will probably allow the numbers in but prevent the letters.
1450668608
The Aaron
Pro
API Scripter
David M. said: Well...I'm running A LOT of scripts.&nbsp; TokenMod, CleanAbilities, Shaped Scripts, IsGM, GroupInit, a custom script for populating druid abilities and health bars, and one just to populate some command buttons in chat to simplify my DM's life. but...None of them are called TrackedObj or even contain that string. Regardless, I went through and disabled all of them except ChangeTokenImg, and it fails the same way. I've replaced the images in the Rollable table with 2 fresh uploaded images from my PC.&nbsp; Unfortunately, I'm getting the same error.&nbsp; Any other thoughts? Sorry to be difficult. I'm just stumped. Try changing the following: setImg = function (o,nextSide,allSides) { var nextURL = getCleanImgsrc(decodeURIComponent(allSides[nextSide])); if(nextURL){ o.set({ currentSide: nextSide, imgsrc: nextURL }); } return nextURL; }, setImgUrl = function (o, nextSide, nextURL) { var next=getCleanImgsrc(nextURL); if(next){ o.set({ currentSide: nextSide, imgsrc: next }); } }, and see if you still get the crash.
1450675172
chris b.
Pro
Sheet Author
API Scripter
sorry i have not replied, been busy this weekend and actually was playing tonight rather than writing sheet code.&nbsp; i wrote the isInt early on and i can probably improve it, parseInt is probably better (though I guess it would allow 3b but then it's not really that important, i only added the checking to help users not to stop them), and add some try catches so at least it won't kill the session
The Aaron said: David M. said: Well...I'm running A LOT of scripts.&nbsp; TokenMod, CleanAbilities, Shaped Scripts, IsGM, GroupInit, a custom script for populating druid abilities and health bars, and one just to populate some command buttons in chat to simplify my DM's life. but...None of them are called TrackedObj or even contain that string. Regardless, I went through and disabled all of them except ChangeTokenImg, and it fails the same way. I've replaced the images in the Rollable table with 2 fresh uploaded images from my PC.&nbsp; Unfortunately, I'm getting the same error.&nbsp; Any other thoughts? Sorry to be difficult. I'm just stumped. Try changing the following: setImg = function (o,nextSide,allSides) { var nextURL = getCleanImgsrc(decodeURIComponent(allSides[nextSide])); if(nextURL){ o.set({ currentSide: nextSide, imgsrc: nextURL }); } return nextURL; }, setImgUrl = function (o, nextSide, nextURL) { var next=getCleanImgsrc(nextURL); if(next){ o.set({ currentSide: nextSide, imgsrc: next }); } }, and see if you still get the crash. That definitely stops the crashing!&nbsp; YAY! ...but it doesn't get the images to change. does anyone have a working implementation of this they'd be willing to let me take a peek at? Also, I'd be happy to let someone peek at my campaign and tell me what it is I've noobed. Thank you so much for your help with this!
1450757153
chris b.
Pro
Sheet Author
API Scripter
Could you copy the campaign to dev and send me an invite , and make sure all users have access to edit the rolltable. I will try to see what is going on.&nbsp; Thanks.
1450758328
The Aaron
Pro
API Scripter
If the code changes I suggested fixed the crash, the issue is that the images you have on the rollable table token come from the market place. You need to download the images and upload them to your user library, then recreate the table with the copies in your user library. One non-intuitive thing: you need to recreate any rollable table tokens from the new table. Any you created from the old table will have the old (marketplace) links. That's probably the issue.
AAAANd we have an answer.&nbsp; I've been trying to drag the image from the Library MANAGER, not the sidebar. finally found this thread which answered that question. Thank you all for your patience and assistance!
1450937590
The Aaron
Pro
API Scripter
Awesome! &nbsp;Glad you got it worked out!
Thanks to everyone in this thread (esp. David) for getting this working! &nbsp; We now have the ability to wild shape our party's druid into any of about a dozen beasts. &nbsp;It's about four clicks - Wildshape to bring up the buttons in chat, then click the shape button (to change the token action set to include beast powers) and click the image button (to change the token image to represent the right creature). &nbsp;One more click on "Unshape" returns her to her human form and if her animal form took any damage, it correctly re-calculates her new human HP total based on the 5e rules. Since there's an expectation that a druid will Wild Shape for nearly every combat, this is going to make our sessions run substantially faster. &nbsp;Thanks!&nbsp;
Any credit given me is surely due to The Aaron and Chris B for providing me an AWESOME framework to fumble with. :D
Anyway to get this to randomize? or even accept except inline rolls? I have some doppelgangers token with 28 diff faces, thought it would be neat to include a --set [[1d28]] command in their attacks to have them randomly morph on each attack :) Just for fun, if not ill just do it by hand.
Is this code gonna be posted up on github?&nbsp;
Coal Powered Puppet said: Is this code gonna be posted up on github?&nbsp; it is, in the OP <a href="https://github.com/Roll20/roll20-api-scripts/blob/master/ChangeTokenImage/ChangeTokenImage.js" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/blob/master/ChangeTokenImage/ChangeTokenImage.js</a>
The Aaron said: David M. said: Well...I'm running A LOT of scripts.&nbsp; TokenMod, CleanAbilities, Shaped Scripts, IsGM, GroupInit, a custom script for populating druid abilities and health bars, and one just to populate some command buttons in chat to simplify my DM's life. but...None of them are called TrackedObj or even contain that string. Regardless, I went through and disabled all of them except ChangeTokenImg, and it fails the same way. I've replaced the images in the Rollable table with 2 fresh uploaded images from my PC.&nbsp; Unfortunately, I'm getting the same error.&nbsp; Any other thoughts? Sorry to be difficult. I'm just stumped. Try changing the following: setImg = function (o,nextSide,allSides) { var nextURL = getCleanImgsrc(decodeURIComponent(allSides[nextSide])); if(nextURL){ o.set({ currentSide: nextSide, imgsrc: nextURL }); } return nextURL; }, setImgUrl = function (o, nextSide, nextURL) { var next=getCleanImgsrc(nextURL); if(next){ o.set({ currentSide: nextSide, imgsrc: next }); } }, and see if you still get the crash. This stops the crashing for me, but there is a problem with what you're saying is the solution: I don't use any tokens from the marketplace. I make them myself and upload them directly to the rollable table. So, the problem must be that you have to drag the images from your library to the rollable table.
1452108576

Edited 1452108814
And I found what the problem is... I checked out the Javascript Console and I see that what is being swapped when using this script is from this: /images/14935838/uuC96TlJLyFXxLtdgrydeA/thumb.png?14518449565 to this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/thumb.png?14518449695 Okay... no problem, except that when you upload directly to the rollable table, it saves as this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/med.png?14518449695 To fix the problem with the script (where my error was concerned), I changed line 68 to: var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|max)(.*)$/); Now that I know where this problem was, I can now look into making this work with my AutoResize script that bases its resize on the image in the rollable table -- which is med.png...
1452110919
The Aaron
Pro
API Scripter
Ah, good point! &nbsp;I'll update the cookbook code.
1452112959
chris b.
Pro
Sheet Author
API Scripter
I never tried loading directly to the rollable table. i'll try to add that update in soon , thanks.!
1452115760

Edited 1452179858
Coal Powered Puppet
Pro
Sheet Author
Running into an issue. &nbsp;I keep getting "0 is not a valid value for set parameter" anytime I try a "--set" command. &nbsp;This happens with and without the --notsame command added in, and happens with any number. &nbsp;The "--flip" command works just fine, however (and my players will love you for it). Edit: The rollable tables I am using have 4 images each.
1452117404
chris b.
Pro
Sheet Author
API Scripter
Can you make sure you are dragging the image from the search into the rollable table? that sounds like the exact error David M was getting above.
1452118509

Edited 1452119190
Coal Powered Puppet
Pro
Sheet Author
That's how I do it. &nbsp; But , I will remake one of the table and see what happens. Edit: Yeah, no joy. &nbsp;Each image is in my library, and uploaded by me before creating the rollable table. &nbsp;It is stated that the TokenMod was the the based/was heavily stolen from. &nbsp;Would Trackerjacker or Cthulutech get in the way? &nbsp;I'll test now. Edit, again: Nope, no conflict that I can tell with Trackjecker or C-tech dice. &nbsp;Its not a big issue, honestly. &nbsp;I mostly wanted something for my players, but this would be awesome if I can turn all my monsters into monster upon command.
SeanOG said: And I found what the problem is... I checked out the Javascript Console and I see that what is being swapped when using this script is from this: /images/14935838/uuC96TlJLyFXxLtdgrydeA/thumb.png?14518449565 to this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/thumb.png?14518449695 Okay... no problem, except that when you upload directly to the rollable table, it saves as this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/med.png?14518449695 To fix the problem with the script (where my error was concerned), I changed line 68 to: var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|max)(.*)$/); Now that I know where this problem was, I can now look into making this work with my AutoResize script that bases its resize on the image in the rollable table -- which is med.png... Awesome!&nbsp; Thanks for following up on that!
David M. said: SeanOG said: And I found what the problem is... I checked out the Javascript Console and I see that what is being swapped when using this script is from this: /images/14935838/uuC96TlJLyFXxLtdgrydeA/thumb.png?14518449565 to this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/thumb.png?14518449695 Okay... no problem, except that when you upload directly to the rollable table, it saves as this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/med.png?14518449695 To fix the problem with the script (where my error was concerned), I changed line 68 to: var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|max)(.*)$/); Now that I know where this problem was, I can now look into making this work with my AutoResize script that bases its resize on the image in the rollable table -- which is med.png... Awesome!&nbsp; Thanks for following up on that! No worries. I have been wanting to use this script for awhile because my players all use a rollable table token, with mounted and dismounted token values. With my own script that automatically resizes based upon the weight value of the side (1 for 1x1, 2 for 2x2), I wanted to make it easier for them than right-clicking and choosing a side. Right now, it's a double call macro (one for this script, one to manually resize), but I'll eventually get it down to one.
1452179925

Edited 1452189356
Coal Powered Puppet
Pro
Sheet Author
For the PC tokens the script seems to work just fine. &nbsp;For the NPC token, I keep getting this error: /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ TypeError: Cannot call method 'substring' of undefined at TrackedObj._validateAttrs (
SeanOG said: David M. said: SeanOG said: And I found what the problem is... I checked out the Javascript Console and I see that what is being swapped when using this script is from this: /images/14935838/uuC96TlJLyFXxLtdgrydeA/thumb.png?14518449565 to this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/thumb.png?14518449695 Okay... no problem, except that when you upload directly to the rollable table, it saves as this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/med.png?14518449695 To fix the problem with the script (where my error was concerned), I changed line 68 to: var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|max)(.*)$/); Now that I know where this problem was, I can now look into making this work with my AutoResize script that bases its resize on the image in the rollable table -- which is med.png... Awesome!&nbsp; Thanks for following up on that! No worries. I have been wanting to use this script for awhile because my players all use a rollable table token, with mounted and dismounted token values. With my own script that automatically resizes based upon the weight value of the side (1 for 1x1, 2 for 2x2), I wanted to make it easier for them than right-clicking and choosing a side. Right now, it's a double call macro (one for this script, one to manually resize), but I'll eventually get it down to one. I'm actually in a similar position with Wildshapes, where I'm using 2 macros, 1 to do stat changes and actions and one for the images because I haven't really figured out how to call this script from my other one.&nbsp; So I set up a menu in chat to give them buttons, because I'm too lazy to get around to pulling the pieces apart.
Coal Powered Puppet said: For the PC tokens the script seems to work just fine. &nbsp;FOr the NPC token, I keep getting this error: /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ TypeError: Cannot call method 'substring' of undefined at TrackedObj._validateAttrs ( A few questions based on my own recent troubleshooting: Do your tokens represent NPC Character sheets? If they aren't linked to a character, you'll get a fail. Are you rolling the original tokens from the rollable table? If you've made changes to the rollable table have you RE-rolled the tokens?
The above error was- much to my embarrassment- likely caused by using a rollable table with a image hard dropped in the table instead of using the libary. &nbsp;I have since taken to deleting old tables and making whole new ones. I am still getting the error "2 is not a valid value for set parameter" (or any other number). &nbsp;I can use --flip and --incr, but not --set. Everything has a character journal linked to it. The token are created by hitting the token button on the tallable table, made not to be a drawing, and assigned to a character journal. &nbsp;The token on the character journal was deleted and this rollable table token was made the default. And I don't make changes to the rollable table (after the above embarrassment); I make whole new tables, remake the token, and assign it to a character sheet.
David M. said: SeanOG said: David M. said: SeanOG said: And I found what the problem is... I checked out the Javascript Console and I see that what is being swapped when using this script is from this: /images/14935838/uuC96TlJLyFXxLtdgrydeA/thumb.png?14518449565 to this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/thumb.png?14518449695 Okay... no problem, except that when you upload directly to the rollable table, it saves as this: /images/14935850/RLTRIkfIWWc1AuUN9MUzqQ/med.png?14518449695 To fix the problem with the script (where my error was concerned), I changed line 68 to: var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|max)(.*)$/); Now that I know where this problem was, I can now look into making this work with my AutoResize script that bases its resize on the image in the rollable table -- which is med.png... Awesome!&nbsp; Thanks for following up on that! No worries. I have been wanting to use this script for awhile because my players all use a rollable table token, with mounted and dismounted token values. With my own script that automatically resizes based upon the weight value of the side (1 for 1x1, 2 for 2x2), I wanted to make it easier for them than right-clicking and choosing a side. Right now, it's a double call macro (one for this script, one to manually resize), but I'll eventually get it down to one. I'm actually in a similar position with Wildshapes, where I'm using 2 macros, 1 to do stat changes and actions and one for the images because I haven't really figured out how to call this script from my other one.&nbsp; So I set up a menu in chat to give them buttons, because I'm too lazy to get around to pulling the pieces apart. Lazy? No... I think not...
Coal Powered Puppet said: The above error was- much to my embarrassment- likely caused by using a rollable table with a image hard dropped in the table instead of using the libary. &nbsp;I have since taken to deleting old tables and making whole new ones. I am still getting the error "2 is not a valid value for set parameter" (or any other number). &nbsp;I can use --flip and --incr, but not --set. Everything has a character journal linked to it. The token are created by hitting the token button on the tallable table, made not to be a drawing, and assigned to a character journal. &nbsp;The token on the character journal was deleted and this rollable table token was made the default. And I don't make changes to the rollable table (after the above embarrassment); I make whole new tables, remake the token, and assign it to a character sheet. Did you try this solution from upthread? If you change line 120 to: setval = parseInt(cmds,10); It will probably allow the numbers in but prevent the letters.