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] D&D 5e Shaped NPC & Spell Importer

1435654088

Edited 1435654113
DXWarlock
Sheet Author
API Scripter
Just as a note to that, I didn't read all the responses if it was mentioned forgive me. It works great with the DMDNDBasicRules pdf also, as its actual text, it has none of the text screwups the MM pdf has when copying. Only step is to copy text, paste in a text document so the layout stays the same, and paste to GM notes. Even with the extra step of pasting to textfile first, its 4x faster for me than having to catch the spelling errors, or outright garbage the MM gives me.
1435654692
Kryx
Pro
Sheet Author
API Scripter
I also use a textfile in between to check the text. The script does parse a lot of the MM errors out - I'd say about 90% of it is removed.
1435655003
DXWarlock
Sheet Author
API Scripter
Mark said: I also use a textfile in between to check the text. The script does parse a lot of the MM errors out - I'd say about 90% of it is removed. OH yea, its amazing what it figures out. Was just pointing it out it works from the other also if someone is having a rough time with one of the badly OCR'd creatures. Maybe its my copy of the MM, I end up with some really wierd characters, or just what looks like cat walking across an ascii toggled keyboard for some of the text..haha
If we're all going through the entire MM here, we should just share the best version of a textfile we have like I did for the Lost Mine of Phandelver stuff. Saves us all working. Of course we totally will show proof of purchase to each other Mr Copyright Enforcer Who Is Reading Things.
1435677815
Kryx
Pro
Sheet Author
API Scripter
30th June 2015 (1.82) Formatting and fix how the success message for !shaped-settings displays to prevent the error in the log.
1435679599

Edited 1435680192
It seems like the css upload to github is damaged. It shows as one line, which Roll20 does not fix. Can you reupload it? EDIT: Actually, the html has the same problem where some lines are truncated, so when you use them, it causes 'unusable' errors.
1435679817
Kryx
Pro
Sheet Author
API Scripter
Josh said: It seems like the css upload to github is damaged. It shows as one line, which Roll20 does not fix. Can you reupload it? Sheet issues should be posted on the sheet thread, not the API thread. That said, this is intentional. The css is minified. It works, just not in the preview.
Oops sorry. too many windows open.
Ok, so, I made a new campaign and copied everything except the Journal Entries and imported some monsters over. The global updates work now, AND when making new monsters using the import macro they have the proper options set (before they were ignoring that part of the API). Though, I do have 'Show Target's AC on Attacks' set to false, but the new monsters have it on by default, but, with the global command, it's not an issue really.
1435689323
Kryx
Pro
Sheet Author
API Scripter
I had "attacks_vs_target_ac" reversed. Should be fixed now.
Mark said: I had "attacks_vs_target_ac" reversed. Should be fixed now. Founds this new bug with API script Mark, in addition to the one mentioned above. Normal Attack (Public) works as expected, but Whispered to GM only seems to have a carriage return at the bottom of all newly imported NPCs. I can't get rid of it :)
1435690876

Edited 1435714329
Sorry, got the links mixed up.
1435692067
Kryx
Pro
Sheet Author
API Scripter
Greg B. said: Normal Attack (Public) works as expected, but Whispered to GM only seems to have a carriage return at the bottom of all newly imported NPCs. I can't get rid of it :) There is no way to get rid of it. Roll20's ability to line break is largely a hack. I spent hours today. No go. Multiattack: Please put sheet related things on the sheet thread. Others will have the same issues.
Is there a place where these stat blocks are already typed up and available? I've been basically manually importing stuff from my MM but it's taking forever.
Brian B. said: Is there a place where these stat blocks are already typed up and available? I've been basically manually importing stuff from my MM but it's taking forever. The easiest way is to scan the book into a pdf. Some of the characters don't get recognized but Mark corrects for most of the common errors. Once scanned you can just copy and paste the text.
Here is the freely available basic rules DM pdf that starts off with some monsters.<a href="http://media.wizards.com/2014/downloads/dnd/DMDnDBasicRules_v0.1.pdf" rel="nofollow">http://media.wizards.com/2014/downloads/dnd/DMDnDBasicRules_v0.1.pdf</a>
1435835453

Edited 1435835497
DXWarlock
Sheet Author
API Scripter
Has anyone got mindflayer(illithid) to work? not sure if the PDF is just horribly bad on the OCR text or what. If so would someone mind sharing what they got to work as the text? Mine ends up with no attacks, token buttons with walls of text as its name, and named the token "Mind Flayer Medium aberration lawful evil Armor Class".
1435837765
Kryx
Pro
Sheet Author
API Scripter
Mind Flayer does indeed have problems. I'll add its errors to the sanitization list.
1435839967
Kryx
Pro
Sheet Author
API Scripter
I've sanitized mind flayers (and fixed many other issues - mainly around the description of a creature). I will commit later.
1435850790
Kryx
Pro
Sheet Author
API Scripter
2nd July 2015 (1.83) Sanitized Mind Flayer - it should also help others Sanitized so the description does not pull from the last action in some cases - it will still happen in others. Added targeting a creature's name for attacks and saves to the API so it can be edited on import and via settings changer Importer will automatically turn on hd toggle tabs.
1435908262

