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

Clarification for setting up one-click install with a script dependency

1639403995
David M.
Pro
API Scripter
Was curious about what steps I need to take to submit a script to the one-click repo that is dependent on an existing one-click utility script. From looking at other scripts, it looks like all I need to do is add a line in the script.json file, something like this: "dependencies": ["script1Name", "script2Name"], So for my case of my SmartAoE script depending on Tim's libInline script, it would be "dependencies": ["libInline"], Can someone confirm? Is there anything else I'm missing?
1639404906
The Aaron
Roll20 Production Team
API Scripter
That should be what you need. I'd suggest adding a check to your script that verifies libInline is installed and tells the GM when it isn't. The reason is twofold:  If people manually install the script, they need to know about the dependency. There is a horrible bug where if you add a dependency to a 1-click script people already have installed, it does not add the dependency automatically. 
1639405119
David M.
Pro
API Scripter
Great, thanks for the confirmation and the heads-up!
1639409773
David M.
Pro
API Scripter
libInline has an exposed function called getRollData that I am using. Would something as simple as this be adequate if I added it to my checkInstall function that fires on('ready'...), or is there another method you would suggest? if (typeof libInline.getRollData ===  'undefined') { //alert user here via sendChat } Will the order of installation matter? libInline and associated functions are defined as follows: const libInline = (() => {    //  << bunch of code removed >>    on('ready', () => {         versionInfo();         logsig();     });     return {         getRollData: getRollData,         getDice: getDice,         getValue: getValue,         getTables: getTables,         getParsed: getParsed,         getRollTip: getRollTip     }; })(); Seems like it would be fine since I wouldn't check for it until on('ready')?
1639411996
The Aaron
Roll20 Production Team
API Scripter
The only thing that would worry me about that would be getting a reference error if libInline is not defined.&nbsp; This is what I use for checking libTokenMarkers in TokenNameNumber: // Make sure libTokenMarkers exists, and has the functions that are expected if('undefined' === typeof libTokenMarkers || (['getStatus','getStatuses','getOrderedList'].find(k=&gt; !libTokenMarkers.hasOwnProperty(k) || 'function' !== typeof libTokenMarkers[k] )) ) { // notify of the missing library sendChat('',`/w gm &lt;div style="color:red;font-weight:bold;border:2px solid red;background-color:black;border-radius:1em;padding:1em;"&gt;Missing dependency: &lt;code&gt;libTokenMarkers&lt;/code&gt; Please install from the 1-click or download &lt;a href="<a href="https://github.com/shdwjk/Roll20API/blob/master/libTokenMarkers/libTokenMarkers.js&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;`" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/libTokenMarkers/libTokenMarkers.js"&gt;here&lt;/a&gt;.&lt;/div&gt;`</a>); return false; } else { return true; } I do this in my CheckInstall, and return true or false to note if all dependencies were satisfied, then my on('ready',...) is like this: on("ready",() =&gt; { if(checkInstall()) { registerEventHandlers(); } }); since TokenNameNumber can't function without libTokenMakers.
1639414395
David M.
Pro
API Scripter
Perfect, thanks!