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 .
×
Create a free account

Is this a possible macro and how would I type it?

1636576169

Edited 1636576284
Sorry if it's a dumb question but I'm running a Pokmeon game and I wanted to see if I could do this all as one macro:  Wild Pokemon Encounter There will be: [[1d6+4]] Pokemon  [[xd100>95]] Will be rare and  [[xd4096=4096]] Will be Shiny  Where x is the number of pokemon rolled initially 
1636577974
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
you could do one or the other of the rare/shiny rolls, but not both.
1636578083
timmaugh
Forum Champion
API Scripter
I don't think the re-using rolls trick will help for what you want to do, but as you're a Pro user, you can use ZeroFrame (a metascript). !&{template:default}{{name=Wild Pokemon Encounter}}{{Pokemon=[[1d6+4]]}}{{Rare=[\][\]$[[0]].valued100>95\]\]}}{{Shiny=[\][\]$[[0]].valued4096=4096\]\]}}{&simple} That will give an output like: Obviously the verbiage can be changed, but hopefully that gets the idea across.
timmaugh said: I don't think the re-using rolls trick will help for what you want to do, but as you're a Pro user, you can use ZeroFrame (a metascript). !&{template:default}{{name=Wild Pokemon Encounter}}{{Pokemon=[[1d6+4]]}}{{Rare=[\][\]$[[0]].valued100>95\]\]}}{{Shiny=[\][\]$[[0]].valued4096=4096\]\]}}{&simple} That will give an output like: Obviously the verbiage can be changed, but hopefully that gets the idea across. I'm new to using something like that how exactly would I put it into my game? 
1636640924
timmaugh
Forum Champion
API Scripter
ZeroFrame is available in the 1-click. If you've never added a script to your game, it's pretty straightforward. Nick O has a good video on how to do that. Once ZF is installed, you can copy the above text into a new Ability or Macro and run it, and you should get the output you want. If you haven't used a script before, just understand that statements you want to be picked up by the API (where scripts live) must begin with an exclamation point. Those messages are not seen in the chat interface by default. Instead, what makes it to the chat panel is what the script outputs. Most of the time, a message would be calling a specific script (Token-Mod, ChatSetAttr, Spawn, etc.), but in the case of metascripts, they intercept the message first and make changes to the command line. For instance, Fetch is another metascript that gets character or token information; if you want the new tooltip of a token, you can't get that with the standard Roll20 structure: @{selected|tooltip}. But you can get it with the Fetch construction: @(selected.tooltip). ZeroFrame provides a few syntax structures we're using: [\][\] ... \]\] ...that represents a deferred roll. We want an inline roll, but we have to wait until something else finishes computing, first. .value ...when attached to an inline roll marker (like $[[0]] ), extracts the value of that roll in place. {&simple} ...instead of letting this message continue as an API message (to be maybe picked up by another script), ZeroFrame outputs the final result after it has processed all of its constructions and it detects no more work to be done. In our case, this means outputting a templated message.
timmaugh said: ZeroFrame is available in the 1-click. If you've never added a script to your game, it's pretty straightforward. Nick O has a good video on how to do that. Once ZF is installed, you can copy the above text into a new Ability or Macro and run it, and you should get the output you want. If you haven't used a script before, just understand that statements you want to be picked up by the API (where scripts live) must begin with an exclamation point. Those messages are not seen in the chat interface by default. Instead, what makes it to the chat panel is what the script outputs. Most of the time, a message would be calling a specific script (Token-Mod, ChatSetAttr, Spawn, etc.), but in the case of metascripts, they intercept the message first and make changes to the command line. For instance, Fetch is another metascript that gets character or token information; if you want the new tooltip of a token, you can't get that with the standard Roll20 structure: @{selected|tooltip}. But you can get it with the Fetch construction: @(selected.tooltip). ZeroFrame provides a few syntax structures we're using: [\][\] ... \]\] ...that represents a deferred roll. We want an inline roll, but we have to wait until something else finishes computing, first. .value ...when attached to an inline roll marker (like $[[0]] ), extracts the value of that roll in place. {&simple} ...instead of letting this message continue as an API message (to be maybe picked up by another script), ZeroFrame outputs the final result after it has processed all of its constructions and it detects no more work to be done. In our case, this means outputting a templated message. Sweet! it worked,  However when I tested it the script is using the Shiny value for the Rare value (I.e rolling d4096 twice)  any way to fix that? 
1636658874
timmaugh
Forum Champion
API Scripter
Yep... that's definitely a bug. Let me get to the bottom of that. It's grabbing the wrong roll when it reconstructs the message. For now you can fix it just by moving the rolls out of the roll template and referencing them by their position: !&{template:default}{{name=Wild Pokemon Encounter}}{{Pokemon=[[1d6+4]]}}[\][\]$[[0]].valued100>95\]\] [\][\]$[[0]].valued4096=4096\]\]{{Rare=$[[1]]}}{{Shiny=$[[2]]}}{&simple} I'll figure out what is going on and release an update to the script, but this should get you in business for now.
1636726744
timmaugh
Forum Champion
API Scripter
OK, I got that sorted. It was a problem of multiple deferred rolls in the same loop iteration and how they were handled. I have made a change to ZeroFrame and submitted it for next week's merge. That means if you got it from the one-click, it should automatically update in your game after the merge goes through. Otherwise, if you installed it manually or you "imported" it from the one-click, you will need to get it yourself. In either case, if you want the fix before the merge goes through next week, you can get it from my personal repo . Since you said you'd never done something like this before, I should probably point out that once you install a script manually (or import it from the one-click rather than "installing" it), the copy in your game is static. It will no longer receive automatic updates should someone submit an enhancement to the script. So, if you decide to remove an automatic install of ZF from your game so that you can manually install/import the newly-updated version, you may want to later return to the one-click version -- after the merge has gone through -- so that you will remain current with the latest version. That is up to you, but I figured I should point out that that's the way things work. =D