Edited 1435910539
DXWarlock
Sheet Author
API Scripter
Looking at the code and results, it doesn't look like its using the + of the hitdice? maybe I'm missing it as your code is way beyond my skill, Im having to try to work it out slowly to see where it doing what. for example (3d8 + 3) as hitdice..I see this in the code sendChat('GM', '/roll ' + nb_dice + 'd' + nb_face, function(ops) where it picks the dice and face, but even following it down don't see it adding the modifier.. as in chat I get (From GM): Hp (3d8) rolled: 4. the minimum should be 6? And wouldnt I expect: (From GM): Hp (3d8+3) rolled:... And its reporting the minimum as 13 (which is the middle of 3d8) not 16 (3d8+3) edit: this is using the 'scout' under non-player characters if that helps.
1435914434
Kryx
Pro
Sheet Author
API Scripter
Con mod is added right below: // Add Con modifier x number of hit dice var constitution_mod = Math.floor((getAttrByName(id, 'constitution', 'current') - 10) / 2); total = Math.floor(nb_dice * constitution_mod + total); That said I should refactor it to use the actual die from the hd rows, now the hd note row which is basically being depreciated. I'm also going to remove the "minimum as average". That simply sets the HP to be about 1/4 higher than average. That's not good. Either use dice or don't.
1435937371
Kryx
Pro
Sheet Author
API Scripter
3rd July 2015 (1.84) (Dev) Refactored how settings are setup Refactored how HP is rolled it will now calculate and display the formula, average, and the amount rolled. These values are based on the HD rows (not the note field) with constitution modifier added for each HD. (Dev) Removed Power cards vestigial stuff that wasn't hooked up anyways.
I look forward to making use of this ^_^. It is features made like this that keep me putting money into roll20
1435954216

Edited 1435955729
DXWarlock
Sheet Author
API Scripter
Ah ok, sorry for the confusion. It seems to work and display now, think it was just me being paranoid from the lack of display in chat of the modifier, and the scout not wanting to parse right. One issue now though with the new one. If I change bar1 from AC to HP, and make bar3 nothing I get One of the bar names has to be set to "HP" for random HP roll
1435955683

Edited 1435955709
DXWarlock
Sheet Author
API Scripter
I believe I figured out why, some reason '0' triggers the !number check. if I add the +1 to 'number' instead of the barTokenName it stops fussing changing these 2 bolded lines. shaped.rollTokenHp = function(token) { var number; for(var i = 0; i &lt; 3; i++) { if(shaped.settings.bar[i].name === 'HP') { number = i+1; break; } } if(!number) { var message = 'One of the bar names has to be set to "HP" for random HP roll'; sendChat('GM', '/w gm ' + message); return; } var barTokenName = 'bar' + (number), represent = token.get('represents');
1435958271
Kryx
Pro
Sheet Author
API Scripter
Fixed. I only tested it in the third, not the first which is why I didn't catch it. Thanks!
Hi there, me again. Tired of me yet? Three things at the moment, and I honestly hope they're more help than harm to improve and not just me being a bother; 1) Heavy lag after generating a mob, normally clears up with a few refreshes. 2) Mobs being named XXX %%NUMBERED%% for the token. I go in to edit out the GM notes and such anyways but just find it odd this occurs. 3) Creating a second import immediately after throws up an error(shown below), re-saving scripts corrects it. /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: number is not defined at Object.shaped.rollTokenHp (evalmachine.&lt;anonymous&gt;:7623:9) at evalmachine.&lt;anonymous&gt;:7482:18 at eval (
1436081258
Kryx
Pro
Sheet Author
API Scripter
Never experienced that. In general roll20 gets laggy after a while of usage, but I haven't seen a spike after importing Set "useAaronsNumberedScript" to false. I've made it off by default again. I missed replacing "number" with "barOfHP" in one spot. Replaced it now.
1436085858
DXWarlock
Sheet Author
API Scripter
We noticed something odd tonight, first time using it 'live' so not sure if its always been this way. When dragging over PC characters, with rollHP set to true, it rolls random HP for Players and NPCs. which caused all the playeres HP's to be changes for "HP" on their sheet. Anyway to get it to only roll if it has is_NPC=1?
1436087404
Kryx
Pro
Sheet Author
API Scripter
PCs used to not roll because they had their hp row linked, but that isn't working anymore... hmmm I'll put in a catch for is_npc as well.
1436089295
Kryx
Pro
Sheet Author
API Scripter
Done, though I found a bug where the token's attributes are not appearing. See <a href="https://app.roll20.net/forum/post/2149510/api-token-attributes-no-longer-populated" rel="nofollow">https://app.roll20.net/forum/post/2149510/api-token-attributes-no-longer-populated</a>
Whatever overall changes were made all three of the above issues seem resolved. Perhaps it was spiking because it was calling on a script not present? Anyhow, again sorry if I have been a bother, just really love to see projects like this succeed and I'm not the best trouble-shooter of late.
1436123883
Kryx
Pro
Sheet Author
API Scripter
You're helping me fix bugs, so no worries. :)
I have a request/suggestion. In the section with the toke bars you list them by color, but this is something that each person can change. It would be better to list them by number, since that cannot change
Something else just occurred to me. I stopped linking the HP bar on the default token because this screws things up in battle (changing the bar on 1 token changes all of them. this has prevented the HP roll of the script form working would it be possible to add a line to unlink the HP bar after the HP has been rolled?
1436186466
Kryx
Pro
Sheet Author
API Scripter
Ken M. said: I have a request/suggestion. In the section with the toke bars you list them by color, but this is something that each person can change. It would be better to list them by number, since that cannot change I comment them by the default color. They are listed in order (1,2,3). Ken M. said: Something else just occurred to me. I stopped linking the HP bar on the default token because this screws things up in battle (changing the bar on 1 token changes all of them. this has prevented the HP roll of the script form working would it be possible to add a line to unlink the HP bar after the HP has been rolled? Yes, I do not recommend linking HP for monsters. The HP roll is meant to not work if there is a link, but there is a bug currently that allows that. You can just change the setting to not have HP linked and the rolling works fine.
1436187043

Edited 1436187488
DXWarlock
Sheet Author
API Scripter
It should be working Ken if you unlinked the token bars and reassigned them to the sheet (and dont have it set in the script config to link on create), its how I have mine. All mine start as unlinked for NPCs to roll HP. Remember if it was linked, and you just unlink it from the token on the board, but dont reassign it to the sheet, the one on the sheets 'saved' state is still linked. I could be wrong, as i only glanced over it, I think thats the only 3 options it looks for to decide to roll besides the rollMonsterHpOnDrop: true, is if it represents something, if its linked, and if its an NPC. if(represent === '') { log('Token does not represent a character'); } else if(token.get(barTokenName + '_link') !== '') { log('Token ' + barTokenName + ' is linked'); } else { var isNPC = getAttrByName(represent, 'is_npc', 'current'); if(isNPC === 1) { rollCharacterHp(represent, function(total, average, formula) { And the is_npc fix worked mark, after a few dozen or so PCs and NPC none of the PC's getting dropped are getting new HPs, thanks!
right now i am getting the "One of the bar names has to be set to \"HP\" for random HP roll" error even though bar 1 is set to HP
1436187567
Kryx
Pro
Sheet Author
API Scripter
The NPC thing actually shouldn't be working - see the bug I linked above. What is likely happening is your PCs have linked bars and the NPCs don't.
1436188033

Edited 1436188201
DXWarlock
Sheet Author
API Scripter
Mark said: The NPC thing actually shouldn't be working - see the bug I linked above. What is likely happening is your PCs have linked bars and the NPCs don't. edit: added bar link log If it helps any, it seems like its the other way around in my case, the is_npc is the 'catch all' that's stopping it. As its seems to return it correctly. This is some logging I added after var isNPC = getAttrByName(represent, 'is_npc', 'current'); and drug 3 PC, then 3 NPCs over "token bar: " "is npc :0" "token bar: " "is npc :0" "token bar: " "is npc :0" "token bar: " "is npc :1" "token bar: " "is npc :1" "token bar: "
1436188041
Kryx
Pro
Sheet Author
API Scripter
Ken M. said: right now i am getting the "One of the bar names has to be set to \"HP\" for random HP roll" error even though bar 1 is set to HP Please make sure you have the latest code. <a href="https://app.roll20.net/forum/post/1816031/#post-2144649" rel="nofollow">https://app.roll20.net/forum/post/1816031/#post-2144649</a> two days ago dealt with bar1 issues.
1436188154
Kryx
Pro
Sheet Author
API Scripter
DXWarlock (William R.) said: If it helps any, it seems like its the other way around in my case, the is_npc is the 'catch all' that's stopping it. As its seems to return it correctly. This is some logging I added after var isNPC = getAttrByName(represent, 'is_npc', 'current'); and drug 3 PC, then 3 NPCs over "is npc :0" "is npc :0" "is npc :0" "is npc :1" "is npc :1" "is npc :1" Oh, right.. NPC does work. It's the detecting the link that doesn't work. I had it backwards above - correct.
1436188312
DXWarlock
Sheet Author
API Scripter
Ah no worries :) Wasn't correcting you if I came across that way. Wasn't sure if it was acting differently for us, and pointing out whatever version I have (not sure if its the latest havent checked lately) was working for pulling that attribute.
1436651272

Edited 1436657503
Kryx
Pro
Sheet Author
API Scripter
11th July 2015 (1.85) Added a spell importer. I still need to parse the description and pull out attack,save,damage,heal,effects Removed Clone Token. I'm still debating about the command format. Currently the journal name and spell name have to have no spaces. I'll have to fix both to work with spaces. Or just use the selected token instead of typing in a character name. Also debating if I should parse the spells from the wording or write the target, attack, save, etc in the json. Likely will parse. Example format: var spellsData = [ { "name":"Fireball", "description":"A bright streak flashes from your pointing finger to a point you choose within range and then blossoms with a low roar into an explosion of flame. Each creature in a 20-foot-radius sphere centered on that point must make a dexterity saving throw. A target takes 8d6 fire damage on a failed save, or half as much damage on a successful one.&lt;br&gt;The fire spreads around corners. It ignites flammable objects in the area that aren’t being worn or carried.", "higherLevel":"When you cast this spell using a spell slot of 4th level or higher, the damage increases by 1d6 for each slot level above 3rd.", "source":"phb 241", "range":"150 feet", "components":{ "verbal":"true", "somatic":"true", "material":"true", "materialMaterial":"A tiny ball of bat guano and sulfur" }, "ritual":"false", "duration":"Instantaneous", "concentration":"false", "castingTime":"1 action", "level":"3", "school":"Evocation", "classes":[ "Cleric", "Sorcerer", "Warlock", "Wizard" ], "domains":[ "Light" ], "patrons":[ "Fiend" ] } ]; Notice that the description has "&lt;br&gt;" for a line break. Those will be replaced and rendered properly on the sheet.
1436656912
The Aaron
Pro
API Scripter
Mark said: I'm still debating about the command format. Currently the journal name and spell name have to have no spaces. I'll have to fix both to work with spaces. Or just use the selected token instead of typing in a character name. I'd probably either split on /\s+--/ or support " and ' delimited strings.
1436657677
Kryx
Pro
Sheet Author
API Scripter
The Aaron said: I'd probably either split on /\s+--/ or support " and ' delimited strings. Using space followed by 2 dashes would require I change my settings API. I could do that... I'll have to think about it. Seems better than forcing quotes for names.
Mark said: 11th July 2015 (1.85) Added a spell importer. I still need to parse the description and pull out attack,save,damage,heal,effects Removed Clone Token. I'm still debating about the command format. Currently the journal name and spell name have to have no spaces. I'll have to fix both to work with spaces. Or just use the selected token instead of typing in a character name. Also debating if I should parse the spells from the wording or write the target, attack, save, etc in the json. Likely will parse. Example format: var spellsData = [ { "name":"Fireball", "description":"A bright streak flashes from your pointing finger to a point you choose within range and then blossoms with a low roar into an explosion of flame. Each creature in a 20-foot-radius sphere centered on that point must make a dexterity saving throw. A target takes 8d6 fire damage on a failed save, or half as much damage on a successful one.&lt;br&gt;The fire spreads around corners. It ignites flammable objects in the area that aren’t being worn or carried.", "higherLevel":"When you cast this spell using a spell slot of 4th level or higher, the damage increases by 1d6 for each slot level above 3rd.", "source":"phb 241", "range":"150 feet", "components":{ "verbal":"true", "somatic":"true", "material":"true", "materialMaterial":"A tiny ball of bat guano and sulfur" }, "ritual":"false", "duration":"Instantaneous", "concentration":"false", "castingTime":"1 action", "level":"3", "school":"Evocation", "classes":[ "Cleric", "Sorcerer", "Warlock", "Wizard" ], "domains":[ "Light" ], "patrons":[ "Fiend" ] } ]; Notice that the description has "&lt;br&gt;" for a line break. Those will be replaced and rendered properly on the sheet. Very cool Mark, glad to see you working on this. BTW Stephen S. Posted all the Free PDF spells in a JSON file some time back, it has some power card stuff in it that not everyone probably needs but would be a great starting point. Here is the link.
Spell importer would be such a boon, you have no idea... I just wish there was an easier way to create importers.