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

Input Please... Front End Loading Power Cards from an Array of Spells

1408659108
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Before Wesley L . and I go too far down the path.... We have spells in an array... example: {Call: "cure_wounds", Name: "Cure Wounds", Class: "Bard,Cleric,Druid,Paladin,Ranger", SubClass: "Life Domain", Ritual: "N", Concentration: "N", Level: "1", School: "Evocation", Component: "V,S", Material: "", Range: "Touch", CastingTime: "1 action", Duration: "Instantaneous", Description: "A creature I touch regains a number of hit points equal to 1d8 + my spellcasting ability modifier. This spell has no effect on undead or constructs.", HigherLevel: ""}, Lots of useful things can be done with that..... But one thing is to make a Power Card macro that looks like this: !power --name|Cure Wounds --ddn --desc| --txcolor|#fff --bgcolor|white --leftsub|1 Action --rightsub|Range 5 feet --1st Level|Evocation --Components|V, S --Duration|Instantaneous --Effect|I touch @{target|token_name}. They regain [[?{modifier|1}d8+3+@{wisdom_mod}]] hit points. --text|This spell has no effect on undead or constructs. --Higher Level|When I cast this spell using a spell slot of 2nd level or higher, the healing increases by 1d8 for each slot level above 1st. And reduce it to this: !cast cure_wounds --Effect|I touch @{target|token_name}. They regain [[?{modifier|1}d8+3+@{wisdom_mod}]] hit points. --text|This spell has no effect on undead or constructs. All the spell information is Power Card formatted in a standard way before being sent to Badgers PC script... also no modification to the PC script is needed. Also.... the API command of just "!cast cure_wounds" give just the spell information in PC format. Two examples... First is "!cast cure_wounds" with "--Effect|" information (or any PC information)... second is just "!cast cure_wounds" We are really just kicking this around and have 93 spells so far... but want to think this through before taking it any further.... Really bad code example below to just get it working: cast = function(msg) { if(msg.content.indexOf(' ') == -1){ var msgMessage = null; var msgApiCommand = msg.content.substr(1, msg.content.length); return; }else{ var msgMessage = msg.content.substr(msg.content.indexOf(' ') + 1); var msgApiCommand = msg.content.substr(1, msg.content.indexOf(' ')-1); }; if(msgMessage.indexOf(' ') == -1){ var msgAttack = "None"; var msgSpell = msgMessage; }else{ var msgSpell = msgMessage.substr(0, msgMessage.indexOf(' ')); var msgAttack = msgMessage.substr(msgMessage.indexOf(' ') + 1); }; if(msgAttack == "None"){ _.each(roll20API.spelllist, function(indexCommands) { if(indexCommands.Call == msgSpell){ var spellName = indexCommands.Name var spellLevel = indexCommands.Level var spellRitual = indexCommands.Ritual var spellSchool = indexCommands.School var spellName = indexCommands.Name var spellComponent = indexCommands.Component var spellMaterial = indexCommands.Material var spellRange = indexCommands.Range var spellCastingTime = indexCommands.CastingTime var spellDuration = indexCommands.Duration var spellDescription = indexCommands.Description if(spellLevel == "0"){spellLevel = "Cantrip"}; if(spellLevel == "1"){spellLevel = "1st Level"}; if(spellLevel == "2"){spellLevel = "2nd Level"}; if(spellLevel == "3"){spellLevel = "3rd Level"}; if(spellLevel.length == 1){spellLevel += "th Level"}; var CastString = " " CastString += "--name|" + spellName + " " CastString += "--desc| --bgcolor|#1c4587 --txcolor|#FFF " CastString += "--leftsub|" + spellCastingTime + " " CastString += "--rightsub|" + spellRange + " " CastString += "--" + spellLevel + "|" + spellSchool + " " CastString += "--Components|" + spellComponent + " " CastString += "--Duration|" + spellDuration + " " CastString += "--Description|" + spellDescription msg.content = CastString PowerCardScript.Process(msg); return; }; }); }; if(msgAttack != "None"){ _.each(roll20API.spelllist, function(indexCommands) { if(indexCommands.Call == msgSpell){ sendChat("API", "Test"); var spellName = indexCommands.Name var spellLevel = indexCommands.Level var spellRitual = indexCommands.Ritual var spellSchool = indexCommands.School var spellName = indexCommands.Name var spellComponent = indexCommands.Component var spellMaterial = indexCommands.Material var spellRange = indexCommands.Range var spellCastingTime = indexCommands.CastingTime var spellDuration = indexCommands.Duration var spellDescription = indexCommands.Description if(spellLevel == "0"){spellLevel = "Cantrip"}; if(spellLevel == "1"){spellLevel = "1st Level"}; if(spellLevel == "2"){spellLevel = "2nd Level"}; if(spellLevel == "3"){spellLevel = "3rd Level"}; if(spellLevel.length == 1){spellLevel += "th Level"}; var CastString = " " CastString += "--name|" + spellName + " " CastString += "--desc| --bgcolor|#1c4587 --txcolor|#FFF " CastString += "--leftsub|" + spellCastingTime + " " CastString += "--rightsub|" + spellRange + " " CastString += "--" + spellLevel + "|" + spellSchool + " " CastString += "--Components|" + spellComponent + " " CastString += "--Duration|" + spellDuration + " " CastString += "--Description|" + spellDescription msg.content = CastString + " " + msgAttack log(msg.content) PowerCardScript.Process(msg); return; }; }); }; }; Main idea is to feed the Power Cards script (without modification) from an Array of Spells to reduce macro typing. Right path? Wrong path? Better way? No way?
1408674602
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
spells = function(msg) { if (msg.type != "api") return; if(msg.content.indexOf(' ') == -1){ var msgMessage = null; var msgApiCommand = msg.content.substr(1, msg.content.length); }else{ var msgMessage = msg.content.substr(msg.content.indexOf(' ') + 1); var msgApiCommand = msg.content.substr(1, msg.content.indexOf(' ')-1); }; if(msgMessage == null){ var textSent = "/direct <hr><b>Spell Library Commands</b>\ <ul>\ <li>!spells bard</li>\ <li>!spells cleric</li>\ <li>!spells druid</li>\ <li>!spells paladin</li>\ <li>!spells ranger</li>\ <li>!spells sorcerer</li>\ <li>!spells warlock</li>\ <li>!spells wizard</li>\ <li>!spells [a-z] (i.e. !spells a)</li>\ <li>!spells [0-9] (i.e. !spells 1)</li>\ <li>!spells abjuration</li>\ <li>!spells conjuration</li>\ <li>!spells divination</li>\ <li>!spells enchantment</li>\ <li>!spells evocation</li>\ <li>!spells illusion</li>\ <li>!spells necromancy</li>\ <li>!spells transmutation</li>\ </ul>" sendChat("API", textSent); return; } if(msgMessage != null){ var string = "/direct <hr><b>Spell List</b> (" + msgMessage + ")<ul>"; _.each(roll20API.spelllist, function(indexCommands) { var spellClass = indexCommands.Class.toLowerCase(); if(spellClass.indexOf(msgMessage) != -1 && msgMessage.length > 1){ string = string + "<li>" + indexCommands.Call + "</li>"; }; var spellLevel = indexCommands.Level.toLowerCase(); if(spellLevel == msgMessage && msgMessage.length == 1){ string = string + "<li>" + indexCommands.Call + "</li>"; }; var spellCall = indexCommands.Call.toLowerCase(); log(spellCall.charAt(0) + "-" + msgMessage) if (spellCall.charAt(0) == msgMessage && msgMessage.length == 1){ string = string + "<li>*" + indexCommands.Call + "</li>"; }; var spellSchool = indexCommands.School.toLowerCase(); if(spellSchool == msgMessage && msgMessage.length > 1){ string = string + "<li>" + indexCommands.Call + "</li>"; }; }); }; sendChat("API", string + "</ul>"); };
1408674670
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
So did a little interface to look up spells.... But it got me thinking... has anyone done a lightweight SQLish API command for a largish array?
Looks good, but this might run afoul of the api limitations discussed in this thread: <a href="https://app.roll20.net/forum/post/1014870/important-api-changes" rel="nofollow">https://app.roll20.net/forum/post/1014870/important-api-changes</a>
1408693342

