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

changing Code for new affect

Nick Olivo wrote the following code: on("chat:message", function(msg) {     if (msg.type == "api" && msg.content.indexOf("!customSpellbook") == 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 "magicmissile":                 magicMissile(spellLevel);                 break;             case "scorchingray":                 scorchingRay(spellLevel,tokenName);                 break;         }         sendChat("API",`!modbattr --charid ${charID} --lvl${spellLevel}_slots_expended|-1`);     } }); function magicMissile(spellLevel){     var numberOfDarts = spellLevel + 2;     var dartOutput = "";     for(counter=1;counter<=numberOfDarts;counter++){         dartOutput+=`{{Dart ${counter} = [[1d4+1]]}}`;     }     var outputMessage = `&{template:default} {{name=Magic Missile}} ${dartOutput}`;     sendChat("API",outputMessage); } function scorchingRay(spellLevel,tokenName){     var numberOfRays = 3 + (spellLevel-2);     var rayOutput = "";     if(spellLevel<2){         sendChat("CustomSpellbook","Scorching Ray requires at least a level 2 spell slot");         return;     }     for (counter=1;counter<=numberOfRays;counter++){         rayOutput+=`{{Ray ${counter} Attack [[1d20+@{${tokenName}|spell_attack_bonus} ]]=[[2d6]] Fire Damage}}`;     }     var outputMessage = `&{template:default} {{name=Scorching Ray}} ${rayOutput}`;     sendChat("API",outputMessage); } I am trying to add a spell to this custom spell book.  I am trying to add Cure Wounds with the disciple of life modifier.  I have added the function and the appropriate case to his code.  It is not working. Any ideas? CASE added under the switch section             case "CureWoundsDL":                 CureWoundsDL(spellLevel);                 break; this function added at the end of his code: function CureWoundsDL(spellLevel){     var HealOutput="";     HealOutput+=`{{Healing=[[${spellLevel}d8+2+${spellLevel}]]}}`;     var outputMessage = `&{template:default} {{name=Cure Wounds - Disciple of Life}} ${HealOutput}`;     sendChat("API",outputMessage); }
1597461855

Edited 1597462127
The Aaron
Roll20 Production Team
API Scripter
The case label needs to be lowercase:             case "curewoundsdl":
The Aaron said: The case label needs to be lowercase:             case "curewoundsdl": That did it.  Just for future reference, why does it have to be lower case? Thanks,
1597506834
The Aaron
Roll20 Production Team
API Scripter
This line in the code forces it to lowercase:         var spellName = args[1].toLowerCase(); That's a common practice for human entered values, to make it easier on them. 
Oh ok.  I thought that line was like VBA LCASE(text here) that way regardless of how it is written else where you could compare it to a lowercase string variable. Last question.  How do I reference the wisdom modifier to add it to the healing formula? Thanks a ton Aaron.  
1597540751

Edited 1597540776
Oosh
Sheet Author
API Scripter
The Aaron said: That's a common practice for human entered values, to make it easier on them.  Them?? I knew it!