Created
October 15, 2022 16:00
-
-
Save scottTomaszewski/1fba2647c85f4d3769dc920f3a827224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to take data.json from obsidian-5e-statblock plugin and make links of the spells in statblocks. Output will be written at the end to "$FILE.out" | |
# Usage: | |
# link_spells.bash data.json | |
# | |
set -e | |
FILE=$1 | |
SPELLS=" | |
abi-dalzim's horrid wilting | |
absorb elements | |
acid splash | |
aganazzar's scorcher | |
aid | |
alarm | |
alter self | |
animal friendship | |
animal messenger | |
animal shapes | |
animate dead | |
animate objects | |
antilife shell | |
antimagic field | |
antipathy\/sympathy | |
arcane eye | |
arcane gate | |
arcane lock | |
armor of agathys | |
arms of hadar | |
ashardalon's stride | |
astral projection | |
augury | |
aura of life | |
aura of purity | |
aura of vitality | |
awaken | |
bane | |
banishing smite | |
banishment | |
barkskin | |
beacon of hope | |
beast bond | |
beast sense | |
bestow curse | |
bigby's hand | |
blade barrier | |
blade of disaster | |
blade ward | |
bless | |
blight | |
blinding smite | |
blindness\/deafness | |
blink | |
blur | |
bones of the earth | |
booming blade | |
borrowed knowledge | |
branding smite | |
burning hands | |
call lightning | |
calm emotions | |
catapult | |
catnap | |
cause fear | |
ceremony | |
chain lightning | |
chaos bolt | |
charm monster | |
charm person | |
chill touch | |
chromatic orb | |
circle of death | |
circle of power | |
clairvoyance | |
clone | |
cloud of daggers | |
cloudkill | |
color spray | |
command | |
commune | |
commune with nature | |
compelled duel | |
comprehend languages | |
compulsion | |
cone of cold | |
confusion | |
conjure animals | |
conjure barrage | |
conjure celestial | |
conjure elemental | |
conjure fey | |
conjure minor elementals | |
conjure volley | |
conjure woodland beings | |
contact other plane | |
contagion | |
contingency | |
continual flame | |
control flames | |
control water | |
control weather | |
control winds | |
cordon of arrows | |
counterspell | |
create bonfire | |
create food and water | |
create homunculus | |
create magen | |
create or destroy water | |
create undead | |
creation | |
crown of madness | |
crown of stars | |
crusader's mantle | |
cure wounds | |
dancing lights | |
danse macabre | |
dark star | |
darkness | |
darkvision | |
dawn | |
daylight | |
death ward | |
delayed blast fireball | |
demiplane | |
destructive wave | |
detect evil and good | |
detect magic | |
detect poison and disease | |
detect thoughts | |
dimension door | |
disguise self | |
disintegrate | |
dispel evil and good | |
dispel magic | |
dissonant whispers | |
distort value | |
divination | |
divine favor | |
divine word | |
dominate beast | |
dominate monster | |
dominate person | |
draconic transformation | |
dragon's breath | |
drawmij's instant summons | |
dream | |
dream of the blue veil | |
druid grove | |
druidcraft | |
dust devil | |
earth tremor | |
earthbind | |
earthquake | |
eldritch blast | |
elemental bane | |
elemental weapon | |
encode thoughts | |
enemies abound | |
enervation | |
enhance ability | |
enlarge\/reduce | |
ensnaring strike | |
entangle | |
enthrall | |
erupting earth | |
etherealness | |
evard's black tentacles | |
expeditious retreat | |
eyebite | |
fabricate | |
faerie fire | |
false life | |
far step | |
fast friends | |
fear | |
feather fall | |
feeblemind | |
feign death | |
find familiar | |
find greater steed | |
find steed | |
find the path | |
find traps | |
finger of death | |
fire bolt | |
fire shield | |
fire storm | |
fireball | |
fizban's platinum shield | |
flame arrows | |
flame blade | |
flame strike | |
flaming sphere | |
flesh to stone | |
fly | |
fog cloud | |
forbiddance | |
forcecage | |
foresight | |
fortune's favor | |
freedom of movement | |
friends | |
frost fingers | |
frostbite | |
gaseous form | |
gate | |
geas | |
gentle repose | |
giant insect | |
gift of alacrity | |
gift of gab | |
glibness | |
globe of invulnerability | |
glyph of warding | |
goodberry | |
grasping vine | |
gravity fissure | |
gravity sinkhole | |
grease | |
greater invisibility | |
greater restoration | |
green-flame blade | |
guardian of faith | |
guardian of nature | |
guards and wards | |
guidance | |
guiding bolt | |
gust | |
gust of wind | |
hail of thorns | |
hallow | |
hallucinatory terrain | |
harm | |
haste | |
heal | |
healing spirit | |
healing word | |
heat metal | |
hellish rebuke | |
heroes' feast | |
heroism | |
hex | |
hold monster | |
hold person | |
holy aura | |
holy weapon | |
hunger of hadar | |
hunter's mark | |
hypnotic pattern | |
ice knife | |
ice storm | |
identify | |
illusory dragon | |
illusory script | |
immolation | |
immovable object | |
imprisonment | |
incendiary cloud | |
incite greed | |
infernal calling | |
infestation | |
inflict wounds | |
insect plague | |
intellect fortress | |
investiture of flame | |
investiture of ice | |
investiture of stone | |
investiture of wind | |
invisibility | |
invulnerability | |
jim's glowing coin | |
jim's magic missile | |
jump | |
kinetic jaunt | |
knock | |
legend lore | |
leomund's secret chest | |
leomund's tiny hut | |
lesser restoration | |
levitate | |
life transference | |
light | |
lightning arrow | |
lightning bolt | |
lightning lure | |
locate animals or plants | |
locate creature | |
locate object | |
longstrider | |
maddening darkness | |
maelstrom | |
mage armor | |
mage hand | |
magic circle | |
magic jar | |
magic missile | |
magic mouth | |
magic stone | |
magic weapon | |
magnify gravity | |
major image | |
mass cure wounds | |
mass heal | |
mass healing word | |
mass polymorph | |
mass suggestion | |
maximilian's earthen grasp | |
maze | |
meld into stone | |
melf's acid arrow | |
melf's minute meteors | |
mending | |
mental prison | |
message | |
meteor swarm | |
mighty fortress | |
mind blank | |
mind sliver | |
mind spike | |
minor illusion | |
mirage arcane | |
mirror image | |
mislead | |
misty step | |
modify memory | |
mold earth | |
moonbeam | |
mordenkainen's faithful hound | |
mordenkainen's magnificent mansion | |
mordenkainen's private sanctum | |
mordenkainen's sword | |
motivational speech | |
move earth | |
nathair's mischief | |
negative energy flood | |
nondetection | |
nystul's magic aura | |
otiluke's freezing sphere | |
otiluke's resilient sphere | |
otto's irresistible dance | |
pass without trace | |
passwall | |
phantasmal force | |
phantasmal killer | |
phantom steed | |
planar ally | |
planar binding | |
plane shift | |
plant growth | |
poison spray | |
polymorph | |
power word heal | |
power word kill | |
power word pain | |
power word stun | |
prayer of healing | |
prestidigitation | |
primal savagery | |
primordial ward | |
prismatic spray | |
prismatic wall | |
produce flame | |
programmed illusion | |
project image | |
protection from energy | |
protection from evil and good | |
protection from poison | |
psychic scream | |
pulse wave | |
purify food and drink | |
pyrotechnics | |
raise dead | |
rary's telepathic bond | |
raulothim's psychic lance | |
ravenous void | |
ray of enfeeblement | |
ray of frost | |
ray of sickness | |
reality break | |
regenerate | |
reincarnate | |
remove curse | |
resistance | |
resurrection | |
reverse gravity | |
revivify | |
rime's binding ice | |
rope trick | |
sacred flame | |
sanctuary | |
sapping sting | |
scatter | |
scorching ray | |
scrying | |
searing smite | |
see invisibility | |
seeming | |
sending | |
sequester | |
shadow blade | |
shadow of moil | |
shape water | |
shapechange | |
shatter | |
shield | |
shield of faith | |
shillelagh | |
shocking grasp | |
sickening radiance | |
silence | |
silent image | |
silvery barbs | |
simulacrum | |
skill empowerment | |
skywrite | |
sleep | |
sleet storm | |
slow | |
snare | |
snilloc's snowball swarm | |
soul cage | |
spare the dying | |
speak with animals | |
speak with dead | |
speak with plants | |
spider climb | |
spike growth | |
spirit guardians | |
spirit shroud | |
spiritual weapon | |
staggering smite | |
steel wind strike | |
stinking cloud | |
stone shape | |
stoneskin | |
storm of vengeance | |
storm sphere | |
suggestion | |
summon aberration | |
summon beast | |
summon celestial | |
summon construct | |
summon draconic spirit | |
summon elemental | |
summon fey | |
summon fiend | |
summon greater demon | |
summon lesser demons | |
summon shadowspawn | |
summon undead | |
sunbeam | |
sunburst | |
swift quiver | |
sword burst | |
symbol | |
synaptic static | |
tasha's caustic brew | |
tasha's hideous laughter | |
tasha's mind whip | |
tasha's otherworldly guise | |
telekinesis | |
telepathy | |
teleport | |
teleportation circle | |
temple of the gods | |
temporal shunt | |
tenser's floating disk | |
tenser's transformation | |
tether essence | |
thaumaturgy | |
thorn whip | |
thunder step | |
thunderclap | |
thunderous smite | |
thunderwave | |
tidal wave | |
time ravage | |
time stop | |
tiny servant | |
toll the dead | |
tongues | |
transmute rock | |
transport via plants | |
tree stride | |
true polymorph | |
true resurrection | |
true seeing | |
true strike | |
tsunami | |
unseen servant | |
vampiric touch | |
vicious mockery | |
vitriolic sphere | |
vortex warp | |
wall of fire | |
wall of force | |
wall of ice | |
wall of light | |
wall of sand | |
wall of stone | |
wall of thorns | |
wall of water | |
warding bond | |
warding wind | |
water breathing | |
water walk | |
watery sphere | |
web | |
weird | |
whirlwind | |
wind walk | |
wind wall | |
wish | |
witch bolt | |
wither and bloom | |
word of radiance | |
word of recall | |
wrath of nature | |
wrathful smite | |
wristpocket | |
zephyr strike | |
zone of truth | |
" | |
#SPELLS=$(echo "$SPELLS" | tr -d "") | |
# Setup output | |
OUTPUT_FILE="$FILE.out" | |
OUTPUT=$(cat "$FILE") | |
# For each spell (line) in the $SPELL variable... | |
while IFS= read -r SPELL; do | |
# Skip empty lines | |
if [ -z "$SPELL" ]; then continue; fi | |
echo "Replacing $SPELL" | |
# REGEX for content after the prefix (cantrip, 1st level, at will, ...) | |
# Look for strings allowed before the spell (spell-prefix), the spell name, and then strings allowed after the spell (spell-suffix) | |
EXISTING_SPELL_REGEX="\(\"\|,\|, \|: \||\)$SPELL\(\"\|,\|, \| (\|\*\||\)" | |
# Replacement string for output. Contains prefix, spell-prefix, linked spell, and spell-suffix | |
SPELL_REPLACEMENT="\1\2[[$SPELL]]\3" | |
# Run REGEX replacements on all the prefixes (I should make this a loop or combine them one day...) | |
OUTPUT=$(echo "$OUTPUT" | sed "s/\([c|C]antrips.*\)$EXISTING_SPELL_REGEX/$SPELL_REPLACEMENT/g") | |
OUTPUT=$(echo "$OUTPUT" | sed "s/\([1-9][a-z][a-z] [lL]evel.*\)$EXISTING_SPELL_REGEX/$SPELL_REPLACEMENT/g") | |
OUTPUT=$(echo "$OUTPUT" | sed "s/\(\"[a|A]t will.*\)$EXISTING_SPELL_REGEX/$SPELL_REPLACEMENT/g") | |
OUTPUT=$(echo "$OUTPUT" | sed "s/\(day each.*\)$EXISTING_SPELL_REGEX/$SPELL_REPLACEMENT/g") | |
done <<< "$SPELLS" | |
# Write output to output file. | |
echo "writing to $OUTPUT_FILE" | |
echo "$OUTPUT" > "$OUTPUT_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment