Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
Advertisement Create a free account Compendium in Game, Join Today

Processing $[[0]]...is it possible?

1590129402
This expression:  [[3d6]] [[$[[0]]*2]]  outputs: 12 [[12*2]] Instead of 12 24 Is there syntax that allows $[[0]] to be used in mathematic equations?
1590135018
GiGs
Pro
Sheet Author
API Scripter
What's the context? What is $[[0]] supposed to represent here?
1590135373

Edited 1590135871
GiGs
Pro
Sheet Author
API Scripter
wow, I had no idea you could access rolls in a normal macro like that. It seems like the msg.inlinerolls property used in the API is being exposed in chat, and I wonder if its unintentional. How did you discover you could do this? There could be some uses to it, like showing a roll result again in a different place in the same macro (which definitely has potential), but you cant do any arithmetic with it, because the roll20 chat engine doesnt see it as a number - it's an object or array variable of some sort, and there's no ability to manipulate objects in roll20 chat. As a Pro user, whatever you are trying to do here, you can do in the API instead. 
1590138150
Ziechael
Forum Champion
Sheet Author
API Scripter
Well... that is just a game changer... You can reference the 'result' before the roll then do math with the roll but this seems to break inline syntax... your only real solution is to do the math on the roll then output the roll result afterwards, giving you 24 12 instead of 12 24 as per your example: Calculated result: [[[[3d6]]*2]]  Original roll: $[[0]] From basic testing, it needs to be on the same row but can be done on each row... this is very interesting! [[[[3d6]]*2]] $[[0]] [[[[3d6]]*2]] $[[0]] The above will give each roll result, no conflict.
1590152004
How did you discover you could do this? I can't recall where exactly, but I came across it in the forums here, somewhere, I think.&nbsp;&nbsp; There could be some uses to it, like showing a roll result again in a different place in the same macro Indeed, I tried so hard to make a macro for D&amp;D 5e OGL for a fighter's second wind that would do several things:&nbsp; roll the hp restored, deduct the "ammo" from the second wind class resource and finally add the hp rolled to the @{hp} field, and finally report the amount of hp gained.&nbsp; With $[[0]] I was finally able to do it (the character's name, in this case, is "Snick Twee"): [[1d10+@{base_level}]] @{Snick Twee|wtype} &amp;{template:npcaction}&nbsp; {{rname=Second Wind}}&nbsp; &nbsp;!modbattr --name Snick Twee --silent --evaluate --hp|$[[0]] --class_resource|-1!!! {{description=Snick&nbsp; digs deep for more energy and regains $[[0]] (1d10+fighter level) hit points}} As far as [[[[3d6]]*2]] $[[0]] You can also do: [[[[3d6]]*2]] $[[0]] $[[1]] to get the result of both rolls. What's the context? What is $[[0]] supposed to represent here? I was thinking about a problem posed recently in another thread&nbsp; <a href="https://app.roll20.net/forum/post/8705764/seemingly-simple-conditional-macro" rel="nofollow">https://app.roll20.net/forum/post/8705764/seemingly-simple-conditional-macro</a> &nbsp;
1590152728
GiGs
Pro
Sheet Author
API Scripter
I asked that context question before I tested $[[0]] and saw what it did, hehe.&nbsp; Sadly its no use for that linked post. There's still no way to do that kind of thing without the API.
1590155521
Sadly its no use for that linked post. There's still no way to do that kind of thing without the API. If $[[0]] could be used mathematically, I think it could be done with kh1 logics.&nbsp;&nbsp; It seems like the msg.inlinerolls property used in the API is being exposed in chat If this is the case, I'm wondering if there is someway to access the exposed object to extract it's "value" property (or whatever it is named)...like put some mini javascript container around it to work with it?&nbsp;
1590156328
GiGs
Pro
Sheet Author
API Scripter
Syneran said: Sadly its no use for that linked post. There's still no way to do that kind of thing without the API. If $[[0]] could be used mathematically, I think it could be done with kh1 logics.&nbsp;&nbsp; It seems like the msg.inlinerolls property used in the API is being exposed in chat If this is the case, I'm wondering if there is someway to access the exposed object to extract it's "value" property (or whatever it is named)...like put some mini javascript container around it to work with it?&nbsp; Yes, if you could manipulate $[[0]] as a number, you could do all sort of things. But you can't. And the API commands that would allow you to manipulate it - such as for getting its value - cant be used in chat.&nbsp;There's no API interpreter here.&nbsp;
1590158885
Thanks GiGs, et al!&nbsp; I appreciate your responses.
1590159318
GiGs
Pro
Sheet Author
API Scripter
And than you for revealing this. I'm thinking it being available is an accident by roll20, and they may get rid of it. But until they do, it's a neat trick for showing dice rolls in more than one place.
1590164946
ᐰndreas J.
Forum Champion
Sheet Author
GiGs said: And than you for revealing this. I'm thinking it being available is an accident by roll20, and they may get rid of it. But until they do, it's a neat trick for showing dice rolls in more than one place. Why would they remove it? And could someone give example of some implications of this finding?
1590165699

Edited 1590165711
GiGs
Pro
Sheet Author
API Scripter
The only thing you can do with it is show a roll in more than one place on the same line. So you could do /roll 1d20+6 and [[2d6]]; my attack roll is $[[0]]; my damage roll is $[[1]] That example isnt very useful, but you can see the potential. Regarding the implications: How long has roll20 been around? this feature hasnt been discovered before, so it's likely a recent devlopment that it's exposed in the chat interface. And the fact that the syntax is identical to what you get in api scripts, in the msg.content&nbsp;property when you have rolls, makes me think its part of the API that has been accidentally exposed. Maybe its a consequence of their work on trying to fix the API slowdowns,&nbsp; But I'm just guessing that, largely out of befuddlement. I cant imagine this feature is intended - it would have been discussed and popularised if so. If it is an accident, we have to consider that it'll be fixed at some point.
1590168299
Jakob
Pro
Sheet Author
API Scripter
I guess this is a case of&nbsp; Hyrum's Law : if enough people start using it, it doesn't matter if it was intentional or not :D
1590169120
GiGs
Pro
Sheet Author
API Scripter
Thats a good point :)
1590169622
And could someone give example of some implications of this finding? An earlier post in this chat thead has an example of Fighter D&amp;D 5e Second Wind Feature.&nbsp; The roll happens pre-template, then gets used to 1) report the roll result, and 2) update the health on the character sheet.&nbsp; Without using $[[0]] it is impossible to use the roll twice in this way
1590174230
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I doubt Roll20 would remove it intentionally, unless it poses a security issue. However, they might inadvertently remove it if it interferes with anything else in the code, or even if it just "looks sloppy" from the back end. Look what happened with Ctrl/Cmd-L and regular Fog of War.
1590204607
GiGs
Pro
Sheet Author
API Scripter
I was thinking the fact that its exposed might be due to a new bug, and when they find and fix that, that will stop it working. I wanst thinking they'd deliberately block it, but just that its existence might be buggy behaviour that might get fixed. (Though given roll20's speed at fixed acknowledged bugs, it could still be around for a long, long time...)