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 .
×

Variable target number macro only works with roll queries, not chat macros

Detailed Description of the Problem When trying to create macros for target based rolls, where the target number might vary, I encountered parsing issues. Namely when following the manual for chat variables it produces an error message when using the '>' or '<' operators as the last character. #rollvariabletarget /roll 1d100< While the documentation says this should work for providing chat parameters this results in the following error when calling it with or without the chat parameter: Could not determine result type of: [{"type":"M","expr":1},{"type":"C","text":"d100> 50"}] While workarounds exist like using the roll queries, or in some cases one can substract the target from the roll, this is not entirely as I expected this to work. Steps to Reproduce the Problem Create a chat parameter macro that uses the target number after a '<' or a '>' as the last character in the /roll command. Thus making the target the chat parameter. Try to use that macro with or without the chat parameter. Description of Your Setup OS: Windows 8.1 Browser: Firefox 33.0.3 and Chrome 38.0.2125.111 m Device: HP Zbook 15 (Seems to be non-specific to OS and Browser but rather in the logic of dice parser.)
1415538976

Edited 1415539019
Gauss
Forum Champion
Could you post your entire macro? You mentioned a query but you do not have a query in your macro. As for the < and > operators, there is supposed to be a term following them. That is why you are getting an error.
1415543026
Pat S.
Forum Champion
Sheet Author
Zim R. said: #rollvariabletarget /roll 1d100&lt; To add on to what Gauss said. If this is the complete macro then it is incomplete. The basis is that your roll needs to have something to compare it to (that is the &lt; is for). To make that macro work in it's most basic form you could use /roll 1d100 &lt;50 or any other number. The macro when used will just give you a success or not (0 or 1 success). /roll 1d100 &lt;?{variable target number|50} allows you to setup a query with the default of 50. You can setup the number to be any default you want though. You can read more up on it here in the wiki: <a href="https://wiki.roll20.net/Dice_Reference#Roll_Querie" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Roll_Querie</a>... and <a href="https://wiki.roll20.net/Dice_Reference#Target_Numb" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Target_Numb</a>... Now if you want to just visually spot the difference between the rolled number and the variable you could just use /roll 1d100 vs 50 and that will just show the dice roll and you can look to see if it rolled above or below /roll 1d100 vs ?{variable number|50} allows you to enter a variable like above but it will only show the text and dice roll for you to look at and compare.
1415543155
Pat S.
Forum Champion
Sheet Author
Going to move this thread to the specific question forum for it fits there.
1415546863

Edited 1415547045
As I've said explicitly in the title of the thread, it does work with Roll Queries. Roll Queries are not the problem. I can get that to work no problem. It is the chat based variables that cause the issues. Namely when I try to call the macro with for example '#rollvariabletarget 50' then from the documentation I expect the 50 to be filled in with the macro command as described in the wiki for specifying a variable in chat: <a href="https://wiki.roll20.net/Macros#Example_4" rel="nofollow">https://wiki.roll20.net/Macros#Example_4</a> This should result in the above described macro to be filled in, according to the documentation, as: /roll 1d100&lt;50 However this actually results in: /roll 1d100&lt; 50 Which is as I can divine about the parser caused by the chat based variables being inserted with a space preceding them. Disconnecting them from the string statement that is tokenized by the dice rolling parser. Meaning that it can't properly parse the statement. This might be entirely intended however if this is the case then it is not made clear from the documentation that this operator is not suited to chat based variable substitution.
1415565757

Edited 1415566520
Gauss
Forum Champion
The operator is suited to the chat just fine. The problem is what you are actually entering (and did not state this in your original post) is "#rollvariabletarget 50" with "#rollvariabletarget" being "/r 1d100&lt;". This produces the exact result expected: "/r 1d100&lt; 50" which of course does not work because there is a space between "&lt;" and "50". This is not a bug so much as a design issue. The dice roller is not designed to remove unneeded spaces in the case of "&lt;" and "&gt;" and the macro autocomplete is not designed to accept extra characters (for example: "#rollvariabletarget50" and still realize it is "#rollvariabletarget"). The operator works fine in chat, I use it in chat all the time. It is how you are mixing the macro command and trying to insert a variable afterwards that is not working. I suggest inserting a query into your macro so that you do not have this problem.
Yes, that is exactly how I have solved it for my usecase. However the documentation implied no restrictions on using using this chat based variable insert with the dice rolling behaviour. As such it came unexpected, even if it is part of the design. Hence me assuming it was a bug. Since either the functionality is as intended but the documentation is incomplete. Or this is a small interaction of separately designed systems where the final results produces unexpected or improper output and thus not working as intended.