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

[Help] - API script that combines markers to attributes with multiple digits

I added everything else I need, except I am having trouble with the setter, the base marker to attribute script works.

I can't figure out what I am doing wrong:

https://gist.github.com/anonymous/633c86f0e16f5559...


I also want to have a "shot arrow" macro, but it seems you can't set attributes this way, but can in a similar way done in the base marker to attribute script???

https://gist.github.com/anonymous/3d145b97b63fd589...


June 26 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
I'd love to help you out with this. Can you give a more thorough explanation of what it's suppose to be doing, and what it's failing to do, and how to activate it to test it?
The retrieval I imagine needs to be converted as well. Essentially it will allow for multiple markers of the same type for a token, tie it back to an attribute. Both will update the other,etc. this will persist to all copies of the token. So you won't have to copy and paste just one token. I next want to tie in light radius. With the attributes on the character sheet it easily allows players to set what active markers they have for any statuses. It should assist with needing more than 3 values.(bars)
June 26 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
So, you're trying to setup a system where:
  • If you add a status to a token which represents a particular character, the status is set on every token representing that character?
  • If on a character, you adjust an attribute of a known name that maps to a status, it adjusts the status of all tokens that represent that character to match?
To test it all you have to do is make an attribute named "melee". Set the value to 5. Add the red marker, set it to 4. Old script would work. This script when working would take an attribute over 9 and make two copies of the same marker to indicate the proper value.
Yes, correct, I'm trying to make it handle multiple digits.
June 26 (10 years ago)

Edited June 26 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
So, the failure is in updateAllTokens?

Just as a point of simplification, this will build your digits for you:
var icons = [];
_.each(value.toString().split(''),function(digit){
	icons.push( marker+'@'+digit );
});
var icon=icons.join();
The .join() takes care of having the right number of commas automatically.

June 26 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Incidentally, Brian has a fly script version that marks with multiple status digits: https://wiki.roll20.net/User:235259/Flight

Looking at that might reveal some insight. Also, try throwing in some log statements to verify that everything is working as you expect it. Try logging the status of each token before and after your .set().
June 26 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
ah.. now that I look at it, there is a striking resemblance... I'm guessing you already know about it. =D