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

Is this a good API for 4e second wind/healing?

Hello I found this API ( <a href="https://gist.github.com/stephenhudson/8392771" rel="nofollow">https://gist.github.com/stephenhudson/8392771</a> ) that is suppose to let you use second wind or heal another target in 4e through chat. However, when I try to use it, it crashes. Hoping someone can take a look at it and figure out if its a valid API script or if something is wrong. I'm excited to possibly getting it to work, but I don't know if its me or the script thats messing up.&nbsp; Script Below:&nbsp; on("chat:message", function(msg) { if(msg.type == "api" && msg.content.toLowerCase().indexOf('!heal') !== -1) { var slice = msg.content.split(" "); //Splits the message input based off spaces. slice[0] is !Attack. var healtarget = slice[1]; var healsource = slice[2]; var curPageID = findObjs({_type: "campaign"})[0].get("playerpageid"); var toke = findObjs({_type: "character", name: healtarget})[0]; var token = findObjs({_type: "graphic", _subtype: "token", _pageid: curPageID, name: healtarget}, {caseInsensitive: true})[0]; var surgevalue = findObjs({ _type: 'attribute', name: 'surgevalue', _characterid: toke.id })[0]; var currenthpvalue = findObjs({ _type: 'attribute', name: 'HP', _characterid: toke.id })[0]; var currenthp = parseInt(currenthpvalue.get("current")); var surgevalue = parseInt(surgevalue.get("current")); var healvalue = 0 if(healsource.indexOf('Valiant') &gt;= 0) { healvalue = randomInteger(6) + surgevalue + 4; } if(healsource.indexOf('secondwind') &gt;= 0) { healvalue = surgevalue; } var totalheal = parseInt(currenthp) + parseInt(healvalue); var surges = findObjs({ _type: 'attribute', name: 'surges', _characterid: toke.id })[0]; if(parseInt(surges.get("current"))&gt;0){ currenthpvalue.set("current", totalheal); surges.set("current", parseInt(surges.get("current")) - 1); if(parseInt(currenthpvalue.get("current"))&gt;parseInt(currenthpvalue.get("max"))){ currenthpvalue.set("current", currenthpvalue.get("max")); }; if(healsource.indexOf('Valiant') &gt;= 0) { currentMsg = "/em is healed by Captain Valiant Wallamin for " + healvalue + " current hp is back up to " + currenthpvalue.get("current") + " and his surges are down to " + surges.get("current"); } if(healsource.indexOf('secondwind') &gt;= 0) { currentMsg = "/em uses their second wind for " + healvalue + " current hp is back up to " + currenthpvalue.get("current") + " and surges are down to " + surges.get("current"); token.set('status_bolt-shield'); } } else { currentMsg = "is out of surges!"; }; sendChat(healtarget, currentMsg); }; });
1475208021
Lithl
Pro
Sheet Author
API Scripter
That script is depending on the character's name containing no spaces, which is probably where the crash you're seeing is happening. Also, the only "heal another target" the script is capable of doing is surge+d6+4, and it will always say that the heal came from Captain Valiant Wallamin. I recommend you use the TokenMod script by Aaron, which is also available via one-click install. It will give you much better control.
Does it allow you to make a macro that can alter the character sheet/token bar's?
1475259947
Jakob
Sheet Author
API Scripter
DM said: Does it allow you to make a macro that can alter the character sheet/token bar's? TokenMod allows you to make macros that can change just about any property that a token has. And if you have linked bars, that will also affect your character.
For an API Script that can alter Character Attributes, I highly recommend Jakob 's ChatSetAttr !
Two great API's to check out. I am mostly going to use it for healing and such. Can't wait to dive into it. Thank you both for the suggestions