Introduction
I'm trying to create custom Google Sheets functions for tabletop rolls and rules, and I ran into what appears to be a technical limitation on part of Google Sheets new Named Functions feature, but I'm hoping to be wrong and hope the community here can recognize a mistake of mine or recommend a sensible workaround1.
For whatever reason, it appears that Google Sheets' new Named Functions do not accept output from other named functions as input.
I have made an example sheet with a demonstration as well as a testing zone that the community is free to mess around with.
The Problem
I am working with two named functions that I have created:
FUNCTION =ROLL_D10(count)
count
: The number of dice rolls you want to roll. Default: 1=ARRAYFORMULA(ROUNDUP(RANDARRAY(IF(AND(ISNUMBER(count),count=INT(count),count>=1),count,1),1)*10,0))
FUNCTION =ROLL_ADVANTAGE(rolls)
rolls
: A singular cell or array of cells consisting of numerical rolls.=IFERROR(LARGE(rolls,1),NA())
The goal is to be able to nest the named functions like so: =ROLL_ADVANTAGE(ROLL_D10(3))
The result should be to retrieve the highest value from a 3d10 roll. To those familiar with tabletop, this would be a double advantage roll.
What appears to be happening is that once created, the nested function will not recalculate unless the cell that contains the nested formula is changed. For example, if I change =ROLL_ADVANTAGE(ROLL_D10(3))
to =ROLL_ADVANTAGE(ROLL_D10(3))&"A"
, it will recalculate the ROLL_D10
function. It will not recalculate if any other On Change or Every Minute/Every Hour event is triggered.
Tests Performed
I have tested the following methods and achieved the following results. Again I invite users to see the example sheet for live examples.
- r = Non-named
ROLL_D10
function; R = NamedROLL_D10
function. - a = Non-named
ADVANTAGE
function; A = NamedADVANTAGE
function. - :S = Output posted to the sheet prior to being passed as input.
- :ƒ = Output passed directly as formula input.
- .n = Non-named function; .N = Named function.
- ‘⇒’ Output passed from
ROLL_D10
toADVANTAGE
function.
Tested Operation | Result |
---|---|
r:S …Raw formula |
Success |
R:S …Raw formula |
Success |
a:S …Raw formula |
Success |
A:S …Raw formula |
Success |
r:ƒ …Raw formula |
Success |
R:ƒ …Raw formula |
Possibly does not work with ƒ.N ⇒ f.N |
a:ƒ …Raw formula |
Success |
A:ƒ …Raw formula |
Success |
r:S ⇒ a |
Success |
r:S ⇒ A |
Success |
R:S ⇒ a |
Success |
R:S ⇒ A |
Success |
r:ƒ ⇒ a |
Success |
r:ƒ ⇒ A |
Success |
R:ƒ ⇒ a |
Success |
R:ƒ ⇒ A |
FAILURE |
Annotations
- I consider a sensible workaround to be avoiding integrating advantage/disadvantage/neutral arguments into the roll functions as this increases complexity and therefore makes it less user-friendly: I do hope to make these functions available generally. If this is the only reasonable option, that is fine, but I would prefer to explore other options first.