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] Carrying tokens v2

1409555428

Edited 1412542544
Ada L.
Marketplace Creator
Sheet Author
API Scripter
This is a remake of my original carrying tokens script. This version is shorter, should have less bugs about token ownership, and makes use of selecting tokens rather than giving their names to the chat command. Usage is explained in the documentation. <a href="https://gist.github.com/Cazra/b9451719989526f5f6df#v2.3" rel="nofollow">https://gist.github.com/Cazra/b9451719989526f5f6df#v2.3</a>
Nice. There is some hesitation between moving a player token and the carried token but I'm sure that's a limitation of the API, since it doesn't know where the token will be placed. I could easily see this being adapted for a "following" token, e.g. a companion animal that automatically follows its owner. Thank you.
1409585376
Ada L.
Marketplace Creator
Sheet Author
API Scripter
A "following" script? You should check out my other thread: <a href="https://app.roll20.net/forum/post/1139410/script-following-slash-marching-order-v2-dot-0#post-1139975" rel="nofollow">https://app.roll20.net/forum/post/1139410/script-following-slash-marching-order-v2-dot-0#post-1139975</a> ;)
1410364471

Edited 1410364520
I'm pretty new to API, so please bare with me if I am missing something obvious. But you stack the tokens you want carried on top, with the bottom token being the one you want to carry the others, right? When I tried that and selected all the tokens, and typed !carry, the API output console gets an error: TypeError: Cannot call method 'get' of undefined. at evalmachine.&lt;anonymous&gt;:320:35. at eval ( Thanks in advance.
1410405175
The Aaron
Roll20 Production Team
API Scripter
@God - Did you have any tokens selected when you issued the command? If you don't have anything selected, this script will crash on line 67 when it tries to call get on undefined.
I tried !carry with selecting the whole stack, both when actually stacked, or just all selected. As soon as I type it in, it gives me that error, And Ive tried with both named tokens, and unnamed tokens. I also tried just selecting the bottom token, or top token just in case I read the instructions on how it works wrong. How can you tell which line it crashes on? (it gives me a similiar issue with the follow API you have too) And ignore my name, it was a obvious joke in the campaign I run and I didnt realize it extends to forum names too.
1410446768
The Aaron
Roll20 Production Team
API Scripter
@God - No worries. If you want to PM me a join link, I can jump in and see if I can get it working for you. They aren't my scripts, but I can probably help you with it.
I added a toFront(carrier); at line 73, and a toBack(carrier) at line 112 (113 after you add the first addition) This makes it very easy to carry and drop back and forth.
1410577454
Ada L.
Marketplace Creator
Sheet Author
API Scripter
@Somebody Yes, the tokens must be stacked, and they all must be selected. I'll make a change to the script though so it informs the user of this instead of crashing. @ Bryan Great idea! I'll add that into the script.
Did you update it by any chance update it to not crash? I was running into multiple crash issues with a player who was trying to figure this out during combat and was crashing the API left and right.
1410824559
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Yes, I just updated the script this evening in the gist. Unfortunately the previewer doesn't update on this page, so you'll need to copy it from the gist page.
Crashing on load for me
1410842477
The Aaron
Roll20 Production Team
API Scripter
Stephen L. said: Yes, I just updated the script this evening in the gist. Unfortunately the previewer doesn't update on this page, so you'll need to copy it from the gist page. Edit the original post and append a unique anchor to the end of the gist URL. I use the version number of the script, but anything works: .../Cazra/b94517...f6df#v2.3
Stephen, any idea why it is crashing when I enable and save it? The old version didn't do that, mind pointing out the line that is supposed to prevent it from crashing when the carry script is called without the proper arguments, I'll have to look into it to get it working.
1411182727
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I'll take a look into the scripts this weekend to see why they're crashing.
Any way we can get the carried token to turn with the token carrier? My players have a bullseye lantern, but their own darvision goes out in a wider selection. As it is, they are stuck looking "upward" and can only turn the lantern.
1412542189
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I could look into setting up an event trigger that will change the direction of carried tokens whenever the carrier's direction changes.
1412542600
Ada L.
Marketplace Creator
Sheet Author
API Scripter
You're in luck! The script is now modified so that carried tokens always face the direction their carrier is facing. :)
:D THANKS SO MUCH!
TypeError: Cannot call method 'get' of undefined at evalmachine. :517:35 at eval ( :(
1412623712

Edited 1412624155
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I'm having trouble replicating your error. Can you describe what you were doing when the error was generated? Unfortunately, the API only provides very cryptic tracing information when an error happens. :/
I selected two tokens using the shift key. I then typed in !carry and pressed enter. Nothing happened, and the error code showed up.
I suppose I should say neither token was Named?
1412692128
Ada L.
Marketplace Creator
Sheet Author
API Scripter
That shouldn't matter whether the tokens are named. I'm testing mine out right now and I'm not getting an error, even with unnamed tokens. Are you perhaps using an older version of the script? Perhaps it is causing some other script to misbehave in an unforeseen way? You can test for this by disabling your other scripts. If the script works when all other scripts are disabled, then this might be the case.