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

Custom token marker with Character sheet checkbox

Hello, I am attempting to implement a feature where toggling a checkbox on a character sheet displays/removes a custom status marker on the associated token on the map.  I've tried multiple times, referencing the Roll20 API documentation and popular scripts like TokenMod and CombatMaster, but I'm consistently failing... My goal is: Use checkbox fields on the character sheet (e.g., attr_status_stun, attr_status_disarmed with value="1"). When a checkbox is checked, a custom marker appear on the token linked to that character. When unchecked the marker should be removed. However changing the checkbox state does not update the token markers at all. I structured status effect checkboxes as <input type="checkbox" name="attr_status_stun" value="1">. And my API script caches all token markers (including custom ones) by their tag and id into a markerCache object using Campaign().get('token_markers'). It listens for changes on each status effect attribute individually using on('change:attribute:attributename') and manipulates the token's statusmarkers string using the cached markerId. Is the approach I'm taking the correct way to implement this functionality for custom markers?  Any help would be greatly appreciated.
1753273948
Andrew R.
Pro
Sheet Author
I do it as GM using ScriptCards. The One Ring 2e has a Daunted status which has a checkbox on the character sheet, and I want a Custom Token Maker on the token and to set the checkbox on the character sheet. !scriptcard {{ --/| Daunted +++snlib+++ --#debug|0 --#emoteState|invisible --#hidecard|0 --#hideTitleCard|1 --#sourcetoken|@{selected|token_id} --&DAUNTED|"Frightened::243695" --&PLAYERHERO|[*S:t-name] --+|[&PLAYERHERO] is Daunted! --!a:[*S:character_id]|daunted:1 -->LibSN_ADD_STATUS_MARKER|[*S:t-id];[&DAUNTED];0 }}
1753287691

Edited 1753287702
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Instead of making your own token cache, I'd recommend using Aaron's LibTokenMarkers script as a dependency so that it handles all the logic of how to interact with the token markers. As for why nothing is happening, that's a complex question that we'd need to see your API script code in order to answer. It could be that your listener isn't structured right, that you have an error in your logic for when to do things, or many other possible issues.