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

Using an API to change enemy health

1529056981

Edited 1529060693
I was hoping for your help oh brainy ones! I DM text only games and&nbsp;currently use a macro to confirm how much damage has been dealt after an attack... It is something like... /emas @{target|Target|token_name} takes [[?{Damage|0}]] damage! It works well, works for PC's and NPCs, as long as they have a 'Token Name'. It's quick and I'm happy with it. However, I then manually have to go in and edit the health of the monster accordingly. Would anyone be able to help me so that when I use my 'XXX takes damage', the same number is then removed from 'Bar 1' from the selected token. I use the fancy !Setattr API which works very well, for a few other things, such as refreshing players resources and quickly 'giving/taking' players gold/silver but I'm not sure if what I want do is feasible in there? HOWEVER, since, like many people, I'll commonly have 10 Monsters (e.g. Goblins) working from the same character sheet. So what I can't do, is change the 'character HP', or it will probably change all matching tokens at once. EDIT:&nbsp; Hey... I'm getting closer! I've found that I can use the !token-mod API and then using the code.... !token-mod --set bar1_value|-10 This reduces 10 from the value in Bar1. I can then learn from this and use... !token-mod --set bar1_value|-?{How much damage|0} This will ask me for a prompt, where I could type in '10' to the box. If the token 'dies', by going below 0hp, the bar starts to then go backwards into negative figures! However, I've figured that I can stop this using an API suggested here: <a href="https://app.roll20.net/forum/permalink/4766020/My" rel="nofollow">https://app.roll20.net/forum/permalink/4766020/My</a> challenge now though, is that I want to ALSO use the ' Bloodied and Dead Status Markers ' API but I don't think that the system is detecting that the value in the Bar1 has changed, so is not running it's 'check' and then marking the 'X/Death' symbol accordingly. Any ideas? Any help would really be appreciated. - Thanks!
1529063911
GiGs
Pro
Sheet Author
API Scripter
The reason this doesnt work, is scripts cant respond to changes caused by other scripts. It's possible to edit scripts so they can communicate with each other. Hopefully Aaron iwll be along to tell you how to edit this script to work with TokenMod.
1529064083

Edited 1529064377
Thanks :) - That really helps! Well. If it helps - I'm not where I grabbed it from, but my 'Dead status Marker' API is a lot smaller and less complicated than what looks like the official one. I have no idea where I grabbed it from: on("change:graphic", function(obj) { if(obj.get("bar1_max") === "") return; if(obj.get("bar1_value") &lt;= 0) { obj.set({ status_dead: true }); } else { obj.set({ status_dead: false }); } });
1529073359
The Aaron
Pro
API Scripter
I responded here:&nbsp; <a href="https://app.roll20.net/forum/permalink/6489086/" rel="nofollow">https://app.roll20.net/forum/permalink/6489086/</a> =D