SHARE
TWEET

Untitled

a guest Oct 23rd, 2018 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function newFormEntry(e) {
  2.   //trigger when linked form is submitted: [timestamp, team, name, pom count]
  3.   Logger.log(e);
  4.  
  5.   //var logSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current Log");
  6.   var teamSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current Teams");
  7.   var teamOne = teamSheet.getRange('A1').getValue();
  8.   var teamTwo = teamSheet.getRange('D1').getValue();
  9.   var teamThree = teamSheet.getRange('G1').getValue();
  10.   var teamFour = teamSheet.getRange('J1').getValue();
  11.  
  12.   //var newTeam = logSheet.getRange(logSheet.getLastRow(), 2);
  13.   var newTeam = e.values[1];
  14.   //var newName = logSheet.getRange(logSheet.getLastRow(), 3);
  15.   var newName = e.values[2];
  16.   //var newPoms = logSheet.getRange(logSheet.getLastRow(), 4);
  17.   var newPoms = e.values[3];
  18.  
  19.   //push raw --> results with roll
  20.   for (var x = 0; x < newPoms; x++) {
  21.     if (newTeam = teamOne) {
  22.       jumpNext(teamSheet, 1).setValue(newName);
  23.       jumpNext(teamSheet, 3).setValue(rnJesus());
  24.     }
  25.     else if (newTeam = teamTwo) {
  26.       jumpNext(teamSheet, 4).setValue(newName);
  27.       jumpNext(teamSheet, 6).setValue(rnJesus());
  28.     }
  29.     else if (newTeam = teamThree) {
  30.       jumpNext(teamSheet, 7).setValue(newName);
  31.       jumpNext(teamSheet, 9).setValue(rnJesus());
  32.     }
  33.     else {
  34.       jumpNext(teamSheet, 10).setValue(newName);
  35.       jumpNext(teamSheet, 12).setValue(rnJesus());
  36.     }
  37.   }
  38.  
  39.   teamSheet.setActiveSelection('M20').setValue(newPoms);
  40.   //at end time, unlink form from raw ==> MANUAL
  41.   //after end time, push results to leaderboards ==> MANUAL
  42.  
  43. }
  44.  
  45. function jumpNext(sheet, column) {
  46.   //sets next empty cell in given column as active
  47.   return sheet.setActiveSelection(sheet.getRange(sheet.getDataRange().getHeight()+1, column));
  48. }
  49.  
  50. function rnJesus() {
  51.   //returns random loaded result
  52.   var x = Math.floor(Math.random() * 25);
  53.   if (x < 2)
  54.     return 0;
  55.   else if (x < 5)
  56.     return 1;
  57.   else if (x < 9)
  58.     return 5;
  59.   else if (x < 14)
  60.     return 10;
  61.   else if (x < 19)
  62.     return 20;
  63.   else if (x < 23)
  64.     return 50;
  65.   else if (x < 24)
  66.     return 100;
  67.   else
  68.     return 1000;
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top