对于我的RPG游戏技能检查脚本...,在下面的脚本(由StackOverflow的成员Edmund chan kei yun创建)中,检查单元格的最高编号(由另一个脚本模拟几个d6骰子掷骰后),然后从表中复制文本(以定义结果操作)。
我还需要像666和111这样的骰子结果组合才能拥有自己的表格结果。这样在表中将有自己的列/行。有人可以帮助我更新脚本以包括骰子结果组合的读取,以便此类组合定向到特定的列/行吗?
这里是带有脚本的工作表可编辑版本的链接...https://docs.google.com/spreadsheets/d/1zYhUnlHCW7kfo0rf1pZY2GNI4qt5PsbGYOljFe2dwJE/edit?usp=sharing
function SetRetrievedValue() {
var app = SpreadsheetApp;
var ss = app.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//var cellcontent1 = sheet.getRange(2,1,6,1).getValues(); use this if its a range of cells you are searching
var cell1 = sheet.getRange(1,1).getDisplayValue(); //gets value as string
var cellcontent1 = cell1.split(""); // splits up the string individually
var newcellcontent1 = Array.prototype.concat.apply([], cellcontent1); // flatten the array
var maxNum1 = Math.max.apply(null, newcellcontent1); //gets the max value in the array
// repeat of cell 1
var cell2 = sheet.getRange(1,2).getDisplayValue();
var cellcontent2 = cell2.split("");
var newcellcontent2 = Array.prototype.concat.apply([], cellcontent2);
var maxNum2 = Math.max.apply(null, newcellcontent2);
var tablecell = ss.getSheetByName("Table sheet").getRange(maxNum1,maxNum2).getValue(); //retrieve the value based on the corresponding max value
sheet.getRange(1,3).setValue(tablecell); // sets the cell C1 as the value retrieved from the table
}
如果您自己调整脚本可能会更好,但是我可以帮助您的是检查特定组合。您想要的是在检查最大值之前检查组合案例,因为组合优先。