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

[Script] Spellbook generator for Pathfinder character sheet

1457025775

Edited 1457025954
James W.
Sheet Author
API Scripter
Julix posted an example macro in the Pathfinder character sheet thread that would put a template into the chat window with buttons for all of your character's spells; since we just had a player ask for help in getting it to work, I wrote an API script to generate the macro automatically. The usage is pretty simple: select a token, then use the "!generate-spellbook" API command. You can give it two optional parameters, separated by spaces. In order, they are: Spell class to generate the macro for. This is just the class number, as it appears in the Spells tab. This defaults to -1, which will include all spells. Name of the character ability to put the macro in; defaults to "Spells". If the character already has an ability with that name, Because I'm a lazy bastard, you can't specify the ability name without also specifying the spell class. To generate a spellbook for the class you have as spell class 0, with the default ability name: !generate-spellbook 0 To generate a spellbook for all classes in an ability called "Spellbook": !generate-spellbook -1 Spellbook Hope someone finds this useful!
1457029443
The Aaron
Pro
API Scripter
Cool!
1457122774
James W.
Sheet Author
API Scripter
Updated the script to add a third optional parameter: the title to use at the top of the template. To generate a spell for spell class 0, with an ability name of "Formulas", and a template title of "Extracts": !generate-spellbook 0 Formulas Extracts Also eliminated some unused variables that came over from the code I used as a base, and switched from using the row_id attributes to the name attributes when building the array of spells, as the row_id attributes isn't actually generated unless you expand the "IDs" section of the spell; it also let me eliminate a check when building the spell level arrays.
1457483439

Edited 1457483469
Added this script to my Iron Gods game. Really liked the ease of use of it, yet I had an odd error come up. The magus worked pretty fine, yet for some odd reason our goblin wizard came out like this. I deleted the macro and recreated it, same problem. I can't find any obvious errors in his spell list either.
1457483537

Edited 1457486168
James W.
Sheet Author
API Scripter
Try specifying a spellclass ("!generate-spellbook 0"). EDIT: Also, I just posted the latest version I created to help with exactly this issue, so try that, too. :D
I had success with this for the first charactor I tried in on, but for the other charactors in my campaign I recieved the following error. "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_0_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_1_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_2_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_3_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_4_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_5_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_6_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_7_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_8_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_9_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_10_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_11_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_12_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_13_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_14_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_15_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_16_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_17_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_18_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_19_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_0_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_1_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_2_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_3_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_4_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_5_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_6_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_7_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_2_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_0_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_1_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_3_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_0_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_1_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_4_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_5_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_8_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_2_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_3_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_4_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_5_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-4-spells_0_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-4-spells_1_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_-K6pSlZQwZcXXCrQ1lUf_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_-K6pTb0BRji1CUNEQiLT_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_-K6pUe-Z50ldwuUhvcFd_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_-K6pVXFm2t-Z8JdQCQjO_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_-K6pWH6fxzoWmTNyZeEx_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-2-spells_-K6pX6HgeFm-h-3w0M-r_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_-K6pXxsWOHlk50m67uMs_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_-K6pbdUOCxLmeVJ4pk11_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-4-spells_-K6pk4cWBYrBvHt5XnX4_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-4-spells_-K6plvaeKb-ZrK859DAv_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_-K9ZrIT3O9yKUnXRxqB0_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-4-spells_-K9Zu8i2QUtpeL5Mf4K8_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-3-spells_-KCNtt0mnsm8aaNhaDqS_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_0_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_0_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_1_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_2_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-1-spells_1_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_3_spellclass" "Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-0-spells_4_spellclass" I have had limited success after clicking the recalc checkbox on the charactor sheet.  Sometimes it works, but usually not.  Any ideas I can try?  my version of the API is current as of this post.
1458017110
James W.
Sheet Author
API Scripter
Those error messages are actually pretty normal; getAttrByName generates them when you try to look up an attribute that hasn't actually been created yet.  In this case, it looks like the character (or characters) in question have a bunch of spells where they left the spellclass as the default, which would mean that the attribute hasn't been created.  These errors shouldn't interfere with how the script functions; when this happens with the spellclass attribute, it's set to assume the spell belongs to spellclass 0, and when this happens with the name attribute, it's because the script is checking for bad spell entries. I've updated the script slightly so that it should only generate these messages if you actually specify a spellclass filter.  That said, is the script actually generating a spellbook for these characters, despite the error messages?
I'm not getting a spellbook generated most of the time.  After trying multiple times for each charactor, I've finally got spellbooks generated for 2 of 4 charactors.
Hey just notice that api is crashing when ever i use this script, is there something wrong with it? error: Unexpected string
/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ ReferenceError: spellclass is not defined at evalmachine.<anonymous>:4580:9 at Array.forEach (native) at evalmachine.<anonymous>:4578:11 at Function._.each._.forEach (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:153:9) at evalmachine.<anonymous>:4541:11 at eval (
1461209640
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
James W. said: Those error messages are actually pretty normal; getAttrByName generates them when you try to look up an attribute that hasn't actually been created yet.  In this case, it looks like the character (or characters) in question have a bunch of spells where they left the spellclass as the default, which would mean that the attribute hasn't been created.  These errors shouldn't interfere with how the script functions; when this happens with the spellclass attribute, it's set to assume the spell belongs to spellclass 0, and when this happens with the name attribute, it's because the script is checking for bad spell entries. I've updated the script slightly so that it should only generate these messages if you actually specify a spellclass filter.  That said, is the script actually generating a spellbook for these characters, despite the error messages? Since they are crashing the script (can confirm that it crashes with, I believe, all fields updated) I would say (keeping in mind that I am myself new to javascript) that this is not a normal thing.
1461282980
James W.
Sheet Author
API Scripter
Scott C. said: James W. said: Those error messages are actually pretty normal; getAttrByName generates them when you try to look up an attribute that hasn't actually been created yet.  In this case, it looks like the character (or characters) in question have a bunch of spells where they left the spellclass as the default, which would mean that the attribute hasn't been created.  These errors shouldn't interfere with how the script functions; when this happens with the spellclass attribute, it's set to assume the spell belongs to spellclass 0, and when this happens with the name attribute, it's because the script is checking for bad spell entries. I've updated the script slightly so that it should only generate these messages if you actually specify a spellclass filter.  That said, is the script actually generating a spellbook for these characters, despite the error messages? Since they are crashing the script (can confirm that it crashes with, I believe, all fields updated) I would say (keeping in mind that I am myself new to javascript) that this is not a normal thing. Those messages absolutely will NOT crash the script; if they did, it certainly wouldn't happen after a dozen or more of them.  If the script is crashing, it's something that's not giving you an error message, which I've seen happen more than once. That said, I'm not likely to work on fixing this any time soon, as I'm working on other things, and I'm going to pretty much have to almost completely rewrite this anyways, what with the character sheet consolidating the spells section into a single list.  I'll update it, it just won't be particularly soon.
1461329102
chris b.
Pro
Sheet Author
API Scripter
'Error: No attribute or sheet field found for character_id -Jhu0cSv6tw19xArGFMt named repeating_lvl-4-spells_0_spellclass" for each of these try changing the class on the spell to 1 or 2 then changing it back.to 0. that will force it to set the class. ("spellclass" is the dropdown on the current spell row). after doing that for all spells on a problem character sheet try again.