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

5E OGL Companion API Spell Tracking Not Working

I am unable to get spell tracking working. I have ammo tracking working beautifully but spell tracking and !longrest do nothing. I click the spell as the GM to test it: The spell slot isn't used. You can also seen in the spells tab this:
Just wondering, did you input Burning Hands manually or through the Compendium?
Its dragged and dropped from the Compendium. 
Am I the only one who has seen this issue. I even created a new game to test this out and am getting the same?
1501106331

Edited 1501106410
I have not run into this problem myself, but I want to try something out if you'll let me. I have this add-on to the companion script that will decrement the number of spell slots remaining rather than count up to the limit of spells per day. Would you add this as an additional script (after the companion script has been added to the game), and see if your spell slots and longrest work as expected (minus the change of decrementing the number of spells left instead of increasing the number of spells expended). Here is the script. var resolveslot = function(msg,character,player,spellslot) { log("Overwrote resolveslot"); var charslot = findObjs({type: 'attribute', characterid: character.id, name: "lvl" + spellslot + "_slots_expended"}, {caseInsensitive: true})[0]; if(!charslot) { charslot = createObj("attribute", {name: "lvl" + spellslot + "_slots_expended", current: "0", max: "", characterid: character.id}); //var charslot = findObjs({type: 'attribute', characterid: character.id, name: "lvl" + spellslot + "_slots_expended"}, {caseInsensitive: true})[0]; } var charslotmax = findObjs({type: 'attribute', characterid: character.id, name: "lvl" + spellslot + "_slots_total"}, {caseInsensitive: true})[0]; if(!charslotmax) { charslotmax = createObj("attribute", {name: "lvl" + spellslot + "_slots_total", current: "0", max: "", characterid: character.id}); //var charslotmax = findObjs({type: 'attribute', characterid: character.id, name: "lvl" + spellslot + "_slots_total"}, {caseInsensitive: true})[0]; } var max = charslotmax.get("current"); var remain = parseInt(charslot.get("current"), 10) - 1; charslot.set({current:remain}); var output = "SPELL SLOT LEVEL " + spellslot + ":\n" + (remain >= 0 ? remain + " LEFT" : "<span style='color:red'>ALL SLOTS EXPENDED</span>"); var formattedOutput = (getAttrByName(character.id, "wtype") === "" ? "" : "/w gm ") + "&{template:desc} {{desc=" + output + "}}"; if(state.FifthEditionOGLbyRoll20.spelltracking != "quiet") { sendChat(msg.who, formattedOutput); } } var longrest = function(msg) { log("Overwrote longrest"); charname = msg.content.substring(msg.content.indexOf(" ") + 1); var character = findObjs({name: charname, type: "character"}, {caseInsensitive: true})[0]; if(!character) { log("NO CHARACTER BY THAT NAME FOUND"); } else { var spellslots = filterObjs(function(obj) { if(obj.get("type") && obj.get("type") === "attribute" && obj.get("name") && obj.get("name").indexOf("expended") > -1) { return true; } else { return false; } }); _.each(spellslots, function(obj) { var spellSlotMaxName = obj.get("name").replace("expended", "total"); var charslotmax = findObjs({type: 'attribute', characterid: character.id, name: obj.get("name").replace("expended", "total")}, {caseInsensitive: true})[0]; obj.set({current: charslotmax ? charslotmax.get("current") : 0}); }); var maxhp = getAttrByName(character.id, "hp", "max"); var hp = findObjs({type: 'attribute', characterid: character.id, name: "hp"}, {caseInsensitive: true})[0]; if(hp && maxhp) { hp.set({current: maxhp}); } } }
What I am looking for is that not only will the game chat show the number of remaining spell slots, but the API console should show 'Overwrote resolveslot' and 'Overwrote longrest' depending on what you tried to do.
1501112514

Edited 1501112601
So I took my character and deleted the sheet and all of a sudden it works for that character. So I took another one and tried the same things over again and it didn't work, but this time with arrows. I have 2 characters now where api is working (one with arrow, one with spells). It seems to be hit or miss when you create a character sheet. I am going to try the script you sent will report back.
Not sure if this helps. But I fixed that other character. I added your script it worked for spells but I really just wanted to stick with the original script. So I removed yours again. Restarted the sanbox and boom character working. So I am wondering if people face this in the future if restarting sandbox or something will work.
That is strange, I'm glad you got it working. If you need further help with the Companion script, feel free to PM me.