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 :)