Skip to content

Instantly share code, notes, and snippets.

@kwhinnery
Last active September 22, 2022 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwhinnery/cff534ea37d58727be1bfdca15b3a5c5 to your computer and use it in GitHub Desktop.
Save kwhinnery/cff534ea37d58727be1bfdca15b3a5c5 to your computer and use it in GitHub Desktop.
Work in progress D&D Tools built in Retool (https://www.retool.com)
{"uuid":"6aca7a34-392b-11ed-bd49-8bb70f5219e2","page":{"id":95557202,"data":{"appState":"[\"~#iR\",[\"^ \",\"n\",\"appTemplate\",\"v\",[\"^ \",\"isFetching\",false,\"plugins\",[\"~#iOM\",[\"resetDiceRoll\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"resetDiceRoll\",\"type\",\"datasource\",\"subtype\",\"JavascriptQuery\",\"namespace\",null,\"resourceName\",\"JavascriptQuery\",\"resourceDisplayName\",null,\"template\",[\"^3\",[\"queryRefreshTime\",\"\",\"lastReceivedFromResourceAt\",null,\"queryDisabledMessage\",\"\",\"successMessage\",\"\",\"queryDisabled\",\"\",\"playgroundQuerySaveId\",\"latest\",\"resourceNameOverride\",\"\",\"runWhenModelUpdates\",false,\"showFailureToaster\",true,\"query\",\"lastDiceClicked.setValue(-1);\\ndiceRolls.setValue([]);\\ndiceRollModifier.setValue(0);\\ndiceRollDisplay.setValue(`<small><i>Roll a die...</i></small>`);\\ndiceRollTotal.setValue(`## 0`);\\n\",\"playgroundQueryUuid\",\"\",\"playgroundQueryId\",null,\"error\",null,\"privateParams\",[\"~#iL\",[]],\"runWhenPageLoadsDelay\",\"\",\"data\",null,\"importedQueryInputs\",[\"^3\",[]],\"isImported\",false,\"showSuccessToaster\",false,\"cacheKeyTtl\",\"\",\"metadata\",null,\"changesetObject\",\"\",\"errorTransformer\",\"// The variable 'data' allows you to reference the request's data in the transformer. \\n// example: return data.find(element => element.isError)\\nreturn data.error\",\"confirmationMessage\",null,\"isFetching\",false,\"changeset\",\"\",\"rawData\",null,\"queryTriggerDelay\",\"0\",\"resourceTypeOverride\",null,\"watchedParams\",[\"^:\",[]],\"enableErrorTransformer\",false,\"showLatestVersionUpdatedWarning\",false,\"timestamp\",0,\"importedQueryDefaults\",[\"^3\",[]],\"enableTransformer\",false,\"showUpdateSetValueDynamicallyToggle\",true,\"runWhenPageLoads\",false,\"transformer\",\"// type your code here\\n// example: return formatDataAsArray(data).filter(row => row.quantity > 20)\\nreturn data\",\"events\",[\"^:\",[]],\"queryTimeout\",\"10000\",\"requireConfirmation\",false,\"queryFailureConditions\",\"\",\"changesetIsObject\",false,\"enableCaching\",false,\"allowedGroups\",[\"^:\",[]],\"queryThrottleTime\",\"750\",\"updateSetValueDynamically\",false,\"notificationDuration\",\"\"]],\"style\",null,\"position2\",null,\"mobilePosition2\",null,\"mobileAppPosition\",null,\"tabIndex\",null,\"container\",\"\",\"createdAt\",\"~m1663636735617\",\"updatedAt\",\"~m1663637756924\",\"folder\",\"actions\",\"screen\",null]]],\"rollDice\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"rollDice\",\"^4\",\"datasource\",\"^5\",\"JavascriptQuery\",\"^6\",null,\"^7\",\"JavascriptQuery\",\"^8\",null,\"^9\",[\"^3\",[\"queryRefreshTime\",\"\",\"lastReceivedFromResourceAt\",null,\"queryDisabledMessage\",\"\",\"successMessage\",\"\",\"queryDisabled\",\"\",\"playgroundQuerySaveId\",\"latest\",\"resourceNameOverride\",\"\",\"runWhenModelUpdates\",false,\"showFailureToaster\",false,\"query\",\"// Don't process unless we have a valid dice roll\\nif (lastDiceClicked.value < 0) {\\n return;\\n}\\n\\n// Generate a dice roll, capturing the current modifier\\nconst diceRoll = {\\n dieRolled: lastDiceClicked.value,\\n modifier: diceRollModifier.value,\\n value: Math.floor(Math.random() * lastDiceClicked.value) + 1,\\n};\\n\\n// Gather all rolls\\nconst allRolls = diceRolls.value.concat([ diceRoll ]);\\n\\n// Calculate and display the current roll results\\nconst detailString = [];\\nlet runningTotal = 0;\\n\\nallRolls.forEach(roll => {\\n const totalRollValue = roll.modifier + roll.value;\\n runningTotal += totalRollValue;\\n \\n let rollString = ' ';\\n if (roll.modifier >= 1) {\\n rollString = `+ ${roll.modifier} `;\\n } else if (roll.modifier < 0) {\\n rollString = `- ${Math.abs(roll.modifier)} `;\\n }\\n \\n detailString.push(`(1d${roll.dieRolled} -> ${roll.value}) ${rollString}= ${totalRollValue}`);\\n});\\n\\n// Update UI with calculated values\\ndiceRollDisplay.setValue('<small>' + detailString.join(', ') + '</small>');\\ndiceRollTotal.setValue(`## ${runningTotal}`);\\n\\n// Update state\\ndiceRolls.setValue(allRolls);\\n\",\"playgroundQueryUuid\",\"\",\"playgroundQueryId\",null,\"error\",null,\"privateParams\",[\"^:\",[]],\"runWhenPageLoadsDelay\",\"\",\"data\",null,\"importedQueryInputs\",[\"^3\",[]],\"isImported\",false,\"showSuccessToaster\",false,\"cacheKeyTtl\",\"\",\"metadata\",null,\"changesetObject\",\"\",\"errorTransformer\",\"// The variable 'data' allows you to reference the request's data in the transformer. \\n// example: return data.find(element => element.isError)\\nreturn data.error\",\"confirmationMessage\",null,\"isFetching\",false,\"changeset\",\"\",\"rawData\",null,\"queryTriggerDelay\",\"0\",\"resourceTypeOverride\",null,\"watchedParams\",[\"^:\",[]],\"enableErrorTransformer\",false,\"showLatestVersionUpdatedWarning\",false,\"timestamp\",0,\"importedQueryDefaults\",[\"^3\",[]],\"enableTransformer\",false,\"showUpdateSetValueDynamicallyToggle\",true,\"runWhenPageLoads\",false,\"transformer\",\"// type your code here\\n// example: return formatDataAsArray(data).filter(row => row.quantity > 20)\\nreturn data\",\"events\",[\"^:\",[]],\"queryTimeout\",\"10000\",\"requireConfirmation\",false,\"queryFailureConditions\",\"\",\"changesetIsObject\",false,\"enableCaching\",false,\"allowedGroups\",[\"^:\",[]],\"queryThrottleTime\",\"750\",\"updateSetValueDynamically\",false,\"notificationDuration\",\"\"]],\"^;\",null,\"^<\",null,\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663620585064\",\"^B\",\"~m1663636560794\",\"^C\",\"actions\",\"^D\",null]]],\"diceRolls\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"diceRolls\",\"^4\",\"state\",\"^5\",\"State\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"_persistedValueGetter\",null,\"_persistedValueSetter\",null,\"persistValue\",false,\"persistedValueKey\",\"\",\"value\",\"[]\"]],\"^;\",null,\"^<\",null,\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663611726243\",\"^B\",\"~m1663611769006\",\"^C\",\"appState\",\"^D\",null]]],\"lastDiceClicked\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"lastDiceClicked\",\"^4\",\"state\",\"^5\",\"State\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"_persistedValueGetter\",null,\"_persistedValueSetter\",null,\"persistValue\",false,\"persistedValueKey\",\"\",\"value\",\"-1\"]],\"^;\",null,\"^<\",null,\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663621123825\",\"^B\",\"~m1663632461146\",\"^C\",\"appState\",\"^D\",null]]],\"appHeader\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"appHeader\",\"^4\",\"widget\",\"^5\",\"TextWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"heightType\",\"fixed\",\"horizontalAlign\",\"left\",\"hidden\",false,\"imageWidth\",\"fit\",\"showInEditor\",false,\"verticalAlign\",\"center\",\"tooltipText\",\"\",\"value\",\"# Retool D&D\",\"disableMarkdown\",false,\"overflowType\",\"scroll\",\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"rowGroup\",\"body\",\"subcontainer\",\"header\",\"row\",-1.1102230246251565e-16,\"col\",1,\"height\",2.5999999999999996,\"width\",4,\"tabNum\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610022677\",\"^B\",\"~m1663636126386\",\"^C\",\"\",\"^D\",null]]],\"$header\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"$header\",\"^4\",\"frame\",\"^5\",\"Frame\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"type\",\"header\",\"sticky\",true,\"isHiddenOnDesktop\",false,\"isHiddenOnMobile\",false]],\"^;\",[\"^3\",[]],\"^<\",null,\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610022712\",\"^B\",\"~m1663610022712\",\"^C\",\"\",\"^D\",null]]],\"dndLogo\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"dndLogo\",\"^4\",\"widget\",\"^5\",\"ImageWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"heightType\",\"fixed\",\"horizontalAlign\",\"center\",\"srcWidth\",512,\"clickable\",false,\"src\",\"https://static.thenounproject.com/png/763027-200.png\",\"hidden\",false,\"srcHeight\",512,\"showInEditor\",false,\"tooltipText\",\"\",\"fit\",\"contain\",\"aspectRatio\",null,\"storageBlobId\",\"89fe5416-66be-43fc-890f-116c4ab28dfd\",\"altText\",\"\",\"dbBlobId\",\"\",\"events\",[\"^3\",[]],\"srcType\",\"src\",\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",0,\"col\",0,\"^G\",2.5999999999999996,\"^H\",1,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610076712\",\"^B\",\"~m1663804217168\",\"^C\",\"\",\"^D\",null]]],\"roll_12\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"roll_12\",\"^4\",\"widget\",\"^5\",\"ButtonWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"horizontalAlign\",\"stretch\",\"clickable\",false,\"iconAfter\",\"\",\"submitTargetId\",null,\"hidden\",false,\"text\",\"d12\",\"showInEditor\",false,\"tooltipText\",\"\",\"styleVariant\",\"solid\",\"submit\",false,\"iconBefore\",\"bold/entertainment-leisure-chess-piece-dice\",\"events\",[\"^:\",[[\"^3\",[\"event\",\"click\",\"type\",\"state\",\"method\",\"setValue\",\"pluginId\",\"lastDiceClicked\",\"targetId\",null,\"params\",[\"^3\",[\"value\",\"12\"]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]],[\"^3\",[\"event\",\"click\",\"type\",\"datasource\",\"method\",\"trigger\",\"pluginId\",\"rollDice\",\"targetId\",null,\"params\",[\"^3\",[]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]]]],\"loading\",false,\"loaderPosition\",\"auto\",\"disabled\",false,\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",0,\"col\",9,\"^G\",0.8,\"^H\",1,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610284912\",\"^B\",\"~m1663804315232\",\"^C\",\"\",\"^D\",null]]],\"roll_d20\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"roll_d20\",\"^4\",\"widget\",\"^5\",\"ButtonWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"horizontalAlign\",\"stretch\",\"clickable\",false,\"iconAfter\",\"\",\"submitTargetId\",null,\"hidden\",false,\"text\",\"d20\",\"showInEditor\",false,\"tooltipText\",\"\",\"styleVariant\",\"solid\",\"submit\",false,\"iconBefore\",\"bold/entertainment-leisure-chess-piece-dice\",\"events\",[\"^:\",[[\"^3\",[\"event\",\"click\",\"type\",\"state\",\"method\",\"setValue\",\"pluginId\",\"lastDiceClicked\",\"targetId\",null,\"params\",[\"^3\",[\"value\",\"20\"]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]],[\"^3\",[\"event\",\"click\",\"type\",\"datasource\",\"method\",\"trigger\",\"pluginId\",\"rollDice\",\"targetId\",null,\"params\",[\"^3\",[]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]]]],\"loading\",false,\"loaderPosition\",\"auto\",\"disabled\",false,\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",0.8,\"col\",9,\"^G\",0.8,\"^H\",1,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610308608\",\"^B\",\"~m1663804324028\",\"^C\",\"\",\"^D\",null]]],\"roll_d10\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"roll_d10\",\"^4\",\"widget\",\"^5\",\"ButtonWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"horizontalAlign\",\"stretch\",\"clickable\",false,\"iconAfter\",\"\",\"submitTargetId\",null,\"hidden\",false,\"text\",\"d10\",\"showInEditor\",false,\"tooltipText\",\"\",\"styleVariant\",\"solid\",\"submit\",false,\"iconBefore\",\"bold/entertainment-leisure-chess-piece-dice\",\"events\",[\"^:\",[[\"^3\",[\"event\",\"click\",\"type\",\"state\",\"method\",\"setValue\",\"pluginId\",\"lastDiceClicked\",\"targetId\",null,\"params\",[\"^3\",[\"value\",\"10\"]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]],[\"^3\",[\"event\",\"click\",\"type\",\"datasource\",\"method\",\"trigger\",\"pluginId\",\"rollDice\",\"targetId\",null,\"params\",[\"^3\",[]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]]]],\"loading\",false,\"loaderPosition\",\"auto\",\"disabled\",false,\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",0.7999999999999998,\"col\",8,\"^G\",0.8,\"^H\",1,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610329488\",\"^B\",\"~m1663804305896\",\"^C\",\"\",\"^D\",null]]],\"roll_d8\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"roll_d8\",\"^4\",\"widget\",\"^5\",\"ButtonWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"horizontalAlign\",\"stretch\",\"clickable\",false,\"iconAfter\",\"\",\"submitTargetId\",null,\"hidden\",false,\"text\",\"d8\",\"showInEditor\",false,\"tooltipText\",\"\",\"styleVariant\",\"solid\",\"submit\",false,\"iconBefore\",\"bold/entertainment-leisure-chess-piece-dice\",\"events\",[\"^:\",[[\"^3\",[\"event\",\"click\",\"type\",\"state\",\"method\",\"setValue\",\"pluginId\",\"lastDiceClicked\",\"targetId\",null,\"params\",[\"^3\",[\"value\",\"8\"]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]],[\"^3\",[\"event\",\"click\",\"type\",\"datasource\",\"method\",\"trigger\",\"pluginId\",\"rollDice\",\"targetId\",null,\"params\",[\"^3\",[]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]]]],\"loading\",false,\"loaderPosition\",\"auto\",\"disabled\",false,\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",0,\"col\",8,\"^G\",0.8,\"^H\",1,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610329565\",\"^B\",\"~m1663804296735\",\"^C\",\"\",\"^D\",null]]],\"roll_d6\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"roll_d6\",\"^4\",\"widget\",\"^5\",\"ButtonWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"horizontalAlign\",\"stretch\",\"clickable\",false,\"iconAfter\",\"\",\"submitTargetId\",null,\"hidden\",false,\"text\",\"d6\",\"showInEditor\",false,\"tooltipText\",\"\",\"styleVariant\",\"solid\",\"submit\",false,\"iconBefore\",\"bold/entertainment-leisure-chess-piece-dice\",\"events\",[\"^:\",[[\"^3\",[\"event\",\"click\",\"type\",\"state\",\"method\",\"setValue\",\"pluginId\",\"lastDiceClicked\",\"targetId\",null,\"params\",[\"^3\",[\"value\",\"6\"]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]],[\"^3\",[\"event\",\"click\",\"type\",\"datasource\",\"method\",\"trigger\",\"pluginId\",\"rollDice\",\"targetId\",null,\"params\",[\"^3\",[]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]]]],\"loading\",false,\"loaderPosition\",\"auto\",\"disabled\",false,\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",0.7999999999999998,\"col\",7,\"^G\",0.8,\"^H\",1,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610571887\",\"^B\",\"~m1663804282431\",\"^C\",\"\",\"^D\",null]]],\"roll_d4\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"roll_d4\",\"^4\",\"widget\",\"^5\",\"ButtonWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"horizontalAlign\",\"stretch\",\"clickable\",false,\"iconAfter\",\"\",\"submitTargetId\",null,\"hidden\",false,\"text\",\"d4\",\"showInEditor\",false,\"tooltipText\",\"\",\"styleVariant\",\"solid\",\"submit\",false,\"iconBefore\",\"bold/entertainment-leisure-chess-piece-dice\",\"events\",[\"^:\",[[\"^3\",[\"event\",\"click\",\"type\",\"state\",\"method\",\"setValue\",\"pluginId\",\"lastDiceClicked\",\"targetId\",null,\"params\",[\"^3\",[\"value\",\"4\"]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]],[\"^3\",[\"event\",\"click\",\"type\",\"datasource\",\"method\",\"trigger\",\"pluginId\",\"rollDice\",\"targetId\",null,\"params\",[\"^3\",[]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]]]],\"loading\",false,\"loaderPosition\",\"auto\",\"disabled\",false,\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",0,\"col\",7,\"^G\",0.8,\"^H\",1,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610571997\",\"^B\",\"~m1663804267931\",\"^C\",\"\",\"^D\",null]]],\"diceRollModifier\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"diceRollModifier\",\"^4\",\"widget\",\"^5\",\"NumberInputWidget\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"readOnly\",false,\"iconAfter\",\"\",\"max\",null,\"inputValue\",0,\"hidden\",false,\"customValidation\",\"\",\"showSeparators\",true,\"hideValidationMessage\",false,\"textBefore\",\"\",\"validationMessage\",\"\",\"textAfter\",\"\",\"showInEditor\",false,\"allowNull\",false,\"showClear\",false,\"tooltipText\",\"\",\"currency\",\"USD\",\"labelAlign\",\"right\",\"formDataKey\",\"{{ self.id }}\",\"value\",0,\"labelCaption\",\"\",\"min\",null,\"labelWidth\",\"33\",\"placeholder\",\"Enter value\",\"showStepper\",true,\"label\",\"Modifier\",\"_validate\",false,\"labelWidthUnit\",\"%\",\"invalid\",false,\"format\",\"decimal\",\"iconBefore\",\"\",\"textAlign\",\"left\",\"inputTooltip\",\"\",\"events\",[\"^:\",[[\"^3\",[\"event\",\"submit\",\"type\",\"datasource\",\"method\",\"trigger\",\"pluginId\",\"rollDice\",\"targetId\",null,\"params\",[\"^3\",[]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]]]],\"loading\",false,\"disabled\",false,\"labelPosition\",\"left\",\"decimalPlaces\",null,\"labelWrap\",false,\"padDecimal\",false,\"maintainSpaceWhenHidden\",false,\"required\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",1.6,\"col\",7,\"^G\",1,\"^H\",2,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663610649810\",\"^B\",\"~m1663635016009\",\"^C\",\"\",\"^D\",null]]],\"$main\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"$main\",\"^4\",\"frame\",\"^5\",\"Frame\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"type\",\"main\",\"sticky\",false,\"isHiddenOnDesktop\",false,\"isHiddenOnMobile\",false]],\"^;\",[\"^3\",[]],\"^<\",null,\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663611064755\",\"^B\",\"~m1663611064755\",\"^C\",\"\",\"^D\",null]]],\"diceRollClear\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"diceRollClear\",\"^4\",\"widget\",\"^5\",\"ButtonWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"horizontalAlign\",\"stretch\",\"clickable\",false,\"iconAfter\",\"\",\"submitTargetId\",\"\",\"hidden\",false,\"text\",\"Clear\\n\",\"showInEditor\",false,\"tooltipText\",\"\",\"style\",[\"^3\",[\"background\",\"canvas\",\"border\",\"rgb(69, 69, 69)\"]],\"styleVariant\",\"solid\",\"submit\",false,\"iconBefore\",\"\",\"events\",[\"^:\",[[\"^3\",[\"event\",\"click\",\"type\",\"datasource\",\"method\",\"trigger\",\"pluginId\",\"resetDiceRoll\",\"targetId\",null,\"params\",[\"^3\",[]],\"waitType\",\"debounce\",\"waitMs\",\"0\"]]]],\"loading\",false,\"loaderPosition\",\"auto\",\"disabled\",false,\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",1.6,\"col\",9,\"^G\",1,\"^H\",1,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663611174886\",\"^B\",\"~m1663637881775\",\"^C\",\"\",\"^D\",null]]],\"diceRollDisplay\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"diceRollDisplay\",\"^4\",\"widget\",\"^5\",\"TextWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"heightType\",\"fixed\",\"horizontalAlign\",\"center\",\"hidden\",false,\"imageWidth\",\"fit\",\"showInEditor\",false,\"verticalAlign\",\"center\",\"tooltipText\",\"\",\"value\",\"<small><i>Use the buttons on the left to roll a virtual dice - the result is displayed here.</i></small>\",\"disableMarkdown\",false,\"overflowType\",\"scroll\",\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",0,\"col\",10,\"^G\",1.6,\"^H\",2,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663611279185\",\"^B\",\"~m1663637496540\",\"^C\",\"\",\"^D\",null]]],\"diceRollTotal\",[\"^0\",[\"^ \",\"n\",\"pluginTemplate\",\"v\",[\"^ \",\"id\",\"diceRollTotal\",\"^4\",\"widget\",\"^5\",\"TextWidget2\",\"^6\",null,\"^7\",null,\"^8\",null,\"^9\",[\"^3\",[\"heightType\",\"fixed\",\"horizontalAlign\",\"center\",\"hidden\",false,\"imageWidth\",\"fit\",\"showInEditor\",false,\"verticalAlign\",\"center\",\"tooltipText\",\"\",\"value\",\"## -\",\"disableMarkdown\",false,\"overflowType\",\"scroll\",\"maintainSpaceWhenHidden\",false]],\"^;\",[\"^3\",[]],\"^<\",[\"^0\",[\"^ \",\"n\",\"position2\",\"v\",[\"^ \",\"^@\",\"\",\"^E\",\"body\",\"^F\",\"header\",\"row\",1.5999999999999996,\"col\",10,\"^G\",0.9999999999999999,\"^H\",2,\"^I\",0]]],\"^=\",null,\"^>\",null,\"^?\",null,\"^@\",\"\",\"^A\",\"~m1663611306475\",\"^B\",\"~m1663804451576\",\"^C\",\"\",\"^D\",null]]]]],\"^A\",null,\"version\",\"2.100.1\",\"appThemeId\",null,\"preloadedAppJavaScript\",null,\"preloadedAppJSLinks\",[],\"testEntities\",[],\"tests\",[],\"appStyles\",\"\",\"responsiveLayoutDisabled\",false,\"loadingIndicatorsDisabled\",false,\"urlFragmentDefinitions\",[\"^:\",[]],\"pageLoadValueOverrides\",[\"^:\",[]],\"customDocumentTitle\",\"\",\"customDocumentTitleEnabled\",false,\"customShortcuts\",[],\"isGlobalWidget\",false,\"isMobileApp\",false,\"multiScreenMobileApp\",false,\"folders\",[\"^:\",[\"appState\",\"actions\"]],\"queryStatusVisibility\",false,\"markdownLinkBehavior\",\"auto\",\"inAppRetoolPillAppearance\",\"NO_OVERRIDE\",\"rootScreen\",null,\"instrumentationEnabled\",false,\"experimentalPerfFeatures\",[\"^ \",\"batchCommitModelEnabled\",false,\"skipDepCycleCheckingEnabled\",false,\"serverDepGraphEnabled\",false,\"useRuntimeV2\",false],\"experimentalDataTabEnabled\",true]]]"},"changesRecord":[{"type":"MIGRATIONS_UP_TO_DATE","payload":{"migratedAppTemplate":{"tests":[],"folders":["appState","actions"],"plugins":{"$main":{"id":"$main","type":"frame","style":{},"folder":"","screen":null,"subtype":"Frame","tabIndex":null,"template":{"type":"main","sticky":false,"isHiddenOnMobile":false,"isHiddenOnDesktop":false},"container":"","createdAt":"2022-09-19T18:11:04.755Z","namespace":null,"position2":null,"updatedAt":"2022-09-19T18:11:04.755Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"$header":{"id":"$header","type":"frame","style":{},"folder":"","screen":null,"subtype":"Frame","tabIndex":null,"template":{"type":"header","sticky":true,"isHiddenOnMobile":false,"isHiddenOnDesktop":false},"container":"","createdAt":"2022-09-19T17:53:42.712Z","namespace":null,"position2":null,"updatedAt":"2022-09-19T17:53:42.712Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"dndLogo":{"id":"dndLogo","type":"widget","style":{},"folder":"","screen":null,"subtype":"ImageWidget2","tabIndex":null,"template":{"fit":"contain","src":"https://static.thenounproject.com/png/763027-200.png","events":{},"hidden":false,"altText":"","srcType":"src","dbBlobId":"","srcWidth":512,"clickable":false,"srcHeight":512,"heightType":"fixed","aspectRatio":null,"tooltipText":"","showInEditor":false,"storageBlobId":"89fe5416-66be-43fc-890f-116c4ab28dfd","horizontalAlign":"center","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T17:54:36.712Z","namespace":null,"position2":{"col":0,"row":0,"width":1,"height":2.5999999999999996,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-21T23:50:17.168Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"roll_12":{"id":"roll_12","type":"widget","style":{},"folder":"","screen":null,"subtype":"ButtonWidget2","tabIndex":null,"template":{"text":"d12","events":[{"type":"state","event":"click","method":"setValue","params":{"value":"12"},"waitMs":"0","pluginId":"lastDiceClicked","targetId":null,"waitType":"debounce"},{"type":"datasource","event":"click","method":"trigger","params":{},"waitMs":"0","pluginId":"rollDice","targetId":null,"waitType":"debounce"}],"hidden":false,"submit":false,"loading":false,"disabled":false,"clickable":false,"iconAfter":"","iconBefore":"bold/entertainment-leisure-chess-piece-dice","tooltipText":"","showInEditor":false,"styleVariant":"solid","loaderPosition":"auto","submitTargetId":null,"horizontalAlign":"stretch","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T17:58:04.912Z","namespace":null,"position2":{"col":9,"row":0,"width":1,"height":0.8,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-21T23:51:55.232Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"roll_d4":{"id":"roll_d4","type":"widget","style":{},"folder":"","screen":null,"subtype":"ButtonWidget2","tabIndex":null,"template":{"text":"d4","events":[{"type":"state","event":"click","method":"setValue","params":{"value":"4"},"waitMs":"0","pluginId":"lastDiceClicked","targetId":null,"waitType":"debounce"},{"type":"datasource","event":"click","method":"trigger","params":{},"waitMs":"0","pluginId":"rollDice","targetId":null,"waitType":"debounce"}],"hidden":false,"submit":false,"loading":false,"disabled":false,"clickable":false,"iconAfter":"","iconBefore":"bold/entertainment-leisure-chess-piece-dice","tooltipText":"","showInEditor":false,"styleVariant":"solid","loaderPosition":"auto","submitTargetId":null,"horizontalAlign":"stretch","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T18:02:51.997Z","namespace":null,"position2":{"col":7,"row":0,"width":1,"height":0.8,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-21T23:51:07.931Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"roll_d6":{"id":"roll_d6","type":"widget","style":{},"folder":"","screen":null,"subtype":"ButtonWidget2","tabIndex":null,"template":{"text":"d6","events":[{"type":"state","event":"click","method":"setValue","params":{"value":"6"},"waitMs":"0","pluginId":"lastDiceClicked","targetId":null,"waitType":"debounce"},{"type":"datasource","event":"click","method":"trigger","params":{},"waitMs":"0","pluginId":"rollDice","targetId":null,"waitType":"debounce"}],"hidden":false,"submit":false,"loading":false,"disabled":false,"clickable":false,"iconAfter":"","iconBefore":"bold/entertainment-leisure-chess-piece-dice","tooltipText":"","showInEditor":false,"styleVariant":"solid","loaderPosition":"auto","submitTargetId":null,"horizontalAlign":"stretch","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T18:02:51.887Z","namespace":null,"position2":{"col":7,"row":0.7999999999999998,"width":1,"height":0.8,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-21T23:51:22.431Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"roll_d8":{"id":"roll_d8","type":"widget","style":{},"folder":"","screen":null,"subtype":"ButtonWidget2","tabIndex":null,"template":{"text":"d8","events":[{"type":"state","event":"click","method":"setValue","params":{"value":"8"},"waitMs":"0","pluginId":"lastDiceClicked","targetId":null,"waitType":"debounce"},{"type":"datasource","event":"click","method":"trigger","params":{},"waitMs":"0","pluginId":"rollDice","targetId":null,"waitType":"debounce"}],"hidden":false,"submit":false,"loading":false,"disabled":false,"clickable":false,"iconAfter":"","iconBefore":"bold/entertainment-leisure-chess-piece-dice","tooltipText":"","showInEditor":false,"styleVariant":"solid","loaderPosition":"auto","submitTargetId":null,"horizontalAlign":"stretch","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T17:58:49.565Z","namespace":null,"position2":{"col":8,"row":0,"width":1,"height":0.8,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-21T23:51:36.735Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"rollDice":{"id":"rollDice","type":"datasource","style":null,"folder":"actions","screen":null,"subtype":"JavascriptQuery","tabIndex":null,"template":{"data":null,"error":null,"query":"// Don't process unless we have a valid dice roll\nif (lastDiceClicked.value < 0) {\n return;\n}\n\n// Generate a dice roll, capturing the current modifier\nconst diceRoll = {\n dieRolled: lastDiceClicked.value,\n modifier: diceRollModifier.value,\n value: Math.floor(Math.random() * lastDiceClicked.value) + 1,\n};\n\n// Gather all rolls\nconst allRolls = diceRolls.value.concat([ diceRoll ]);\n\n// Calculate and display the current roll results\nconst detailString = [];\nlet runningTotal = 0;\n\nallRolls.forEach(roll => {\n const totalRollValue = roll.modifier + roll.value;\n runningTotal += totalRollValue;\n \n let rollString = ' ';\n if (roll.modifier >= 1) {\n rollString = `+ ${roll.modifier} `;\n } else if (roll.modifier < 0) {\n rollString = `- ${Math.abs(roll.modifier)} `;\n }\n \n detailString.push(`(1d${roll.dieRolled} -> ${roll.value}) ${rollString}= ${totalRollValue}`);\n});\n\n// Update UI with calculated values\ndiceRollDisplay.setValue('<small>' + detailString.join(', ') + '</small>');\ndiceRollTotal.setValue(`## ${runningTotal}`);\n\n// Update state\ndiceRolls.setValue(allRolls);\n","events":[],"rawData":null,"metadata":null,"changeset":"","timestamp":0,"isFetching":false,"isImported":false,"cacheKeyTtl":"","transformer":"// type your code here\n// example: return formatDataAsArray(data).filter(row => row.quantity > 20)\nreturn data","queryTimeout":"10000","allowedGroups":[],"enableCaching":false,"privateParams":[],"queryDisabled":"","watchedParams":[],"successMessage":"","changesetObject":"","errorTransformer":"// The variable 'data' allows you to reference the request's data in the transformer. \n// example: return data.find(element => element.isError)\nreturn data.error","queryRefreshTime":"","runWhenPageLoads":false,"changesetIsObject":false,"enableTransformer":false,"playgroundQueryId":null,"queryThrottleTime":"750","queryTriggerDelay":"0","showFailureToaster":false,"showSuccessToaster":false,"confirmationMessage":null,"importedQueryInputs":{},"playgroundQueryUuid":"","requireConfirmation":false,"runWhenModelUpdates":false,"notificationDuration":"","queryDisabledMessage":"","resourceNameOverride":"","resourceTypeOverride":null,"importedQueryDefaults":{},"playgroundQuerySaveId":"latest","runWhenPageLoadsDelay":"","enableErrorTransformer":false,"queryFailureConditions":"","updateSetValueDynamically":false,"lastReceivedFromResourceAt":null,"showLatestVersionUpdatedWarning":false,"showUpdateSetValueDynamicallyToggle":true},"container":"","createdAt":"2022-09-19T20:49:45.064Z","namespace":null,"position2":null,"updatedAt":"2022-09-20T01:16:00.794Z","resourceName":"JavascriptQuery","mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"roll_d10":{"id":"roll_d10","type":"widget","style":{},"folder":"","screen":null,"subtype":"ButtonWidget2","tabIndex":null,"template":{"text":"d10","events":[{"type":"state","event":"click","method":"setValue","params":{"value":"10"},"waitMs":"0","pluginId":"lastDiceClicked","targetId":null,"waitType":"debounce"},{"type":"datasource","event":"click","method":"trigger","params":{},"waitMs":"0","pluginId":"rollDice","targetId":null,"waitType":"debounce"}],"hidden":false,"submit":false,"loading":false,"disabled":false,"clickable":false,"iconAfter":"","iconBefore":"bold/entertainment-leisure-chess-piece-dice","tooltipText":"","showInEditor":false,"styleVariant":"solid","loaderPosition":"auto","submitTargetId":null,"horizontalAlign":"stretch","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T17:58:49.488Z","namespace":null,"position2":{"col":8,"row":0.7999999999999998,"width":1,"height":0.8,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-21T23:51:45.896Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"roll_d20":{"id":"roll_d20","type":"widget","style":{},"folder":"","screen":null,"subtype":"ButtonWidget2","tabIndex":null,"template":{"text":"d20","events":[{"type":"state","event":"click","method":"setValue","params":{"value":"20"},"waitMs":"0","pluginId":"lastDiceClicked","targetId":null,"waitType":"debounce"},{"type":"datasource","event":"click","method":"trigger","params":{},"waitMs":"0","pluginId":"rollDice","targetId":null,"waitType":"debounce"}],"hidden":false,"submit":false,"loading":false,"disabled":false,"clickable":false,"iconAfter":"","iconBefore":"bold/entertainment-leisure-chess-piece-dice","tooltipText":"","showInEditor":false,"styleVariant":"solid","loaderPosition":"auto","submitTargetId":null,"horizontalAlign":"stretch","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T17:58:28.608Z","namespace":null,"position2":{"col":9,"row":0.8,"width":1,"height":0.8,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-21T23:52:04.028Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"appHeader":{"id":"appHeader","type":"widget","style":{},"folder":"","screen":null,"subtype":"TextWidget2","tabIndex":null,"template":{"value":"# Retool D&D","hidden":false,"heightType":"fixed","imageWidth":"fit","tooltipText":"","overflowType":"scroll","showInEditor":false,"verticalAlign":"center","disableMarkdown":false,"horizontalAlign":"left","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T17:53:42.677Z","namespace":null,"position2":{"col":1,"row":-1.1102230246251565e-16,"width":4,"height":2.5999999999999996,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-20T01:08:46.386Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"diceRolls":{"id":"diceRolls","type":"state","style":null,"folder":"appState","screen":null,"subtype":"State","tabIndex":null,"template":{"value":"[]","persistValue":false,"persistedValueKey":"","_persistedValueGetter":null,"_persistedValueSetter":null},"container":"","createdAt":"2022-09-19T18:22:06.243Z","namespace":null,"position2":null,"updatedAt":"2022-09-19T18:22:49.006Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"diceRollClear":{"id":"diceRollClear","type":"widget","style":{},"folder":"","screen":null,"subtype":"ButtonWidget2","tabIndex":null,"template":{"text":"Clear\n","style":{"border":"rgb(69, 69, 69)","background":"canvas"},"events":[{"type":"datasource","event":"click","method":"trigger","params":{},"waitMs":"0","pluginId":"resetDiceRoll","targetId":null,"waitType":"debounce"}],"hidden":false,"submit":false,"loading":false,"disabled":false,"clickable":false,"iconAfter":"","iconBefore":"","tooltipText":"","showInEditor":false,"styleVariant":"solid","loaderPosition":"auto","submitTargetId":"","horizontalAlign":"stretch","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T18:12:54.886Z","namespace":null,"position2":{"col":9,"row":1.6,"width":1,"height":1,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-20T01:38:01.775Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"diceRollTotal":{"id":"diceRollTotal","type":"widget","style":{},"folder":"","screen":null,"subtype":"TextWidget2","tabIndex":null,"template":{"value":"## 0","hidden":false,"heightType":"fixed","imageWidth":"fit","tooltipText":"","overflowType":"scroll","showInEditor":false,"verticalAlign":"center","disableMarkdown":false,"horizontalAlign":"center","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T18:15:06.475Z","namespace":null,"position2":{"col":10,"row":1.5999999999999996,"width":2,"height":0.9999999999999999,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-20T01:09:13.652Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"resetDiceRoll":{"id":"resetDiceRoll","type":"datasource","style":null,"folder":"actions","screen":null,"subtype":"JavascriptQuery","tabIndex":null,"template":{"data":null,"error":null,"query":"lastDiceClicked.setValue(-1);\ndiceRolls.setValue([]);\ndiceRollModifier.setValue(0);\ndiceRollDisplay.setValue(`<small><i>Roll a die...</i></small>`);\ndiceRollTotal.setValue(`## 0`);\n","events":[],"rawData":null,"metadata":null,"changeset":"","timestamp":0,"isFetching":false,"isImported":false,"cacheKeyTtl":"","transformer":"// type your code here\n// example: return formatDataAsArray(data).filter(row => row.quantity > 20)\nreturn data","queryTimeout":"10000","allowedGroups":[],"enableCaching":false,"privateParams":[],"queryDisabled":"","watchedParams":[],"successMessage":"","changesetObject":"","errorTransformer":"// The variable 'data' allows you to reference the request's data in the transformer. \n// example: return data.find(element => element.isError)\nreturn data.error","queryRefreshTime":"","runWhenPageLoads":false,"changesetIsObject":false,"enableTransformer":false,"playgroundQueryId":null,"queryThrottleTime":"750","queryTriggerDelay":"0","showFailureToaster":true,"showSuccessToaster":false,"confirmationMessage":null,"importedQueryInputs":{},"playgroundQueryUuid":"","requireConfirmation":false,"runWhenModelUpdates":false,"notificationDuration":"","queryDisabledMessage":"","resourceNameOverride":"","resourceTypeOverride":null,"importedQueryDefaults":{},"playgroundQuerySaveId":"latest","runWhenPageLoadsDelay":"","enableErrorTransformer":false,"queryFailureConditions":"","updateSetValueDynamically":false,"lastReceivedFromResourceAt":null,"showLatestVersionUpdatedWarning":false,"showUpdateSetValueDynamicallyToggle":true},"container":"","createdAt":"2022-09-20T01:18:55.617Z","namespace":null,"position2":null,"updatedAt":"2022-09-20T01:35:56.924Z","resourceName":"JavascriptQuery","mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"diceRollDisplay":{"id":"diceRollDisplay","type":"widget","style":{},"folder":"","screen":null,"subtype":"TextWidget2","tabIndex":null,"template":{"value":"<small><i>Use the buttons on the left to roll a virtual dice - the result is displayed here.</i></small>","hidden":false,"heightType":"fixed","imageWidth":"fit","tooltipText":"","overflowType":"scroll","showInEditor":false,"verticalAlign":"center","disableMarkdown":false,"horizontalAlign":"center","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T18:14:39.185Z","namespace":null,"position2":{"col":10,"row":0,"width":2,"height":1.6,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-20T01:31:36.540Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"lastDiceClicked":{"id":"lastDiceClicked","type":"state","style":null,"folder":"appState","screen":null,"subtype":"State","tabIndex":null,"template":{"value":"-1","persistValue":false,"persistedValueKey":"","_persistedValueGetter":null,"_persistedValueSetter":null},"container":"","createdAt":"2022-09-19T20:58:43.825Z","namespace":null,"position2":null,"updatedAt":"2022-09-20T00:07:41.146Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"diceRollModifier":{"id":"diceRollModifier","type":"widget","style":{},"folder":"","screen":null,"subtype":"NumberInputWidget","tabIndex":null,"template":{"max":null,"min":null,"label":"Modifier","value":0,"events":[{"type":"datasource","event":"submit","method":"trigger","params":{},"waitMs":"0","pluginId":"rollDice","targetId":null,"waitType":"debounce"}],"format":"decimal","hidden":false,"invalid":false,"loading":false,"currency":"USD","disabled":false,"readOnly":false,"required":false,"_validate":false,"allowNull":false,"iconAfter":"","labelWrap":false,"showClear":false,"textAfter":"","textAlign":"left","iconBefore":"","inputValue":0,"labelAlign":"right","labelWidth":"33","padDecimal":false,"textBefore":"","formDataKey":"{{ self.id }}","placeholder":"Enter value","showStepper":true,"tooltipText":"","inputTooltip":"","labelCaption":"","showInEditor":false,"decimalPlaces":null,"labelPosition":"left","labelWidthUnit":"%","showSeparators":true,"customValidation":"","validationMessage":"","hideValidationMessage":false,"maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T18:04:09.810Z","namespace":null,"position2":{"col":7,"row":1.6,"width":2,"height":1,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-20T00:50:16.009Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null}},"version":"2.100.1","appStyles":"","createdAt":null,"appThemeId":null,"isFetching":false,"rootScreen":null,"isMobileApp":false,"testEntities":[],"isGlobalWidget":false,"customShortcuts":[],"customDocumentTitle":"","preloadedAppJSLinks":[],"markdownLinkBehavior":"auto","multiScreenMobileApp":false,"queryStatusVisibility":false,"instrumentationEnabled":false,"pageLoadValueOverrides":[],"preloadedAppJavaScript":null,"urlFragmentDefinitions":[],"experimentalPerfFeatures":{"useRuntimeV2":false,"serverDepGraphEnabled":false,"batchCommitModelEnabled":false,"skipDepCycleCheckingEnabled":false},"responsiveLayoutDisabled":false,"inAppRetoolPillAppearance":"NO_OVERRIDE","loadingIndicatorsDisabled":false,"customDocumentTitleEnabled":false,"experimentalDataTabEnabled":true}}},{"type":"WIDGET_TEMPLATE_UPDATE","payload":{"plugin":{"id":"diceRollTotal","type":"widget","style":{},"folder":"","screen":null,"subtype":"TextWidget2","tabIndex":null,"template":{"value":"## 0","hidden":false,"heightType":"fixed","imageWidth":"fit","tooltipText":"","overflowType":"scroll","showInEditor":false,"verticalAlign":"center","disableMarkdown":false,"horizontalAlign":"center","maintainSpaceWhenHidden":false},"container":"","createdAt":"2022-09-19T18:15:06.475Z","namespace":null,"position2":{"col":10,"row":1.5999999999999996,"width":2,"height":0.9999999999999999,"tabNum":0,"rowGroup":"body","container":"","subcontainer":"header"},"updatedAt":"2022-09-20T01:09:13.652Z","resourceName":null,"mobilePosition2":null,"mobileAppPosition":null,"resourceDisplayName":null},"update":{"value":"## -"},"widgetId":"diceRollTotal","shouldRecalculateTemplate":true},"isUserTriggered":true}],"gitSha":null,"checksum":null,"createdAt":"2022-09-21T23:54:13.807Z","updatedAt":"2022-09-21T23:54:13.807Z","pageId":1451466,"userId":348139,"branchId":null},"modules":{}}
lastDiceClicked.setValue(-1);
diceRolls.setValue([]);
diceRollModifier.setValue(0);
diceRollDisplay.setValue(`<small><i>Roll a die...</i></small>`);
diceRollTotal.setValue(`## 0`);
// Don't process unless we have a valid dice roll
if (lastDiceClicked.value < 0) {
return;
}
// Generate a dice roll, capturing the current modifier
const diceRoll = {
dieRolled: lastDiceClicked.value,
modifier: diceRollModifier.value,
value: Math.floor(Math.random() * lastDiceClicked.value) + 1,
};
// Gather all rolls
const allRolls = diceRolls.value.concat([ diceRoll ]);
// Calculate and display the current roll results
const detailString = [];
let runningTotal = 0;
allRolls.forEach(roll => {
const totalRollValue = roll.modifier + roll.value;
runningTotal += totalRollValue;
let rollString = ' ';
if (roll.modifier >= 1) {
rollString = `+ ${roll.modifier} `;
} else if (roll.modifier < 0) {
rollString = `- ${Math.abs(roll.modifier)} `;
}
detailString.push(`(1d${roll.dieRolled} -> ${roll.value}) ${rollString}= ${totalRollValue}`);
});
// Update UI with calculated values
diceRollDisplay.setValue('<small>' + detailString.join(', ') + '</small>');
diceRollTotal.setValue(`## ${runningTotal}`);
// Update state
diceRolls.setValue(allRolls);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment