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

Spell slots - can they decrement instead of increment? (OGL 5e DnD)

Hi! I've had a search around, can't seem to find my specific question, but my apologies if this is a failure in common sense! I'm using the 5th edition OGL script and nothing else. I have two players with spells and spell slots. The display reads[4] [0] and when they cast a spell, it increments that count by 1, while outputting correctly into the chat box (SPELL SLOT LEVEL 1, 4 OF 4 EXPENDED). This leads to some confusion - when they look at the chat log, it tells them how many they have left, but looking at their character sheet they might see [4] [3] and think they have three left, when it fact they have one left. Is there any way to set the spell slot tracker so that it decrements rather than increments?
The Shaped sheet decrements.  Might be better to post the question in the OGL sheet thread?
Not with the current implementation of the companion script.You could achieve the functionality with a separate script that will copy the original with the added change for decrementing spell slots. If this sounds like something you would want, let me know. I don't think it would take to long to do. It's a simple change really.
I would also like to know how to accomplish this.
1498609755

Edited 1498609894
Here you go, this script will override the functions used in the 5th Edition OGL Companion script to make the spell slot tracking decrement rather than increment. To use this, you should add this as a new script AFTER adding the 5th Edition OGL by Roll20 Companion script. var resolveslot = function(msg,character,player,spellslot) {     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) {     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});         }     } }
Kyle G. said: Here you go, this script will override the functions used in the 5th Edition OGL Companion script to make the spell slot tracking decrement rather than increment. To use this, you should add this as a new script AFTER adding the 5th Edition OGL by Roll20 Companion script. var resolveslot = function(msg,character,player,spellslot) {     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) {     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});         }     } } Thank you :D I will plug it in and give it a whirl! My apologies for not replying sooner, our game went on summer hiatus :)