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

Ideas to assign repeating Spells Schools to repeating Spells list ?

Hi ! I'am thinking about a way (if it's possible...) to assign a Spell School (from a repeating section) to a Spell (from another repeating section). Here is my current work : <a href="https://www.dropbox.com/s/ghyvx51leo7p7z0/feuille" rel="nofollow">https://www.dropbox.com/s/ghyvx51leo7p7z0/feuille</a>... (sorry in french...) On the left, you can add Schools. The little cog on each school open a modal with the school's params inside. Each school works as a radio button: if you click a school, it filter the spell list. On the top right you can see rounded numbers from 0 to 15, it's the spells levels filter. Each Level works as a radio button : if you click a level, it filtre the spell list On the right, you can add Spells. You can see the spell name and the params behind (inspired from d&d sheet). When a spell is created, i register the Level and School currently selected inside an hidden field of the spell. When a filter (Level or School) is applied, i parse every spells, look the hidden values and if i have a match, check an hidden checkbox "spell_display" and display the spell via css wizardry. And the double filter works quite well :3 When the checkbox "Réassigner" (top left) is checked, i display all the spells and the filter wont work. The player have to check a School, check a Level and then update the wanted spell to assign the selected filters to the spell. Here is what i would like to do : An easiest way to change School and Level of a spell. For the Level it's easy, a Select with options from 0 to 15. done. But i cant find a way for School... - a dynamic Select would be perfect but we can use dom Y_Y - a field with autocomplete ? - a false select (css wizardry) with dynamics attr_names changing every time a school is updated @_@ If i cant find a way, i'll just use a fixed list, with fixed Schools, but it's a shame for the customisation of the game... <a href="https://www.dropbox.com/s/ggjxssoriy5x93o/feuille-" rel="nofollow">https://www.dropbox.com/s/ggjxssoriy5x93o/feuille-</a>... if someone think about something else, i'll be glad and happy \0/
1526319060
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
If you're ok with using sheetworkers then I'd recommend doing it by using a text entry for the spell's current schools. Then you use regex matching to filter spells based on what their school entry is (if it matches the selected school filter without case sensitivity). Something like this for the sheetworker code: &lt;script&gt; const repeatingAttributes = [/*Array of objects with the attributes in each repeating section that need to be gotten with getAttrs, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; used in getID() &nbsp; &nbsp; Entity format: &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; section:'Name of the section', &nbsp; &nbsp; &nbsp; &nbsp; fields:['name_of_the_attribute'] &nbsp; &nbsp; } &nbsp; &nbsp; */ &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; section:'spell', &nbsp; &nbsp; &nbsp; &nbsp; fields:['school'] &nbsp; &nbsp; }, ], getID = function(cloneRepAttr,callback,sectionAggregate){ &nbsp; &nbsp; var currSection=cloneRepAttr.shift(); &nbsp; &nbsp; sectionAggregate = sectionAggregate || []; &nbsp; &nbsp; getSectionIDs('repeating_'+currSection.section,(itemIDArr)=&gt;{ &nbsp; &nbsp; &nbsp; &nbsp; sectionAggregate.push({ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; section:currSection.section, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id:itemIDArr, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fields:currSection.fields &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; if(_.isEmpty(cloneRepAttr)){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callback(sectionAggregate); &nbsp; &nbsp; &nbsp; &nbsp; }else{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getID(cloneRepAttr,callback,sectionAggregate); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; }); }; on('change:school_filter',(event)=&gt;{ &nbsp; &nbsp; const setObj = {}; &nbsp; &nbsp; getID(repeatingAttributes,(attrNames)=&gt;{ &nbsp; &nbsp; &nbsp; &nbsp; getAttrs(attrNames,(attributes)=&gt;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _.each(_.keys(attributes),(key)=&gt;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(event.newValue && /\w/.test(event.newValue)){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(new RegExp(attributes[key],'i').test(event.newValue)){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setObj[key.replace(/school/,'display_filter')]=1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setObj[key.replace(/school/,'display_filter')]=0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setObj[key.replace(/school/,'display_filter')]=1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setAttrs(setObj,{silent:true}); &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; }); }); &lt;/script&gt;
Hum, i came to the same conclusion. A text entry is a cheap solution and open to spelling mistake but it's the easiest way to do the work. My JS is realy rusty, i came to something like that before your exemple var sDisplay = {}; getSectionIDs( "repeating_spells", function(idarray) { &nbsp;&nbsp; &nbsp;getAttrs( [ "selected_school", "selected_level", "select_all", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;...idarray.map(id =&gt; `repeating_spells_${id}_spell_school`), &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;...idarray.map(id =&gt; `repeating_spells_${id}_spell_level`) ], function( v ) { &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var cur_ecole = v[ "selected_school" ]; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var cur_level = v[ "selected_level" ]; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for( var i in idarray ) { &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if( ( v[ `repeating_spells_${idarray[ i ]}_spell_school` ] ===&nbsp; cur_ecole && v[ `repeating_spells_${idarray[ i ]}_spell_level` ] ===&nbsp; cur_level ) || v[ "select_all" ] === "1" ) { &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sDisplay[ `repeating_spells_${idarray[ i ]}_spell_display` ] = 1; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} else { &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sDisplay[ `repeating_spells_${idarray[ i ]}_spell_display` ] = 0; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;setAttrs( sDisplay, { silent: true } ); &nbsp;&nbsp; &nbsp;}); }); i'll add the case sensitivity as suggested and i think that will do the work :3 But i'll definitely try to implement your work to reduce my script ;)
1526326307
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Good luck