Edited 1408693397
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
I considered that..... one reason we haven't shared the array. But.... right now... 1) No use of state, in any code. 2) Under 400 item array, and not that wide of an array. 3) With everything we have, including all scripts, we are likely under 1,400 lines of code. Trying to put together really efficient 5E API. 1) Power Cards ~ HB 2) Token Marker ~ BK 3) Spell Array ~ WL 4) Record Sheet ~ Actoba That is about it.... by would really like any use of that array to be really efficient.
1408850327
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
API question... can you add repeating entries to a record sheet with API? Then I can just "add" spell with API to a sheet and its even less of an impact on server resource (once for each spell add.. and normal macro's after that.)
1408884458
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
After looking over Kevin's work..... been looking at that 5E sheet... { "name":"repeating_spellbookcantrip_0_spellname", "current":"Spell NameC1", "max":"", "_id":"-JV449looVIO2oFE9s9Z", "_type":"attribute", "_characterid":"-JUa8waurTJ6Wc3PIfqA" }, Full list of spell attributes... "name":"repeating_spellbookcantrip_0_spellname", "name":"repeating_spellbookcantrip_0_spellgainedfrom", "name":"repeating_spellbookcantrip_0_spellschool", "name":"repeating_spellbookcantrip_0_spellconcentration", "name":"repeating_spellbookcantrip_0_spellritual", "name":"repeating_spellbookcantrip_0_spellisprepared", "name":"repeating_spellbookcantrip_0_spelltypeadvanced", "name":"repeating_spellbookcantrip_0_spelltypeattack", "name":"repeating_spellbookcantrip_0_spellcasttime", "name":"repeating_spellbookcantrip_0_spelltarget", "name":"repeating_spellbookcantrip_0_spellrange", "name":"repeating_spellbookcantrip_0_spellduration", "name":"repeating_spellbookcantrip_0_spellcomponents", "name":"repeating_spellbookcantrip_0_spelldescription", "name":"repeating_spellbookcantrip_0_spellhighersloteffect", "name":"repeating_spellbookcantrip_0_attackstat", For the spells we have (cantrip through 1st level right now... which is about 25% of the spells) in a xls file...which we can turn into this quickly... { Call:"acid_splash", Name:"Acid Splash", Class:"Sorcerer,Wizard", SubClass:"", Ritual:"N", Concentration:"N", Level:"0", School:"Conjuration", Component:"V,S", Material:"", Range:"60 feet", CastingTime:"1 action", Duration:"Instantaneous", Description:"I hurl a bubble of acid. Choose one creature within range, or choose two creatures within range that are within 5 feet of each other. A target must succeed on a Dexterity saving throw or take 1d6 acid damage.", HigherLevel:"This spell's damage increases by 1d6 when I reach 5th level (2d6), 11th level (3d6), and 17th level (4d6).", Effect:"I hurl a bubble of acid at @{target|t1|token_name}, and @{target|t2|token_name} who is within 5 feet. --texta|They must succeed on a **Dexterity saving throw** vs. [[8+@{selected|spellcastingability}+@{selected|PB}]]. --Failed Save|the creature takes [[1d6+{floor((@{characterlevel})/5),1}kl1*1d6+{floor((@{characterlevel})/11),1}kl1*1d6+{floor((@{characterlevel})/17),1}kl1*1d6]] acid damage." } I think the best approach would be to consistently add spells to players and NPCs through API. !addspell spellname charactername Puts in the record sheet and makes a powercard formated macro. or something...
1408988047
The Aaron
Roll20 Production Team
API Scripter
Sounds awesome!