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

Reviving SRD Importer by Chris S.

1644078056

Edited 1646217899
I've been writing my own version of the SRD importer by Chris S for the 3.5 character sheet made by Diana P. You can quickly copy and paste monster stat blocks onto a character sheet, run the script, and upload most of the relevant information. Also included is a function to create attack macros and skill macros. A separate code is included two posts down for shortened statblocks (like those often found in modules). Code available at:&nbsp; <a href="https://github.com/astuertz/Roll20/blob/main/importMonster.js" rel="nofollow">https://github.com/astuertz/Roll20/blob/main/importMonster.js</a> Update 3/2: *Uploaded newest version of the code with minor corrections to old code *Created a new call !createspellMacros. This call creates the ability name of each spell listed as zSPELL(something) in the Other Field. This is intended as a shortcut to be used with the !importSpell call from my other script. That script can be found here: <a href="https://app.roll20.net/forum/post/10693924/script-api-script-to-create-spell-macros-for-3-dot-5/?pageforid=10693924#post-10693924" rel="nofollow">https://app.roll20.net/forum/post/10693924/script-api-script-to-create-spell-macros-for-3-dot-5/?pageforid=10693924#post-10693924</a> This is actually a topic with 2 scripts (the first creates nearly 700 spell macros for 3.5, the other transfers those spells onto the character sheet using the input information). In this case, assuming that you are using the importSpell script, you can add each spell name to the bottom of the statblock using the appropriate name (something to the effect of zSPELLMageArmor) and add the appropriate text thereafter. So each spell line should read: zSPELLMageArmor CL 9 DC 13 Ranged 13 Melee 15 Include the appropriate numbers and use as is relevant to the spell. This is a basically a shortcut to a shortcut, if you will. I just found it tedious to create ability macros for each spell manually, and this let's you do it much more easily. The spell names are also generally intuitive, removing spaces and capitalizing all words except "or". It is also notable that some spells have the Lesser/Greater and the spell name reversed. Like zSPELLConfusionLesser. But generally it doesn't take too much guesswork to get the spell name correct the first time. As should be noted in the importSpell topic, once you run importSpell, it changes the name from zSPELL to just SPELL. This should indicate whether or not it was successful. Update 2/20: *Changed Concentrate to Concentration for !createskillMacros *Changed the Skills generation field to change -# to +-# for skills for the purpose of !createskillMacros Update 2/13: *!shortblockMonster reincorporated into !importMonster, now using the updated error checking and error reporting. *Regex for "Senses" is no longer case insensitive in !shortblockMonster *Added new command !IM to display all available commands, as well as describe their use and function. *Added additional error checking to !createattackMacro. Now sends error message if it cannot correctly parse the name or attack modifier info from either Attack or Full Attack field of NPC on character sheet. Update 2/12: *Checks to see if an attribute exists before setting (now for all attributes). It is no longer needed to populate attributes before using script. *Now supports non-integer ability scores. If ability score is not an integer, ability mods are set to '0' by default. *No longer floods chat with all the updated information. Instead, if a value is not found in stat block, it adds to the error message which is displayed in a neat box at the end. *Commonly used routines in each step of the code have been changed into functions. Likewise, ability scores are generated using a for() function which calls a function for each ability score. *A bit of comment clean/up (redoing instructions in the beginning as well) *Adding !createabilityMacros to create a simple ability macro for each listed ability (see comment section at beginning of code). Each macro contains only the name of the ability and its description. *Had the script check for any of the commands and load functions and global variables. No more redundant usage of functions or variables for each command. *Now also populates the npcname field. *Checks to make sure that importMonster is a valid character *Checks to make sure that the other field has text.
1644082927
Andreas J.
Forum Champion
Sheet Author
Translator
hoyer have been doing updates to the 3.5E sheet: <a href="https://app.roll20.net/forum/post/10277870/d-and-d-3-dot-5-sheet-upgrade" rel="nofollow">https://app.roll20.net/forum/post/10277870/d-and-d-3-dot-5-sheet-upgrade</a>
1644132748

