jeudi 28 octobre 2021

(Google Sheets Apps Script) How do I get different results with the same random function using an image click?

I am making a WTF-type random character generator. I am new to Google apps script, but I got it working via an image click. My next goal is to get multiple different results using the same method. The problem I'm running into is that it's giving the same result for each different cell. I've tried using Utilities.sleep() and waitForAllDataExecutionsCompletion() but ultimately I'm out of my depth.

How do I fix this?

function dungeonsAndDragonsChoices() {
  dND1();
  dND2();
  dND3();
  dND4();
  dND5();
  dND6();
}

function dND1() {
  ss.setActiveCell('E2').setValue(randomMood+" "+ddrandomAncestry+" "+ddrandomClass+" from "+ddrandomHome+" "+randomQuirk);
}
function dND2() {
  ss.setActiveCell('E5').setValue(randomMood+" "+ddrandomAncestry+" "+ddrandomClass+" from "+ddrandomHome+" "+randomQuirk);
}
function dND3() {
  ss.setActiveCell('E8').setValue(randomMood+" "+ddrandomAncestry+" "+ddrandomClass+" from "+ddrandomHome+" "+randomQuirk);
}
function dND4() {
  ss.setActiveCell('E11').setValue(randomMood+" "+ddrandomAncestry+" "+ddrandomClass+" from "+ddrandomHome+" "+randomQuirk);
}
function dND5() {
  ss.setActiveCell('E14').setValue(randomMood+" "+ddrandomAncestry+" "+ddrandomClass+" from "+ddrandomHome+" "+randomQuirk);
}
function dND6() {
  ss.setActiveCell('E17').setValue(randomMood+" "+ddrandomAncestry+" "+ddrandomClass+" from "+ddrandomHome+" "+randomQuirk);
}

(I'm sure this can be made prettier, but I'm new at it and I was trying to make everything easily readable)




Aucun commentaire:

Enregistrer un commentaire