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

Two Variables Off One Dropdown Option

1498739549
Jakob
Sheet Author
API Scripter
Well, if you log the setting object (within the repeating conversion section) just before doing setAttrs(setting), what does it say in the console? If it was setting the correct attributes to the correct values, the variables would be set correctly, so clearly it isn't doing that.
So the code looks like this: // spellRingConversion getSectionIDs('repeating_spells', function (idArray) { getAttrs(idArray.map(id => `repeating_spells_${id}_spellRing`), function (values) { console.log(values); // Logging all the spellRing key:value pairs from the old sheet console.log(idArray); // logging all row ids. Those missing from the values object above don't have a spellRing // attribute set, so they should default to air let setting = {}; idArray.forEach(function (id) { switch (values[`repeating_spells_${id}_spellRing`]) { case '@{Void}': setting[`repeating_spells_${id}_spell_ring`] = '@{foo_void}'; break; case '@{Water}': setting[`repeating_spells_${id}_spell_ring`] = '@{foo_water}'; break; case '@{Fire}': setting[`repeating_spells_${id}_spell_ring`] = '@{foo_fire}'; break; case '@{Earth}': setting[`repeating_spells_${id}_spell_ring`] = '@{foo_earth}'; break; default: setting[`repeating_spells_${id}_spell_ring`] = '@{foo_air}'; // defaulting to air in case the select was never changed } }); console.log(setting); // Logging the attributes we are about to set. setAttrs(setting); }); }); One day, I saw something in the console. Since then, it hasn't logged anything, and I have no idea why. Now the only clue I have is this line: FILLED IN A DEFAULT VALUE FOR repeating_spells_-KkLyf2GvtxzhbIszMJj_spell_ring The only thing anywhere near it are a bunch of triggering commands.
1498766086

Edited 1498766147
Jakob
Sheet Author
API Scripter
Okay, so the FILLED IN A DEFAULT VALUE doesn't come from the sheet workers, that's a message from the sheet which appears when you create a new repeating row and it fills in the default. If it's not logging anything, this code never runs. Make sure the following are true: 1) the code is in the form I wrote down earlier, with the on("sheet:opened") event checking the version and then running convertFromOldSheet(). 2) You are testing this on a character which has never been opened with this sheet before (the function in the on("sheet:opened") checks if there's no version attribute present, and only runs the conversion if there isn't).
Oh dear god, that cracked it. It's just what I needed. I suspected of course that I was an idiot, but it was a matter of what exact BRAND of idiot. The problem was you'd given me two bits of conversion code so this was in there twice: on('sheet:opened', function () { let currentVersion = 1.0; getAttrs(['version'], function (v) { if (!v.version) { convertFromOldSheet(); }; setAttrs({ version: currentVersion }); }); }); I knew it set the version number but didn't catch that is was calling the conversion script, so I'd deleted the duplicate instance, thinking it a bad idea to have it in there twice. So it's working now. God bless.