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

Calling math functions nested macro

So I've built a little macro and I have a journal entry that explains a new character creation process to new players, including a link to the macro at the point where they should use it.  But a line in the macro uses the abs function, and that line fails to execute.  The macro works fine when called directly, not from the journal entry: Human Male Age [[abs(122-[[4d50]]-[[d12]])]] (Adult 16) Mature: [[120+[[2d10]]*2d4]] lb, 58 + $[[0]] in But this call only executes the second line: !&#Human-Male-Age-Ht-Wt Is there a way (as a plus subscriber) that I can use macro calls from the journal if those macros include functions like abs, floor, ceil and round ?
1608750533
Kraynic
Pro
Sheet Author
I don't think any of those functions rely on subscriber level.  They are (or at least should be) just part of the dice roller mechanics.  When I copy/paste what you posted into a game, both lines work for me.  In case there is some glitch with abs, have you thought about just using 16 as your minimum with kh1? [[{122-4d50-d12,16+0d0}kh1]] Human Male Age [[{122-4d50-d12,16+0d0}kh1]] Mature: [[120+[[2d10]]*2d4]] lb, 58 + $[[0]] in
1608751197
Andreas J.
Forum Champion
Sheet Author
Translator
Yeah, don't think there is anything related to subscription levels either. The Order of Operations seems to check out as well, with math functions like abs being processed basically last. I'd go with a workaround like Kraynic's to skill abs() from your equations.
Thanks to both of you.  The crazy formula with abs is to mimic a specific population distribution, as I'm also using it for things other than PC generation.  unfortunately the suggested solution makes a very large percentage of the results equal to the minimum adult age (more than would actually be sub-adult per the original formula). The issue seems to be in calling the abs function in a macro that is called from a journal link.  I think it's a nested macro type problem, but there are none of the normal characters that cause nested macros to break like comma, closing curly bracket or vertical pipe.  Perhaps there is something in the required syntax or special characters that I need, or maybe it just can't be done.  I'll try a simple test with a macro like abs(2) to see if that can be called from the journal.
Confirmed - I can't call even a simple [[abs(2)]] macro from a journal link using !&#macro_name. Which suggests to me that constants and math operators in macros may be passable, but you can't pass through functions using this syntax.
1608756497
Jordan C.
Pro
API Scripter
Pete K. said: Confirmed - I can't call even a simple [[abs(2)]] macro from a journal link using !&#macro_name. Which suggests to me that constants and math operators in macros may be passable, but you can't pass through functions using this syntax. Forgive me if I missed something, but the syntax for calling macros via journal links is to write  `#macro-name in the URL field instead of the !&#macro-name you are referencing.
1608756616
Kraynic
Pro
Sheet Author
I see.  I wondered why it was set up to be able to go below 0 to begin with.  Due to my dice luck (or lack thereof), I mostly was generating people age 30+.  If you just can't get absolute to work, just leave it out.  It is easy enough to ignore a - sign in front of a number if it will cut down on set up frustration. It would take a different approach, but I have used a "character" with token actions set up for character/npc generation.  You could use the Bio & Info tab for instructions and have all the rolls laid out as token actions, if that works better for the macros you are trying to run. 
1608763569

Edited 1608763655
Oosh
Sheet Author
API Scripter
Have you checked if parentheses are the problem? You can try ( and ) instead of ( and ), see if escaping those does anything. They'll definitely break [Button](links), honestly haven't played with Journal links much though so it may not be any use. Worth a crack though.
I had not thought of using the Bio and Info tab for that - a good idea for keeping all of that together.  The hanging minus would be a last resort. This is the first time I put links in a journal, so I was suspecting that I perhaps got the syntax wrong with something I copied from some forum post.  I'll give the `#macro_name syntax a try and see if that is another way I can fix this.
1608766782

Edited 1608766818
Oosh
Sheet Author
API Scripter
Oh wait.... It's just the first line getting sent to API because of the !. Try adding a line break to the start of your macro, then click the link again: Human Male Age [[abs(122-[[4d50]]-[[d12]])]] (Adult 16) Mature: [[120+[[2d10]]*2d4]] lb, 58 + $[[0]] in 
 and 
 don't seem to work in Journal links.
1608768894

Edited 1608768966
Jordan C.
Pro
API Scripter
FWIW, I was able to get a result in chat with the following setup and the math seemed to be functioning appropriately:
Oosh said: Oh wait.... It's just the first line getting sent to API because of the !. Try adding a line break to the start of your macro, then click the link again: Human Male Age [[abs(122-[[4d50]]-[[d12]])]] (Adult 16) Mature: [[120+[[2d10]]*2d4]] lb, 58 + $[[0]] in 
 and 
 don't seem to work in Journal links. What are &#10 and &#13 commands? I was able to get Jordan's fix to work by replacing !&# with `# I'll remember the ( and ) trick in case I need to try that at some point. I'm going to try Kraynic's suggestion of putting instructions on the bio & info tab, and I already have several token actions tied to abilities on the character sheet.  For this particular macro it may be easier to have it as a separate macro.  If I put it on the sheet I'll be tempted to nest it into attributes that I really want to hold as constants once they have initially been determined via randomizing macro or player choice.