角色扮演游戏骰子掷骰子技能检查器脚本问题 [英] RPG gaming dice roll skill checker script question

查看:102
本文介绍了角色扮演游戏骰子掷骰子技能检查器脚本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的RPG游戏技能检查脚本...在下面的脚本(由StackOverflow的成员Edmund chan kei yun创建)中,检查单元格的最高编号(在通过另一个脚本模拟几个d6骰子掷骰后),并然后从表中复制文本(以定义结果操作).

For my RPG gaming skill check script... In the below script (created by Edmund chan kei yun, a member at StackOverflow) cells are checked for the highest numbers (after simulated several d6 dice rolls by another script), and then text is copied from a table (to define resulting actions).

我还需要像666和111这样的骰子结果组合才能拥有自己的表格结果.这样将在表中具有自己的列/行.有人可以帮助我更新脚本以包括骰子结果组合的读取,以便此类组合定向到特定的列/行吗?

I would also need dice result combos like 666 and 111 to have their own table results. Such will have their own columns/rows in the table. Could someone help me to update the script to include the reading of combos of dice result as well, so that such combo directs to a specific column/row?

这里是带有脚本的工作表可编辑版本的链接... https://docs.google.com/spreadsheets/d/1zYhll edit?usp = sharing

Here is a link to an editable version of the sheet with script... 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
}

推荐答案

如果您自己调整脚本可能会更好,但是我可以帮助您的是检查特定组合.您想要的是在检查最大值之前先检查组合案例,因为组合优先.

it might be better if you adjust the script by yourself, but what i can help you with is the checking for specific combos. what you would want is to check for combo cases prior to checking for highest value, since combos take precedence.

由于唯一的组合是666和111,因此我们可以使用if语句将选中的行/列更改为7.因此,这是脚本中唯一需要添加的内容.

Since the only combos are 666 and 111, we can use an if statement to change the row/column that is checked to 7. Therefore this is the only addition you would need to your script.

  if (newcellcontent1[0]=== '6' && newcellcontent1[0]===newcellcontent1[1] && newcellcontent1[1]===newcellcontent1[2]) { //if attacker rolls a 666
    maxNum1 = 7;
  }
  if (newcellcontent2[0]=== '1' && newcellcontent2[0]===newcellcontent2[1] && newcellcontent2[1]===newcellcontent2[2]) { //if defender rolls a 111
    maxNum2 = 7;
  }
  
  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

请尝试自行对脚本进行任何较小的更改.这是我使用的Google工作表 https://docs.google.com/spreadsheets/d/1NSpdsqQ2-c20EANnYoiKWQHNTu05C-7NGr0Y7K9on8A/edit?usp=sharing

Please try to make any minor changes to the script by yourself. This is the google sheet that i used https://docs.google.com/spreadsheets/d/1NSpdsqQ2-c20EANnYoiKWQHNTu05C-7NGr0Y7K9on8A/edit?usp=sharing

这篇关于角色扮演游戏骰子掷骰子技能检查器脚本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