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

Help - Using APIs inside of Macros

I am creating a series of Macros to help with character creation of HarnMaster 3.0 characters. I am using the  ChatSetAttr API, by Jakob Here is an example of what I'm attempting to do... Table:   "CULTURES" is a list of Kingdoms, nothing special: Uller Palmira Krandmiir Timeon etc. Macro:   "GENERATE-CULTURE" If I set the macro as follows, the CULTURE is being rolled from the table and is SET on the Character Sheet correctly. !setattr --sel --CULTURE|[[1t[CULTURES]]] Continuing on, each Culture has its own table for Social Class (ULLER-SOCIAL, PALMIRA-SOCIAL, KRANDMIIR-SOCIAL, TIMEON-SOCIAL, etc.). What I want to do is concatenate the value of @{selected|CULTURE} + "-SOCIAL" so it rolls on the correct table. Something like this... !setattr --sel --SOCIAL_CLASS|[[1t[@{selected|CULTURE}-SOCIAL]]] But alas, I can't figure out how to do it. Is something like this possible? Thanks in advance!
1601666599
GiGs
Pro
Sheet Author
API Scripter
You havent described what the problem is. You might be running into a problem with roll20's Order of Operations. When you run a macro, roll20 looks through the macro and replaces all attribute calls with values from the character sheet. It does this before the macro runs. So if you have those two chatsetAttrs commands in the same macro, the @{selected|CULTURE} value will be the value the sheet had before the macro ran. There's no way to get around this problem without writing a custom script. If on the other hand the problem is with the table call, it is possible to do that kind of thing, it might be being messed up by whatever the table values are.
Thanks, GiGs - I understand the order of operations and these are in two different macros. Sorry I didn't mention that. The problem lies with the table call. I want to call a table with a name prefixed with the value of the CULTURE attribute from the character sheet. The table name will be @{selected|CULTURE} concatenated with "-SOCIAL", such as Uller-SOCIAL, Palmira-SOCIAL, Timeon-SOCIAL, etc. I hope this clarifies my problem.
1601668633
GiGs
Pro
Sheet Author
API Scripter
To be specific, when you say the table name will start with  @{selected|CULTURE} , do you mean the value stored in the  @{selected|CULTURE} attribute, or do you mean the specific text " @{selected|CULTURE}"?
I mean the value stored in the  @{selected|CULTURE}  attribute
This is why I thought the following should work. But it doesn't. !setattr --sel --SOCIAL_CLASS|[[1t[@{selected|CULTURE}-SOCIAL]]]
I figured it out. Table names are Case Sensitive. I didn't know that.  The Value of the  @{selected|CULTURE}  attribute was Uller and the table name was ULLER-SOCIAL. I changed the table name to Uller-SOCIAL and it works now.  It's always some silly thing like that. Thanks for your assistance GiGs
1601671906
GiGs
Pro
Sheet Author
API Scripter
You're welcome (not that I did anything haha).
1601680444
Gold
Forum Champion
Good job folks! Thanks for innovating, Jim GiGS: Thanks for always helping people figure these issues out, and to understand what Roll20 tech is doing in the background of API and macros.
Thank for your response Gold.  I have a question about calling a macro from another macro.  I assume, it is just like using @{<Target>|Attribute} in that the #<Called_Macro> is  replaced with the actual code of <Called_Macro> before execution. Is this true?
1601685240

Edited 1601685288
Oosh
Sheet Author
API Scripter
This is correct - in fact they're expanded before Attributes , something to keep in mind if you try to use the same trick to use an Attribute name in a macro (ie it won't work.... it will attempt to find a macro called #@{attribute name}, as the Attributes have not yet been expanded). Not that I've tested this, but I'm assuming the listed order is correct.
What about using two API calls in the same Macro? For example, using the  ChatSetAttr  API to set an attribute which been generated using the  RecursiveTable API. This generates the value: !rt [[1t[SIBLING_RANK]]] The rows in the SIBLING_RANK table are: Eldest of [[1d6]] 2nd Child of [[1d6+1]] 3rd Child of [[1d6+2]] 4th Child of [[1d6+3]] 5th Child of [[1d6+4]] 6th Child of [[1d6+5]] And, this sets it on the Character Sheet: !setattr --sel --SIBLING_RANK|<Generated Value> Is there any way to combine these into a single Macro?