Edited 1644746263
Standard stat block (from SRD): Size/Type: Medium Animal Hit Dice: 2d8+4 (13 hp) Initiative: +2 Speed: 50 ft. (10 squares) Armor Class: 14 (+2 Dex, +2 natural), touch 12, flat-footed 12 Base Attack/Grapple: +1/+2 Attack: Bite +3 melee (1d6+1) Full Attack: Bite +3 melee (1d6+1) Space/Reach: 5 ft./5 ft. Special Attacks: Trip Special Qualities: Low-light vision, scent Saves: Fort +5, Ref +5, Will +1 Abilities: Str 13, Dex 15, Con 15, Int 2, Wis 12, Cha 6 Skills: Hide +2, Listen +3, Move Silently +3, Spot +3, Survival +1* Feats: TrackB, Weapon Focus (bite) Environment: Temperate forests Organization: Solitary, pair, or pack (7-16) Challenge Rating: 1 Advancement: 3 HD (Medium); 4-6 HD (Large) Level Adjustment: — Shortened Stat block: CE Small undead Init +2; Senses darkvision 60 ft., scent; Listen +7, Spot +7 Languages Common, Goblin AC 14, touch 13, flat-footed 12 hp 58 (7 HD) Immune undead immunities (MM 317) Resist cold 5, fire 5, sonic 5 Fort +2, Ref +6, Will +6 Speed 30 ft. (6 squares) Melee 2 tentacles each +6 (1d8+3) and 2 claws each +1 (1d6+1) Space 5 ft.; Reach 5 ft. (10 ft. with tentacles) Base Atk +3; Grp +6 Atk Options improved grab, Power Attack Special Actions bonedrink, pounce Abilities Str 16, Dex 14, Con 0, Int 10, Wis 8, Cha 12 SQ unholy toughness Feats Combat Reflexes, Improved Natural Attack (claws), Power Attack Skills Hide +10, Listen +7, Move Silently +14, Spot +7 Improved Grab (Ex) To use this ability, a bonedrinker must hit with a tentacle attack. It can then attempt to start a grapple as a free action without provoking attacks of opportunity. If it wins the grapple check, it establishes a hold and deals automatic claw or tentacle damage to the grappled victim. It can deal automatic claw or tentacle damage in each subsequent round that it maintains the grapple, and a bonedrinker that has successfully pinned an opponent can begin to drink its bones (see Bonedrink, below). Bonedrinkers have a +4 racial bonus on grapple checks. Bonedrink (Su) Once a lesser bonedrinker has successfully grappled an opponent, it can begin to drink its bones. To do this, it must pin its foe, at which point it fastens onto the creature with its fangs and secretes a painful toxin that deals 1d4 points of Constitution damage. Each round the pin is maintained, the bonedrinker deals an additional 1d4 points of Constitution damage. Creatures reduced to 0 Constitution die; their bones become too brittle to support their bodies and they collapse into a sack of loose flesh. Creatures without bones or Constitution scores are immune to this ability. Pounce (Ex) If a bonedrinker charges, it can make a full attack in the same round. Unholy Toughness (Ex) A lesser bonedrinker gains a bonus to its hit points equal to its Charisma modifier × its Hit Dice
1644324207

