ok first thing is first. This code is a modified version of Nick Olivo's Customspellbook code and all the code for functions Magic Missile and Scorching Ray (as well as the custom spell book) are his. Any changes to accommodate Cure wounds, inflict wounds, healing word and now Spiritual Hammer are mine. When I run: on("chat:message", function(msg)
{
if (msg.type == "api" && msg.content.indexOf("!customPrayers") == 0){
var args = msg.content.split(/\s+/);
var spellName = args[1].toLowerCase();
var spellLevel = Number(args[2]);
var tokenid = msg.selected[0]._id;
var token = getObj("graphic",tokenid);
var charID = token.get("represents");
var tokenName = token.get("name");
switch(spellName){
case "curewoundsdl":
CureWoundsDL(spellLevel,tokenName);
break;
case "healingworddl":
HealingWordDL(spellLevel,tokenName);
break;
case "inflictwounds":
InflictWounds(spellLevel,tokenName);
break;
case "spiritualweapon":
SpiritualWeapon(spellLevel,tokenName);
break;
}
sendChat("API",`!modbattr --charid ${charID} --lvl${spellLevel}_slots_expended|-1`);
}
});
function CureWoundsDL(spellLevel,tokenName){
var HealOutput="";
HealOutput+=`{{Healing=[[${spellLevel}d8+@{${tokenName}|Wisdom_mod}+(2+${spellLevel})]]}}`;
var outputMessage = `&{template:default} {{name=Cure Wounds - Disciple of Life}} ${HealOutput}`;
sendChat("API",outputMessage);
}
function HealingWordDL(spellLevel,tokenName){
var HealOutput="";
HealOutput+=`{{Healing=[[${spellLevel}d4+@{${tokenName}|Wisdom_mod}+2+${spellLevel}]]}}`;
var outputMessage = `&{template:default} {{name=Healing Word - Disciple of Life}} ${HealOutput}`;
sendChat("API",outputMessage);
}
function InflictWounds(spellLevel,tokenName){
var DmgOutput = "";
DmgOutput+=`{{Attack [[1d20+@{${tokenName}|spell_attack_bonus} ]] for [[(2+${spellLevel})d10]] Necrotic Damage}}`;
var outputMessage = `&{template:default} {{name=Inflict Wounds}} ${DmgOutput}`;
sendChat("API",outputMessage);
}
function SpiritualWeapon(spellLevel,tokenName){
var DmgOutput = "";
/* DmgOutput+=`{{Attack [[1d20+@{${tokenName}|spell_attack_bonus} ]] ` +
`for [[1d8 + @{selected|spellcasting_modifier}]] + [[{floor(?{Cast as Level|2}/2)-1,0}kh1]]d8 Force Damage}}`;*/
DmgOutput+=`{{Attack [[1d20+@{${tokenName}|spell_attack_bonus} ]] ` +
`for [[1d8 + @{selected|spellcasting_modifier}]] + [[1d8]] Force Damage}}`;
var outputMessage = `&{template:default} {{name=Spiritual Weapon}} ${DmgOutput}`;
sendChat("API",outputMessage);
log(outputMessage);
} I get the following in the log: "ERROR: Unable to find character selected in chat command."
"Error
at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:158:1), <anonymous>:637:11)
at String.replace (<anonymous>)
at Object.d20.textchat.doChatInput (eval at <anonymous> (/home/node/d20-api-server/api.js:158:1), <anonymous>:549:29)
at sendChat (/home/node/d20-api-server/api.js:1815:16)
at SpiritualWeapon (apiscript.js:25161:5)
at apiscript.js:25126:17
at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16)
at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8)
at /home/node/d20-api-server/api.js:1661:12
at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560"
"&{template:default} {{name=Spiritual Weapon}} {{Attack [[1d20+@{Sam Pippin|spell_attack_bonus} ]] for [[1d8 + @{selected|spellcasting_modifier}]] + [[1d8]] Force Damage}}" When the Spiritual Hammer function is changed to this: function SpiritualWeapon(spellLevel,tokenName){
var DmgOutput = "";
DmgOutput+=`{{Attack [[1d20+@{${tokenName}|spell_attack_bonus} ]] ` +
`for [[1d8 + @{selected|spellcasting_modifier}]] + [[{floor(?{Cast as Level|2}/2)-1,0}kh1]]d8 Force Damage}}`;
/* DmgOutput+=`{{Attack [[1d20+@{${tokenName}|spell_attack_bonus} ]] ` +
`for [[1d8 + @{selected|spellcasting_modifier}]] + [[1d8]] Force Damage}}`;*/
var outputMessage = `&{template:default} {{name=Spiritual Weapon}} ${DmgOutput}`;
sendChat("API",outputMessage);
log(outputMessage); I get the following output: "ERROR: Unable to find character selected in chat command."
"Error
at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:158:1), <anonymous>:637:11)
at String.replace (<anonymous>)
at Object.d20.textchat.doChatInput (eval at <anonymous> (/home/node/d20-api-server/api.js:158:1), <anonymous>:549:29)
at sendChat (/home/node/d20-api-server/api.js:1815:16)
at SpiritualWeapon (apiscript.js:25161:5)
at apiscript.js:25126:17
at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16)
at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8)
at /home/node/d20-api-server/api.js:1661:12
at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560"
SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "?" found.
undefined Also the following shows up in a red box above the output log: Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your script's code and click the "Save Script" button. We will then attempt to start running the scripts again. More info... If this script was installed from the Script Library, you might find help in the Community API Forum. For reference, the error message generated was: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "?" found.
undefined