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

Token Statusmarker query

Is there a way to query the Token to get the Statusmarkers currently applied? I looked at Token-Mod but there looks to only be Set actions and no Get actions.
1608767097
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It does have a report option. I haven't tested, but maybe if you made a non-change change (like changing the name to what it already is) you could get a report of the status of the token markers before?
Thanks. Not sure that will give me what I am looking for. I have a macro that sets a marker for an npc that has been Hexed.... I was hoping to be able to query that in order to apply Hex damage instead of prompting the pc if they want to apply the extra damage.
1608775628

Edited 1608775694
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ah, performing an action on the token marker status would likely require a separate API script. polling the status alone wouldn't be able to dictate a course of action, since regular macros do not have branching logic. Since you have a macro that can set the token marker, I assume this is in a game with the API. You might look into toggling a modifier (maybe with a query attached—I can't remember offhand if Global Damage Modifiers accept queries or are integer-only—I suspect the latter.) on or off when you set that token marker.
I actually just wrote this last night for the exact same thing (I was working with TokenMod and wanted to be able to pull all status markers currently assigned). It's quick and dirty, but works for what I need it for. With a token selected, run `!getconditions` on("ready", () => {     const getChatMessageFromTokenMarkers = (tokenname, markers) => {         tokenname = tokenname || "Player";         let chatMessage = '/w GM <p><b>' + tokenname + '</b> is currently:<br>';         if (markers.length == 0) {             chatMessage += "just fine!";         } else {             _.each(markers, marker => {                 let status = marker.split("::")[0];                 let status_value = marker.split("@")[1];                 chatMessage += status + " ";                 chatMessage += status_value || "";                 chatMessage += "<br>";             });         }         return chatMessage + "</p>";     };     on("chat:message", msg => {         if(msg.type == "api" && playerIsGM(msg.playerid)) {             if(msg.content.split(" ")[0].toLowerCase() === '!getconditions') {                 if (!msg.selected) return;                 if (msg.selected[0]._type !== "graphic") return;                 obj = getObj(msg.selected[0]._type, msg.selected[0]._id);                 currentMarkers = obj.get("statusmarkers");                 currentMarkers = (currentMarkers.length == 0) ? [] : currentMarkers.split(",");                 let chatMessage = getChatMessageFromTokenMarkers(obj.get("name"), currentMarkers);                 sendChat("Token Markers", chatMessage);             }         }     }); });
I just re-read your 2nd reply Eric. While not exactly what you're looking for, I think you could still take the script I wrote above and modify it based on the status token applied and then do any calculations necessary and apply it to the token. For reference, take a look at this URL (this is what I started my script from)  API:Token Markers
Thanks Keith and Mark. I will try out the script and let you know how it goes.
Mark, That is a good start. If I were to use it in conjunction with PowerCards, would it give me the list for @{target|target_id}? I'm not a java developer so I'm not confident in making possible changes like that.
I haven't used PowerCards before. I'll test it out and see what I can come up with. I'm pretty sure you can, but I'm just getting into writing API scripts myself so I'm not wholly familiar with everything just yet. Just to make sure I'm understanding what you're asking, you want to run the command and then have the "Select target" screen come up and click on the token you want to get conditions for?
Hi Mark, let me see if I can explain the use case.  1. Player casts spell such as Hex on NPC token 2. Spell applies Statusmarker to NPC token via !token-mod 3. Round moves on then comes back to Player on next round 4. Player attacks NPC with Statusmarker applied. 5. Attack macro, checks if Statusmarker is applied. 6. Finding statusmarker, attack macro applies extra damage to NPC. I think that is the flow I am envisioning. I just happen to be using PowerCards because you can use If-Else logic with it but the main goal would be to be able to check what statusmarker has been applied via a macro. In my specific case I am working on it happens to be the Hex spell which I am applying a statusmarker to the NPC.