Edited 1644324263
GiGs
Pro
Sheet Author
API Scripter
It looks like you have a lot of repeated code there. I'd be looking at how to convert all the instances like this: match = other.match(/DR\s*[\d]+(.*)/ig); if(match){ var regex = match[0]; foundAttribute = findObjs({ _characterid: importMonster.id, _type: "attribute", name: 'npcdescr' })[0]; var descr = getAttrByName(importMonster.id, "npcdescr"); regex = descr + "\n" + "Immune" + regex; foundAttribute.set("current",regex); } To a function, so you could replace that entire block with something like &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkMatch('DR', 'npcdescr', charid); or maybe just &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkMatch('DR', charid); and make the script a lot shorter and more readable. It might be tricky since it looks like a lot of your code inside the if(match){ block do have slight variations, but there's likely still ways to simplify it. Once done, that would make it easier to find errors, and add fixes.
GiGs said: It looks like you have a lot of repeated code there. I'd be looking at how to convert all the instances like this: match = other.match(/DR\s*[\d]+(.*)/ig); if(match){ var regex = match[0]; foundAttribute = findObjs({ _characterid: importMonster.id, _type: "attribute", name: 'npcdescr' })[0]; var descr = getAttrByName(importMonster.id, "npcdescr"); regex = descr + "\n" + "Immune" + regex; foundAttribute.set("current",regex); } To a function, so you could replace that entire block with something like &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkMatch('DR', 'npcdescr', charid); or maybe just &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;checkMatch('DR', charid); and make the script a lot shorter and more readable. It might be tricky since it looks like a lot of your code inside the if(match){ block do have slight variations, but there's likely still ways to simplify it. Once done, that would make it easier to find errors, and add fixes. Definitely. I think the one thing I think is lacking the most is error checking. There are certain things like setting the attributes that won't work unless the attributes have already been created. (I tried to have it make checks for these at first, but I couldn't get the error check to work; so instead, I just left instructions to populate all of the fields with "1's" ahead of time to generate all of the attributes. I theory, it would check if the attribute existed or not--then, if it did, it would update it; or if not, it would create it.) A lot of this so far has lacked a lot of error checking. And yes, a lot of the code is pretty much copy + paste with a few things changed. Mostly, the regex expressions are different (which could be made a string), the attribute names are different, and I've also gotten way better at parsing text since I first started this. Like for one, I didn't know that you could use a regex expression in a .replace() or a .split() until I was already mostly done with the main body of the code. I'm also concerned about whether my notes are sufficient or intelligible. I'd like people to be able to come in and look at my code and be like "oh, that makes sense." The !createaattackMacros section I just added is by far the most complex thing I've added. It wasn't intended to be overly complex; it was just a complex problem that needed a complex solution. I tend to prefer simpler solutions whenever possible, since I don't want to make my code more confusing that it has to be.
1644341180
GiGs
Pro
Sheet Author
API Scripter
There are certain things like setting the attributes that won't work unless the attributes have already been created. (I tried to have it make checks for these at first, but I couldn't get the error check to work; so instead, I just left instructions to populate all of the fields with "1's" ahead of time to generate all of the attributes. I theory, it would check if the attribute existed or not--then, if it did, it would update it; or if not, it would create it.) I wondered about that, since you should be able to check if an attribute exists and create it if not. Some of your code even does that, so I don't know why its not working.
1644341387

Edited 1644341588
GiGs said: There are certain things like setting the attributes that won't work unless the attributes have already been created. (I tried to have it make checks for these at first, but I couldn't get the error check to work; so instead, I just left instructions to populate all of the fields with "1's" ahead of time to generate all of the attributes. I theory, it would check if the attribute existed or not--then, if it did, it would update it; or if not, it would create it.) I wondered about that, since you should be able to check if an attribute exists and create it if not. Some of your code even does that, so I don't know why its not working. I had the code check if it was "undefined," and I don't think that was exactly the right way to go about it. I tried a couple different things without results. Naturally, I got bored with the error checking and went on to the mechanical parts of the script. To be clear, I had it fetch an object and store it in a variable. That variable is what is checked against being "undefined," and I think because I use that variable a lot, it isn't undefined. It might come up "null" but I don't remember if I tried that.
1644540692
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Astuertz! Multiple posts of long blocks of code can be confusing, especially when they are they are essentially iterations of the same script. It can get even worse if someone carelessly quotes an entire post. Most folks will either use a git or gist, or if posting the code in-forum, keep updating to the latest version in the top post. It makes it easier for users to look for the latest version. Just a suggestion. :)
keithcurtis said: Hi Astuertz! Multiple posts of long blocks of code can be confusing, especially when they are they are essentially iterations of the same script. It can get even worse if someone carelessly quotes an entire post. Most folks will either use a git or gist, or if posting the code in-forum, keep updating to the latest version in the top post. It makes it easier for users to look for the latest version. Just a suggestion. :) Thanks . Ill update this thread when I get home and am on my PC.
New Update: Working on incorporating error checking. Some common routines have been changed into functions. Ability scores now use a "for" function and a list of strings like the work I had done for !createskillMacros.
1644689371

Edited 1644689427
vÍnce
Pro
Sheet Author
I appreciate you updating the thread of your progress with this.&nbsp; Many thanks.&nbsp; I know Keith mentioned it's best practice to just update one code-block at the top of the thread vs continuous new posts of code changes, and I agree, but maybe linking a gist (or similar) would be handy since people could see the history of changes which can be very beneficial/educational for many.&nbsp;&nbsp; Cheers
vÍnce said: I appreciate you updating the thread of your progress with this.&nbsp; Many thanks.&nbsp; I know Keith mentioned it's best practice to just update one code-block at the top of the thread vs continuous new posts of code changes, and I agree, but maybe linking a gist (or similar) would be handy since people could see the history of changes which can be very beneficial/educational for many.&nbsp;&nbsp; Cheers True enough. I was trying to avoid making a new account. But that is probably the best practice. I will set it up for future updates.