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 .
×
Advertisement Create a free account

Is it possible to edit a text drawing via API?

1516322330
Say I have put some text onto a map that text-drawing thing. Is it possible to edit or update that text using an API? Like, if I want an API to read a value on a character sheet and update the text on the map to reflect the value, can that be done? And if so, would it the map with the text need to be the active map the players are on or could it be in the background?
1516324104
The Aaron
Forum Champion
API Scripter
You absolutely can.&nbsp; Those are Text objects:&nbsp; <a href="https://wiki.roll20.net/API:Objects#Text" rel="nofollow">https://wiki.roll20.net/API:Objects#Text</a> They do not need to be active.
I think the OP is asking if a script exists to do what he wants. To my knowledge, there is no script currently written that will do what you're asking.&nbsp; That said, depending how you want to handle it, it wouldn't be that hard to write for someone who knows what they're doing (which excludes me, since I'm a neophyte javascript coder).
1516347602
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
This is the sort of solution that makes me want to start looking for a problem.
1516377564
The Aaron
Forum Champion
API Scripter
Right, so if this is more of an "I want a script to do X" post, lets flesh that out.&nbsp; The technical aspects are all there, it's the interface that will be the hard part. "When I do ACTION, copy ATTRIBUTE from CHARACTER and update the value of TEXT on PAGE" ACTION -- what is the action you want to do?&nbsp; Needs to be an event, such as an API command in the chat, a specific roll template being sent to chat, an attribute on a character being changed, a token being moved/flagged/adjusted in some way. CHARACTER -- how do you know which character to use, and what ATTRIBUTE to collect? And does the attribute need to be evaluated (formula) first? TEXT -- how do you know what text to update, and if this is more general, which PAGE to do the update on? Those are the questions that need to be answered before the script can be written.&nbsp; You could write a script that would take the attribute of a known character and update a known text object with its contents in a few lines of code, but it isn't useful if you can't do it in a general case: let attr = getObj('attribute', knownAttrID ); let text = getObj('text', knownTextID ); text.set('text',attr.get('current'));