What I’m trying to do
I am trying to create a script that lets me add together metadata variables from different notes on a core note, using meta bind js. I am hoping to be able to choose from options and have the results change based on dynamic variables.
I have a script (found on this forum post) that I’ve been able to adapt thus far for pulling metadata from other notes based on dynamic metadata in the core note. It works really well when I reference/pull metadata from a single external note. This is what the code looks like - it pulls from metadata I’ve put in my external “barbarian” note, changing the metadata of my core note based on the dropdown menu.
level: level6
dndClass: Barbarian
prof: 3
Level: INPUT[inlineSelect (option(level1), option(level2), option(level3), option(level4), option(level5), option(level6), option(level7), option(level8), option(level9), option(level10), option(level11), option(level12), option(level13), option(level14), option(level15), option(level16), option(level17), option(level18), option(level19), option(level20)):level]
Class: INPUT[inlineSelect(option(Artificer), option(Barbarian, Barbarian), option(Bard), option(Cleric), option(Druid), option(Fighter), option(Monk), option(Paladin), option(Ranger), option(Rogue), option(Sorcerer), option(Warlock), option(Wizard)):dndClass]
Proficiency Bonus:
{level} as level
{dndClass} as dndClass
---
const level = context.bound.level;
const dndClass = context.bound.dndClass;
const str = `\`VIEW[{${dndClass}#${level}.prof}][:prof]\``;
return engine.markdown.create(str);
However, now I have a metadata field in which I list multiple notes to pull data from - that I am using specifically to populate a dataviewjs table (so I can’t expand the metadata list into different fields). See below:
liquor:
- Short Sword
load: 1
Choose your weapons and armour:
INPUT[inlineListSuggester(option(Unarmed), option(Dagger), option(Cudgel), option(Club), option(Short Sword), option(Sword), option(Long Sword), option(Short Spear), option(Spear), option(Great Spear), option(Axe), option(Long-hafted Axe), option(Great Axe), option(Mattock), option(Bow), option(Great Bow), option(Leather Shirt), option(Leather Corslet), option(Mail-shirt), option(Coat of Mail),option(Helm)):liquor]
{liquor} as liquor
---
const liquor = context.bound.liquor;
const str = `\`VIEW[{${liquor}#Load}][:load]\``;
return engine.markdown.create(str);
I’d like to add together the “load” fields from multiple external notes dynamically, based on what has been added to the core note’s metadata (i.e. helm’s load metadata + spear’s load metadata, for example) but of course, that doesn’t work with the above script - VIEW[{${liquor}#Load}][:load] works with a single variable, but as soon as I add another, I get an error (the code defaults to VIEW[{Helm, Spear#Load}], which is not readable).
Things I have tried
I’ve tried to research how to pull from multiple notes using dynamic metadata in meta bind js engine, but have not come up with an understandable solution. I’m a javascript novice and so don’t have the background to figure out creative solutions on my own - I’m a bit stuck! Any guidance or insight would be much appreciated.
Thanks so much!