Quest Queue

== Summary ==
The Quest Queue automatically invites the party to the next quest specified in a Google Sheet queue whenever the party completes a quest. This script must be installed by one (and only one) member of the party (usually the party leader). All party members who own the quests to be launched by the queue must install the Launch Quests With Link script (V3 / Feb. 2023 or later).
Quest Queue was co-authored by @Snefferdy and @bumbleshoot. The script is maintained by @Snefferdy.
== Usage Instructions ==
Follow the installation instructions below. In your copy of the provided Google Sheet, the top row on the Quest Queue page is first quest in the queue and so on. First, use the column A cell's dropdown menu to select the member whose inventory the quest will launch from. Doing so will then populate the dropdown menu in the column B cell with that member's available quests. If either of the two cells is red, then you don't have a functioning Launch Quests With Link URL lined up; both cells must be cyan.
Do not edit anything on the "Inventory Data" page. This updates automatically and needs to be correct for the spreadsheet to work. The Quest Code Reference page doesn't have any function and is included simply for your reference. The cross-pages code written into the Quest Queue spreadsheet will break if the pages are copied out and into another spreadsheet. So, if you have another party spreadsheet that you want to merge with this, you should use your copy of the Quest Queue spreadsheet as the main spreadsheet, and copy the pages from the other spreadsheet into this one (using the page's tab dropdown... Copy to).
After you have completed 2500 quests using the queue, you will run out of rows on the Quest Queue spreadsheet page (the top row is deleted when that quest is launched, reducing the total number of rows on the page. When you need more rows, use the "add" button at the bottom of the page to add any number of additional lines. Next, select the last cells showing content in columns D and E, and then click/drag the small blue square in the bottom right corner of the column E cell all the way to the bottom of the newly lengthened page to fill down the necessary formulas in these two columns.
When party membership changes, or new Launch Quests With Link URLs need to be added, the script and deployment must be updated. See the Update Instructions section for more information.
Only one member should have Quest Queue installed. No party member should have any other scripts set up to automatically invite party members to quests, because they will conflict with Quest Queue.
== Installation ==
You need to use a desktop computer for this. It will not work on a phone or tablet! Note: only one party member should install this script.
# Instruct party members to install the Launch Quests With Link script. All members who want to have quests launched from the queue (including the member installing Quest Queue) need to have Launch Quests With Link (V3 or later) installed. Collect the members' web app URLs, being sure to note which URL belongs to which party member.
#Click here to go to the Quest Queue script. If you're not already signed into your Google account, you will be asked to sign in. If your browser is signed in to multiple Google Accounts, the page may not load. In this case, use another browser, a private browsing window, or sign out of all Google Accounts except the one you would like to use for Quest Queue.
# In the main menu on the left, click on "Overview" (looks like a lowercase letter i inside a circle).
# Click the "Make a copy" button (looks like two pages of paper).
# At the top of your screen, click on "Copy of Quest Queue". Rename it "Quest Queue" and click the "Rename" button.
#Click here to go to the Quest Queue Google Sheets template.
#Under the file menu, click "Make a copy".
#At the top of your screen, click on "Copy of Quest Queue Template". Rename it to whatever you like.
#Click the "Share" button near the top right corner of the page (looks like a little person). Click the drop-down under "General access", and select "Anyone with the link". Then click the "Copy link" button.
#Return to the Quest Queue script and paste the URL between the quotations where it says const SPREADSHEET_URL = "";. It should now look something like this: const SPREADSHEET_URL = "https://docs.google.com/spreadsheets/d/1-BdAT-6_dIECSSdu8VWPxsjXKEzCkGyRQd_rcKJAb3g/edit#gid=0";
# Click here to open your Habitica API Settings. Highlight and copy your User ID (it looks something like this: 35c3fb6f-fb98-4bc3-b57a-ac01137d0847). In the Quest Queue script, paste your User ID between the quotations where it says const USER_ID = "";. It should now look something like this: const USER_ID = "35c3fb6f-fb98-4bc3-b57a-ac01137d0847";
# On the same page where you copied your User ID, click the "Show API Token" button, and copy your API Token. In the Quest Queue script, paste your API Token between the quotations where it says const API_TOKEN = "";. It should now look something like this: const API_TOKEN = "35c3fb6f-fb98-4bc3-b57a-ac01137d0847";
#Click here to navigate to your Habitica Party page, and click the member list button. Click on the first member in the list and carefully copy the string of characters following "https://habitica.com/profile/" shown in the browser URL bar; this is the member's user ID. In the Quest Queue script, paste the first member's ID between the quotations where it says const USER01_ID = "";. It should now look something like this: const USER01_ID "35c3fb6f-fb98-4bc3-b57a-ac01137d0847"; If you like, you can type the member's username for future reference after the // at the end of the line.
#In your list of members' Launch Quests With Link URLs (collected in step 1), find and copy the URL for the member corresponding to the user ID you copied in the previous step. In the Quest Queue script, paste the first member's URL between the quotations where it says const USER01_LAUNCHQUESTS_URL = "";. It should now look something like this: const USER01_LAUNCHQUESTS_URL = "https://script.google.com/macros/s/AKfycbxDxx4YzG8knlv69BF4_OXkuyVPOSrjYe9XziErBD9fVRIwwo0vu6rhqsW9ZJyxPSmr/exec";. If the member does not have the Launch Quests With Link script installed, leave this line unchanged.
#Repeat steps 13 and 14 for each member in the party, progressing through the lines in the script const USER01..., const USER02..., etc. until all members' IDs and URLs have been added (including those for you, the member installing the script). Be sure that each member's URL is in the correct line with the corresponding USER## as that user's ID. Do not delete any unused lines in the script, leave all 30.
#Click the "save" button (floppy disk icon) in the toolbar.
#Click the blue "Deploy" button near the top of the page, then click "New deployment". Under "Description", type "Quest Queue" (without the quotes). Then click the "Deploy" button.
#Click the "Authorize access" button and select your Google account. Click on "Advanced", then "Go to Quest Tracker (unsafe)". (Don't worry, it is safe!) Then click the "Allow" button.
#Under "Web app", click the "Copy" button to copy the Web App URL. Then click the "Done" button.
#Paste your Web App URL inside the quotations where it says const WEB_APP_URL = "";
#(Again) click the "save" button (floppy disk icon) in the toolbar.
#Click the drop-down menu to the right of the "Debug" button, near the top of the page. Select "createWebhook" from the drop-down.
#Click the "Run" button to the left of the "Debug" button. Wait for it to say "Execution completed" at the bottom of the screen.
#Click the drop-down menu to the right of the "Debug" button, near the top of the page. Select "doPost" from the drop-down.
#Click the "Run" button to the left of the "Debug" button. Wait for it to say "Execution completed" at the bottom of the screen.
#Return to the Google Sheet and select the "Inventory Data" page tab at the bottom of the window. The page should be populated with member usernames in the first column, their corresponding Launch Quests With Link URL in the second column, and the codes for each quest in the member's inventory starting in the third column.
#You can now begin creating your queue of quests using the drop-down menus on the Quest Tracker page of the spreadsheet (tab at the bottom of the window). See Usage Instructions section above for more information about using the queue, and see the Update Instructions section below for when party membership or Launch Quests With Link URL information must be changed. Congratulations, you're done!
== Member Information Update Instructions ==
You need to use a desktop computer for this. It will not work on a phone or tablet!
When party information changes (i.e. new member joins, member leaves, Launch Quests With Link URL information changes) the script must be updated.
# Navigate to Google Apps Script, logging in to the Google Account hosting the Quest Queue script. If more than one Google Account is logged in to the browser, you may encounter errors. If so, use another browser or a private window.
#Open the Quest Queue script.
# Make the necessary changes to the lines const USER##_ID = ""; and const USER##_LAUNCHQUESTS_URL = "";. Be sure to change only the information inside the quotation marks. Do not delete the quotation marks.
#Click the "save" button (floppy disk icon) in the toolbar.
#Click the blue "Deploy" button near the top of the page, then click "Manage deployments".
#Select the Active deployment at the top of the list on the left, and then click the edit button (looks like a pencil). Click on the "Version" box and select "New version" from the drop-down. Then click the "Deploy" button.
# The changes will not be reflected in the Google Sheet until your party has next completed a quest. Be sure that the changes you have made are not related to the user from whose inventory the next queued quest will be launched. After the next quest starts, you can make changes to your queue with the updated information.
== Contact ==
If you have questions, or to report a bug contact Snefferdy on habitica.
Category:Extensions, Add-Ons, and Customizations