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

Group Check Alphabetic Order

Group Check is one of my favorite APIs, and I use it since a long time ago. There is a detail, however, that bothers me a little: under !group-check-config --show, the list appears in the order the checks were added. When there are a lot of checks, it is cumbersome to look for a specific one. When calling !group-check with no check name, the buttons appear in the same order, and again it takes time to find the specific check needed at the moment. Is there a way of organizing the checks in alphabetical order? If there is not, how could I add it to the script? I am not especially good with JavaScript, but am able to write a couple of lines if I am given some guidelines. Thank you!
1655960542

Edited 1655961302
Oosh
Sheet Author
API Scripter
A quick skim of the script, I think this should do it. Line 928 is where this function starts, the first .sort() will sort the option keys, the second one is the checks: &nbsp; &nbsp; getConfigTable = () =&gt; { &nbsp; &nbsp; &nbsp; return "&lt;h4&gt;Current Options&lt;/h4&gt;" + &nbsp; &nbsp; &nbsp; &nbsp; "&lt;table style= \" margin:3px; \" &gt;" + &nbsp; &nbsp; &nbsp; &nbsp; "&lt;tr style= \" font-weight:bold \" &gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt;&lt;/tr&gt;" + &nbsp; &nbsp; &nbsp; &nbsp; Object . entries ( state . groupCheck . options ) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; . sort () // optionally add this &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; . map (([ key , value ]) =&gt; `&lt;tr&gt;&lt;td&gt; ${ key } &lt;/td&gt;&lt;td&gt; ${ value } &lt;/td&gt;&lt;/tr&gt;` ) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; . join ( "" ) + &nbsp; &nbsp; &nbsp; &nbsp; "&lt;/table&gt;" + &nbsp; &nbsp; &nbsp; &nbsp; "&lt;h4&gt;Checks&lt;/h4&gt;" + &nbsp; &nbsp; &nbsp; &nbsp; "&lt;table style= \" margin:3px; \" &gt;" + &nbsp; &nbsp; &nbsp; &nbsp; "&lt;tr style= \" font-weight:bold \" &gt;&lt;td&gt;Command&lt;/td&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Formula&lt;/td&gt;&lt;td&gt;Special&lt;/td&gt;&lt;/tr&gt;" + &nbsp; &nbsp; &nbsp; &nbsp; Object . entries ( state . groupCheck . checkList ) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; . sort () // add this &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; . map (([ key , value ]) =&gt; `&lt;tr&gt;&lt;td&gt; ${ key } &lt;/td&gt;&lt;td&gt; ${ value . name } &lt;/td&gt;&lt;td&gt; ${ htmlReplace ( value . formula ) } &lt;/td&gt;&lt;td&gt; ${ value . special || "" } &lt;/td&gt;&lt;/tr&gt;` ) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; . join ( "" ) + &nbsp; &nbsp; &nbsp; &nbsp; "&lt;/table&gt;" ; &nbsp; &nbsp; }, I can post the full code somewhere if you like, probably easier to just grab it from <a href="https://raw.githubusercontent.com/Roll20/roll20-api-scripts/master/GroupCheck/GroupCheck.js" rel="nofollow">https://raw.githubusercontent.com/Roll20/roll20-api-scripts/master/GroupCheck/GroupCheck.js</a> - click the Raw button, then ctrl-A to select all quickly, paste it into a new script and add the two (or just one) sort() methods. edit - I'm... actually not sure why this works, now I think about it. The array is full of Object.entries() arrays and sort shouldn't really be doing anything unless those are also unwrapped. Maybe sort() spreads them internally? Anyway, if you want a more sophisticated sort (for example, uppercase 'Z' comes before lowercase 'a' in a default sort due the character code order) that can also be done . sort (([ keyA ,], [ keyB ,]) =&gt; keyA . toLowerCase () &gt; keyB . toLowerCase () ? 1 : - 1 )
1655964502

Edited 1655964581
Thank you! It sorted the list appearing under "!group-check-config --show", but did nothing to the list of buttons under "!group-check". I guess I must find where to put another ".sort()". Even the best would be to have first saves, then skill checks, then ability checks, each section ordered alphabetically. With your help, I already have an idea of the kind of thing I must try to do. Thanks again.
1655964908
Oosh
Sheet Author
API Scripter
No problem - I haven't used the script, so didn't know about the other list. Let me know if you have any issues with that part.
Sure! Thank you again.