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

Outputting dynamic text using values

Is there a way to make a macro output text based upon a value? Here is my intent: In the D&D 5E Character sheet within the Resources tab, I have a resource that flips between 0 and 1. I want to make a macro within the sheets "Attributes and Abilities" tab that outputs either "Something" or "" depending on whether or not the resource value is 0/1. Nothing else being output, just the text. This way, if a different macro calls for this output, it can get the desired output automatically (no queries, etc. Only manual part is editing the value) Are there ways in which I can do so?
1710617818
Gauss
Forum Champion
You can set that up via Rollable Tables.  Create two Rollable Tables Name one of them 0inserttablenamehere Name the other 1inserttablenamehere then your rolls of 0 or 1 would be:  [[1t[[[here is your roll]]inserttablenamehere]]] Next, in 0inserttablenamehere create one entry. Name the entry the output you want on a 0.  Finally,  in 1inserttablenamehere create one entry. Name the entry the output you want on a 1.  Note: I don't know how you are generating the 1 or 0, you will need to provide more information if you want additional help on how to get this working. 
I will try this out - as for generating the 1 or 0 in the Resource (@{repeating_resource_$#_resource_left}), that would be done manually in the character sheet itself. I do not mind doing so as I only need to click on the field, and scroll either up/down once to set it to the value I desire To put my idea more fully, I aim to create a way to append the "Damage Type" field of a macro-called weapon with additional types depending on if said resource is 0/1 - ie if it is "Force", and I wanted to append it with "Piercing", the result would be "Force, Piercing" (the tablename being ", Piercing" to smoothly sit next to "Force") (EDIT) - I seem to be unable to find the "Add" button under Collections for Roll-Tables, am I missing anything?
1710619341
Gauss
Forum Champion
Your GM will need to create the Rollable table.  The table names need to be identical. You cannot use two table names.  However, the outputs are different. 
You can do this using the Prefix Trick since it's attribute based. You could use the following attributes:- IsPiercing0 IsPiercing1 , Piercing IsPiercing @{prefix}@{character_name}|IsPiercing@{your attribute for resource}} Then in your damage types you'd set them as "Force@{IsPiercing}" etc. You don't have to use the "IsPiercing" attribute you can also, in your damage type, set it as "Force@{prefix}@{character_name}|IsPiercing@{your attribute for resource}}"
Thank you for your suggestion - I am giving that a try now. I am not sure if I am doing it correctly, but I seem to be seeing an error saying "No attribute was found for @{character_name|prefix}" (among some others) - So to clarify my exact steps, in the D&D5E Character Sheet in Attributes and Abilities, I added 3 new items under Attributes, and named them "ACPBT0, ACPBT1, ACPBT" ACPBT0 is blank on the Current and Max field ACPBT1 has ", Piercing" in the Current field, and nothing in Max ACPBT has "@{ACPBT}@{character_name}|ACPBT@{repeating_resource_$2_resource_left}}" in Current, nothing in Max Within the macro I am using that calls for this, I have it set as {{dmg1type=Force@{ACPBT}}} I am thinking that I may be mistaking what to put in the Prefix field, as setting it back to "prefix" gives me the error above as well as a similar second one for "@{char_name|char_name}".
I probably should have been clearer. To use the Prefix trick you need need another attribute called "prefix" that contains @{ With ACPBT being @{prefix}@{character_name}|ACPBT@{repeating_resource_$2_resource_left}}
Okay, made some progress for sure Current steps; ---Custom Attributes---     prefix:    @{ ACPBT0:     ACPBT1:    , piercing ACPBT:     @{prefix}@{Char_Name}|ACPBT@{repeating_resource_$2_resource_left}} (Character Ability) Macro being used: @{char_name|wtype}&{template:dmg} {{rname=Arm-Cannon}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[((1d6 + %{char_name|PB}) + @{spell_attack_bonus}[SPELL] + 3[MOD]) * %{char_name|CHB}]]}} {{dmg1type=Force@{ACPBT}}} {{desc=54}} {{spelllevel=}} {{innate=}} {{globaldamage=[[0]]}} It does still error out when trying to output the arg, but it does read the attribute name at least - if @{repeating_resource_$2_resource_left} is 1, it outputs the damage type as "ForceChar_Name|ACPBT1", and if 0, "ForceChar_Name|ACPBT0" The errors that come with this are two sets saying "No attribute was found for @{Char_Name|Char_Name}". What might I be doing incorrectly? (clarifying what %{Char_Name|PB} and %{Char_Name|CHB} are, those determine what damage is added if other resources are 0 or 1; ie |PB is "[[@{repeating_resource_$2_resource_left}[Plasma]*1d8]]", and |CHB "[[{{[[@{repeating_resource_$2_resource_right}[Charge]]],0}>1}*2+(1)]]")
Change all instances of 'char_name' to be 'character_name' instead.  .█████╗ ██╔══██╗ . said: ---Custom Attributes---     prefix:    @{ ACPBT0:     ACPBT1:    , piercing ACPBT:     @{prefix}@{character_name}|ACPBT@{repeating_resource_$2_resource_left}} (Character Ability) Macro being used: @{character_name|wtype}&{template:dmg} {{rname=Arm-Cannon}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[((1d6 + %{character_name|PB}) + @{spell_attack_bonus}[SPELL] + 3[MOD]) * %{character_name|CHB}]]}} {{dmg1type=Force@{ACPBT}}} {{desc=54}} {{spelllevel=}} {{innate=}} {{globaldamage=[[0]]}}
Wait like literally 'character_name' or with my actual characters name? I've just been saying "char_name" as a substitute for my chars name, I've been using the actual char name for all of this
Literally @{character_name} 
On all of the ability macros and attributes associated? I tried the changes Jarren had shown above as they were, but when running the macro, I got this: No ability was found for %{character_name|PB} No ability was found for %{character_name|CHB} No character was found for 'character_name' SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-], [+|\-|*|\/|%] or [0-9] but "c" found.
Only in the attribute ACBPT. For the abilities (PB & CHB) use the actual name as you had before
Ah, okay. Trying now Yooo it worked =0 Ty for all the clarification guys. I'm really glad this works - I'll continue experimenting with this and see how much I can do w/ it
Okay - here is my still-in-progress but conceptually working set of stuff that I have done to more/less create a Ranged Weapon that can be upgraded with additional damage types/damages based on stuff - based (directly) off of the Arm-Cannon from Metroid, with everyone's help here, thank you Attribute List: prefix     @{ --Charge-- ACCBT0:     ACCBT1:    Charged, ACCBT:     @{prefix}@{character_name}|ACCBT@{repeating_resource_$1_resource_left}} --Spazer-- ACSBT0:     ACSBT1:    , Spazer ACSBT:     @{prefix}@{character_name}|ACSBT@{repeating_resource_$2_resource_left}} --Ice-- ACIBT0:     ACIBT1:    , Ice ACIBT:     @{prefix}@{character_name}|ACIBT@{repeating_resource_$3_resource_left}} --Wave-- ACWBT0:     ACWBT1:    , Electrical ACWBT:     @{prefix}@{character_name}|ACWBT@{repeating_resource_$4_resource_left}} --Plasma-- ACPBT0:     ACPBT1:    , Piercing ACPBT:     @{prefix}@{character_name}|ACPBT@{repeating_resource_$5_resource_left}} (I know "Spazer" isn't a damage type, I don't really know what to do for that one honestly) Character Ability Macro: [Macro Name: AC] &{template:atk} {{mod=+[[@{spell_attack_bonus}[SPELL] + [[2[Crafted]+@{repeating_resource_$0_resource_left}[Infused]]][MOD] + @{pb}[PROF]]]}} {{rname=[Arm-Cannon](~-1234567890_1234567|ACA)}} {{r1=[[@{my_char|d20}cs>20 + @{spell_attack_bonus}[SPELL] + [[2[Crafted]+@{repeating_resource_$0_resource_left}[Infused]]][MOD] + @{pb}[PROF]]]}} @{my_char|rtype}cs>20 + @{spell_attack_bonus}[SPELL] + [[2[Crafted]+@{repeating_resource_$0_resource_left}[Infused]]][MOD] + @{pb}[PROF]]]}} {{range=120ft}} {{desc=}} [Macro Name: ACA] &{template:dmg} {{attack=1}} {{dmg1flag=1}} {{dmg1=[[floor(((1d6 + %{my_char|IB} + %{my_char|WB} + %{my_char|PB}) + @{spell_attack_bonus}[SPELL] + [[2[Crafted]+@{repeating_resource_$0_resource_left}[Infused]]][MOD]) * %{my_char|SB} * %{my_char|CHB})]]}} {{dmg1type=@{ACCBT}Force@{ACSBT}@{ACIBT}@{ACWBT}@{ACPBT}}} [Macros: CHB, SB, IB, WB, PB (each will be 1 space apart for ease of viewing)] [[@{repeating_resource_$1_resource_left}[Charge]*2+1]] [[@{repeating_resource_$2_resource_left}[Spazer]*0.5+1]] [[@{repeating_resource_$3_resource_left}[Ice]*1d4]] [[@{repeating_resource_$4_resource_left}[Wave]*1d4]] [[@{repeating_resource_$5_resource_left}[Plasma]*1d8]] This is pretty solid, and at least for me it seems to work very well. Might attempt adding stuff for Missile types next. That will be fun lol. By all means as well, critique this and suggest ways that I can do this better - I'm all for learning different ways to approach these things