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

Alternative to Escaping the @ symbol

Okay my problem is thus.I'm trying to fit every single power into a single macro. For ease of use on mobile, But I've run into a problem. The template calls specific attributes on the character sheet with the @ symbol. But when the @ symbol is placed into a variable roll query assumes its trying to target a character. So I have to escape the @ symbol. But when I escape the @ symbol it loses the ability to target the attributes. Is there a way I can escape the @ symbol and still have it target the attributes its supposed to target? ?{Powers|Piercing Shard,&{template:dnd4epower} {{encounter=2 }} {{emote= As I pierce my enemy’s defenses, its perceptions of reality become twisted, cloaking me from its sight. }} {{name=Piercing Shard}} {{level=Level 1}} {{type=Encounter♦}} {{keywords=Arcane, Cold, Illusion, Implement, Psychic, Weapon }} {{action=Standard ♦}} {{range=Melee Weapon }} {{target=One Creature }} {{attack=[[ 1d20 + @{power-17-attack} ]] vs. **@{power-17-def}** }}  {{damage=[[ (floor(@{level}/21)*(@{power-17-weapon-num-dice}d@{power-17-weapon-dice})) + @{power-17-weapon-num-dice}d@{power-17-weapon-dice}+@{power-17-damage} ]] damage. }} {{critical=[[ (floor(@{level}/21)*(@{power-17-weapon-num-dice}*@{power-17-weapon-dice})) + @{power-17-weapon-num-dice}*@{power-17-weapon-dice} + @{power-17-damage} ]] damage. }} {{effect=You are invisible to the target until the start of your next turn.}}
1563040104

Edited 1563040114
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Would this Stupid Trick help? Prefix Trick to Variably Call Attributes  - Kyle G.
1563041411

Edited 1563041775
GiGs
Pro
Sheet Author
API Scripter
I'm not sure what's happening here. If I'm reading your code properly, your @ character are never nested inside each other, so they don't need replacement. I think your problem is some other part of the code. Generally most of us have given up on the madness of nested roll queries, and use Chat Menus instead.
I honestly have no idea what a prefix attribute is, or what it means to variably call attributes. I assume it means to call attributes with a variable?
@gigis Its not really the nesting that causes the need to be escaped.  Its the variable. Since they are all in a variable, they need to be escaped.
And chat menus are kind of useless for what I need this for.
1563041857
GiGs
Pro
Sheet Author
API Scripter
You should never replace characters in attribute calls. You have for example @{level} This should be @{level} Attributes are always processed before roll queries, and never need html replacements. Read  the wiki here , the section starting with "Due to the order of operations".  Devlin M. said: @gigis Its not really the nesting that causes the need to be escaped.  Its the variable. Since they are all in a variable, they need to be escaped. What would the variable look like if you didnt use any html entities?
1563042749

Edited 1563042993
GiGs
Pro
Sheet Author
API Scripter
Devlin M. said: And chat menus are kind of useless for what I need this for. Maybe I'm not understanding what this is supposed to do, but it looks to me like this is a perfect situation for a chat menu. It looks like a roll query in which you select from a list of powers, and the power you select is then rolled into chat. Is that correct? A Chat Menu does the same thing, except you get a button for each power printed in chat, and you click the button for the power you want to use. It is then rolled and printed into chat. A big advantage of the chat menu is you can create a macro or ability for each individual power and call on them in the menu. You can also call on powers directly from the character sheet. They are much simpler to write and maintain than complex nested roll queries. As a Pro user, you can even use a script to automatically build chat menus from existing powers on the character sheet, like my Universal Chat Menus or Scotts Menu Maker .
1563044168
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I probably misread what the issue was. If for reasons, you wish to nest queries and calls, you could look at this: Drop Down Nester  - Scott C. Again, I don't know if it is helpful. I tend to look at complex html replacements and my eyes start to glaze. :)
1563047407

Edited 1563047552
@gigi when I call the @ outside the variable it works fine. When I call it inside the variable it says it cannot find the character ID. So I tried escaping it. And when I escaped the @ it instead of using the value the @ reoresents (like @num_diced@weapon_dice is supposed to result in a roll of say 2d10) instead nothing happens (I just get a result of @num_dice d @weapon_dice). Chat menus dont work because the mobile interface doesnt register the tap on the buttons well or accurately. I have a couple players who have entered financial troubles and cannot use computers right now. So Im trying to make it so they can do everything in combat via drop down menus. I even plan to make macros that adjust hp and move their token that way 
And Im not nesting. Im literally using a single macro and a variable. There is no calling to other macros. 
So all I need to know really is, how to best call an attribute within a variable. How would I write ?{Example|1d20+@Strength+@dexterity| 1d20+@charisma+@surge count}
I actually should check once my battery recharges, if I can't call attributes within variables in general or if its an issue specifically with these built in sheet attributes.
1563049093
GiGs
Pro
Sheet Author
API Scripter
I didnt realise mobile would make chat buttons hard to use. I see why chat menus aren't a solution.  You are nesting. You have put a complete rolltemplate call inside a rollquery - that is nesting.  Regarding the issue: As the page I linked shows, you never replace characters in an attribute call. The problem is somewhere else. Something in the code is making it break those attribute calls. But replacing the @ won't fix it - that will force your macro to fail, because of the order of operations.  I'd try Keith's suggestion of the Drop Down Nester by Scott. And cross your fingers that Ziechael notices this thread (the resident roll query expert).
1563049545
GiGs
Pro
Sheet Author
API Scripter
Devlin M. said: So all I need to know really is, how to best call an attribute within a variable. How would I write ?{Example|1d20+@Strength+@dexterity| 1d20+@charisma+@surge count} Youre missing the brackets around those attributes, but this works (I just tested it) /roll ?{Example|str + dex,1d20+@{Strength}+@{dexterity}|cha + surge,1d20+@{charisma}+@{surge count} } Its a bad idea to have spaces in an attiribute name though.
1563092207
Ziechael
Forum Champion
Sheet Author
API Scripter
There is a lot to sift through here! Your options are thus: Have it as a token ability but checked as 'show in macro bar' so you don't need to have the token selected, this will allow generic attribute calls. Set it up as a universal macro and check 'in bar'. Just using your original example the following works out of the box with standard html replacements: ?{Powers|Piercing Shard,&{template:dnd4epower} {{encounter=2 }} {{emote= As I pierce my enemy’s defenses, its perceptions of reality become twisted, cloaking me from its sight. }} {{name=Piercing Shard}} {{level=Level 1}} {{type=Encounter♦}} {{keywords=Arcane, Cold, Illusion, Implement, Psychic, Weapon }} {{action=Standard ♦}} {{range=Melee Weapon }} {{target=One Creature }} {{attack=[[ 1d20 + @{power-17-attack} ]] vs. **@{power-17-def}** }} {{damage=[[ (floor(@{level}/21)*(@{power-17-weapon-num-dice}d@{power-17-weapon-dice})) + @{power-17-weapon-num-dice}d@{power-17-weapon-dice}+@{power-17-damage} ]] damage. }} {{critical=[[ (floor(@{level}/21)*(@{power-17-weapon-num-dice}*@{power-17-weapon-dice})) + @{power-17-weapon-num-dice}*@{power-17-weapon-dice} + @{power-17-damage} ]] damage. }} {{effect=You are invisible to the target until the start of your next turn.}}|Power 2,insert code here} For option 2 you need to prefix your attribute calls with an identifier (selected or target if you are able to use tokens in the use case, character name otherwise (such as 'Mr Test')) as below: ?{Powers|Piercing Shard,&{template:dnd4epower} {{encounter=2 }} {{emote= As I pierce my enemy’s defenses, its perceptions of reality become twisted, cloaking me from its sight. }} {{name=Piercing Shard}} {{level=Level 1}} {{type=Encounter♦}} {{keywords=Arcane, Cold, Illusion, Implement, Psychic, Weapon }} {{action=Standard ♦}} {{range=Melee Weapon }} {{target=One Creature }} {{attack=[[ 1d20 + @{Mr Test|power-17-attack} ]] vs. **@{Mr Test|power-17-def}** }} {{damage=[[ (floor(@{Mr Test|level}/21)*(@{Mr Test|power-17-weapon-num-dice}d@{Mr Test|power-17-weapon-dice})) + @{Mr Test|power-17-weapon-num-dice}d@{Mr Test|power-17-weapon-dice}+@{Mr Test|power-17-damage} ]] damage. }} {{critical=[[ (floor(@{Mr Test|level}/21)*(@{Mr Test|power-17-weapon-num-dice}*@{Mr Test|power-17-weapon-dice})) + @{Mr Test|power-17-weapon-num-dice}*@{Mr Test|power-17-weapon-dice} + @{Mr Test|power-17-damage} ]] damage. }} {{effect=You are invisible to the target until the start of your next turn.}}|Power 2,insert code here}
Ziechael said: There is a lot to sift through here! Your options are thus: Have it as a token ability but checked as 'show in macro bar' so you don't need to have the token selected, this will allow generic attribute calls. Set it up as a universal macro and check 'in bar'. Just using your original example the following works out of the box with standard html replacements: ?{Powers|Piercing Shard,&{template:dnd4epower} {{encounter=2 }} {{emote= As I pierce my enemy’s defenses, its perceptions of reality become twisted, cloaking me from its sight. }} {{name=Piercing Shard}} {{level=Level 1}} {{type=Encounter♦}} {{keywords=Arcane, Cold, Illusion, Implement, Psychic, Weapon }} {{action=Standard ♦}} {{range=Melee Weapon }} {{target=One Creature }} {{attack=[[ 1d20 + @{power-17-attack} ]] vs. **@{power-17-def}** }} {{damage=[[ (floor(@{level}/21)*(@{power-17-weapon-num-dice}d@{power-17-weapon-dice})) + @{power-17-weapon-num-dice}d@{power-17-weapon-dice}+@{power-17-damage} ]] damage. }} {{critical=[[ (floor(@{level}/21)*(@{power-17-weapon-num-dice}*@{power-17-weapon-dice})) + @{power-17-weapon-num-dice}*@{power-17-weapon-dice} + @{power-17-damage} ]] damage. }} {{effect=You are invisible to the target until the start of your next turn.}}|Power 2,insert code here} For option 2 you need to prefix your attribute calls with an identifier (selected or target if you are able to use tokens in the use case, character name otherwise (such as 'Mr Test')) as below: ?{Powers|Piercing Shard,&{template:dnd4epower} {{encounter=2 }} {{emote= As I pierce my enemy’s defenses, its perceptions of reality become twisted, cloaking me from its sight. }} {{name=Piercing Shard}} {{level=Level 1}} {{type=Encounter♦}} {{keywords=Arcane, Cold, Illusion, Implement, Psychic, Weapon }} {{action=Standard ♦}} {{range=Melee Weapon }} {{target=One Creature }} {{attack=[[ 1d20 + @{Mr Test|power-17-attack} ]] vs. **@{Mr Test|power-17-def}** }} {{damage=[[ (floor(@{Mr Test|level}/21)*(@{Mr Test|power-17-weapon-num-dice}d@{Mr Test|power-17-weapon-dice})) + @{Mr Test|power-17-weapon-num-dice}d@{Mr Test|power-17-weapon-dice}+@{Mr Test|power-17-damage} ]] damage. }} {{critical=[[ (floor(@{Mr Test|level}/21)*(@{Mr Test|power-17-weapon-num-dice}*@{Mr Test|power-17-weapon-dice})) + @{Mr Test|power-17-weapon-num-dice}*@{Mr Test|power-17-weapon-dice} + @{Mr Test|power-17-damage} ]] damage. }} {{effect=You are invisible to the target until the start of your next turn.}}|Power 2,insert code here} Well the token is selected so that shouldn't be a problem. Ok I tried adding a targeter to it. Having it target the character using the macro. The Character's name is Rosgrace Tealeaf so I adjusted the macro to be such. [[1d20+@{Rosgrace Tealeaf|power-2-attack}  ]] But all I got was No attribute was found for @{Rosgrace Tealeaf|power-2-attack} ]] vs. <strong>AC</strong>}} {{damage=[[1d10+@{Rosgrace Tealeaf}
Says no Attribute. Its a special hidden attribute created by the character sheet. That is made up of other hidden attributes.  Are hidden character sheet attributes not usable when nesting?
1563119837

Edited 1563119978
Maybe I'll just ban the use of templates from my campaign.
1563119989
Ziechael
Forum Champion
Sheet Author
API Scripter
Have you tried adding it as an ability on the sheet with no identifier? Worked fine for me or is there a larger macro at play here requiring additional nesting?
I don't know what that means exactly. Here is the error message. No attribute was found for @{Rosgrace Tealeaf|power-2-weapon-attack} ]] vs. <strong>AC</strong>}} {{damage=[[1d10+@{Rosgrace Tealeaf} And here is an image showing there is already an ability named power-2-weapon-attack
Here is the full macro I'm testing this all on. &{template:dnd4epower}  ?{Powers|Rakish Skewer,{{atwill=1}} {{emote=I strike at my opponent from strange angles, feet barely touching the ground at all as my wings keep me moving. }}  {{name=Rakish Skewer}}  {{level=1}}  {{type=At-Will}}  {{keywords=Weapon, implement, arcane, cold  }}  {{action=Standard}}  {{range=Melee Weapon}}  {{target=One Creature}}  {{attack=[[1d20+@{Rosgrace Tealeaf|power-2-weapon-attack}  ]] vs. **AC**}}  {{damage=[[1d10+@{Rosgrace Tealeaf|power-2-weapon-damage}  ]] damage.}}  {{hiteffect=I gain a +2 power bonus to all defenses against the target’s attacks until the end of your next turn and I can shift 1 square adjacent to the target.}}  {{special= I can use this power as a melee basic attack.}}   |Eldritch Bolt,{{atwill=1 }} {{emote=With a gesture, I create a shard of shimmering force and send it streaking toward my enemy.  }} {{name=Eldritch Bolt }} {{level=1 }} {{type=At-Will }} {{keywords=Implement, Arcane, Force  }} {{action=Standard }} {{range=Ranged 10 }} {{target=One Creature }} {{attack=[[1d20+@{Rosgrace Tealeaf|power-1-weapon-attack} ]] vs. **Reflex** }} {{damage=[[1d10+@{Rosgrace Tealeaf|power-1-weapon-damage} ]] force damage. }}  {{special= I can use this power as a ranged basic attack. }}|Winged Step, {{atwill=1 }} {{emote=As my enemy falls his lifeforce strengthens my wings and I take flight.  }} {{name=Winged Step}} {{level=1 }} {{type=At-Will }} {{keywords=Arcane, Flight}} {{action=Free }} {{range=Personal}}  {{trigger=I reduce an enemy to 0 hit points, or an enemy adjacent to me drops to 0 hit points.}} {{effect= I shift and fly a number of squares up to my Dexterity modifier (+3).}}}
I just noticed that the power-2-weapon-attack calls on the weapon-1-attack attribute which I don't see in the list
Added it but there was no change
I think its just not possible to do. In fact the documentation for the powercard API actually says that it cannot be done. That Attribute calls are always handled before the template is triggered. I'm guessing that is why its not possible. So I gave up and decided to tell my players to go shove it if they complain about  me banning templates. And the following is the macro I have decided to go with. [[1d20+@{weapon-1-attack}+@{halflevel}]] [[?{Weapon Dice|1|2|3}d10+@{weapon-1-damage}]] ?{Damage Type|untyped|cold|}damage. ?{Hit Effect|Skewer,I gain a +2 power bonus to all defenses against the target’s attacks until the end of your next turn and I can shift 1 square adjacent to the target.|Eldritch Bolt,No additional Effect|Piercing Shard,Effect: I turn invisible for the target until the end of my next turn.}
1563139404
Ziechael
Forum Champion
Sheet Author
API Scripter
It 100% can/does work but it gets hella complex the more you add. I'm happy to help you work through it and will try to add more description/pictures as needed. With regards to: Devlin M. said: No attribute was found for @{Rosgrace Tealeaf|power-2-weapon-attack} ]] vs. <strong>AC</strong>}} {{damage=[[1d10+@{Rosgrace Tealeaf} and: Devlin M. said: Here is the full macro I'm testing this all on. &{template:dnd4epower}  ?{Powers|Rakish Skewer,{{atwill=1}} {{emote=I strike at my opponent from strange angles, feet barely touching the ground at all as my wings keep me moving. }}  {{name=Rakish Skewer}}  {{level=1}}  {{type=At-Will}}  {{keywords=Weapon, implement, arcane, cold  }}  {{action=Standard}}  {{range=Melee Weapon}}  {{target=One Creature}}  {{attack=[[1d20+@{Rosgrace Tealeaf|power-2-weapon-attack}  ]] vs. **AC**}}  {{damage=[[1d10+@{Rosgrace Tealeaf|power-2-weapon-damage}  ]] damage.}}  {{hiteffect=I gain a +2 power bonus to all defenses against the target’s attacks until the end of your next turn and I can shift 1 square adjacent to the target.}}  {{special= I can use this power as a melee basic attack.}}   |Eldritch Bolt,{{atwill=1 }} {{emote=With a gesture, I create a shard of shimmering force and send it streaking toward my enemy.  }} {{name=Eldritch Bolt }} {{level=1 }} {{type=At-Will }} {{keywords=Implement, Arcane, Force  }} {{action=Standard }} {{range=Ranged 10 }} {{target=One Creature }} {{attack=[[1d20+@{Rosgrace Tealeaf|power-1-weapon-attack} ]] vs. **Reflex** }} {{damage=[[1d10+@{Rosgrace Tealeaf|power-1-weapon-damage} ]] force damage. }}  {{special= I can use this power as a ranged basic attack. }}|Winged Step, {{atwill=1 }} {{emote=As my enemy falls his lifeforce strengthens my wings and I take flight.  }} {{name=Winged Step}} {{level=1 }} {{type=At-Will }} {{keywords=Arcane, Flight}} {{action=Free }} {{range=Personal}}  {{trigger=I reduce an enemy to 0 hit points, or an enemy adjacent to me drops to 0 hit points.}} {{effect= I shift and fly a number of squares up to my Dexterity modifier (+3).}}} you are still escaping part of your attribute calls, @{Rosgrace Tealeaf|power-2-weapon-attack} should be simply @{Rosgrace Tealeaf|power-2-weapon-attack} in each instance.
1563139911
Ziechael
Forum Champion
Sheet Author
API Scripter
For reference, this works as both a journal ability AND a global macro (the latter can NEVER be opened again without ruining the html so keep a copy safely offsite or as an ability should you need to replace/update it): &{template:dnd4epower} ?{Powers|Rakish Skewer,{{atwill=1}} {{emote=I strike at my opponent from strange angles, feet barely touching the ground at all as my wings keep me moving. }} {{name=Rakish Skewer}} {{level=1}} {{type=At-Will}} {{keywords=Weapon, implement, arcane, cold }} {{action=Standard}} {{range=Melee Weapon}} {{target=One Creature}} {{attack=[[1d20+@{Rosgrace Tealeaf|power-2-weapon-attack} ]] vs. **AC**}} {{damage=[[1d10+@{Rosgrace Tealeaf|power-2-weapon-damage} ]] damage.}} {{hiteffect=I gain a +2 power bonus to all defenses against the target’s attacks until the end of your next turn and I can shift 1 square adjacent to the target.}} {{special= I can use this power as a melee basic attack.}}|Eldritch Bolt,{{atwill=1 }} {{emote=With a gesture, I create a shard of shimmering force and send it streaking toward my enemy. }} {{name=Eldritch Bolt }} {{level=1 }} {{type=At-Will }} {{keywords=Implement, Arcane, Force }} {{action=Standard }} {{range=Ranged 10 }} {{target=One Creature }} {{attack=[[1d20+@{Rosgrace Tealeaf|power-1-weapon-attack} ]] vs. **Reflex** }} {{damage=[[1d10+@{Rosgrace Tealeaf|power-1-weapon-damage} ]] force damage. }} {{special= I can use this power as a ranged basic attack. }}|Winged Step,{{atwill=1 }} {{emote=As my enemy falls his lifeforce strengthens my wings and I take flight. }} {{name=Winged Step}} {{level=1 }} {{type=At-Will }} {{keywords=Arcane, Flight}} {{action=Free }} {{range=Personal}} {{trigger=I reduce an enemy to 0 hit points, or an enemy adjacent to me drops to 0 hit points.}} {{effect= I shift and fly a number of squares up to my Dexterity modifier (+3).}}} Literally all I did was take your original macro and revert the additional html you'd put on the weapon-attack and weapon-damage attribute calls and remove some additional spacing/hard returns. You are close to mastering it... kudos on keeping the template call outside of the query by the way, common factors shouldn't be part of a query where possible (the final }} from each template could be omitted and a }} could be placed after the query for example).
I dont know what a global macro is, unless you just mean those macros kept in their own tab by jukebox. But it sounds like I should avoid using that anyway. Ill try your revision on a later day. 
1563153239
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
By Global Macro, Zeichael is referring to a macro in the Collections tab, yes. Many people say "macro" when they mean "Ability", or macro code stored on a character sheet/journal. I am assuming he was just erring on the side of caution in naming it that way. Macros will collapse HTML entities when they are re-opened. Abilities generally do not.
@Ziechael Yours worked but I don't understand why. How come the right brackets that were a part of the @ did not need to be escaped even though they were still inside the ?{} when the brackets of {{At-will=1}} were? Does it have to do with attribute calls being called before the roll query, whatever that is, does its magic? If I don't understand it I won't remember it. My brain always forgets anything I don't understand.
1563328522
GiGs
Pro
Sheet Author
API Scripter
Devlin M. said: Does it have to do with attribute calls being called before the roll query, whatever that is, does its magic?&nbsp; This is correct. Roll20 has an Order of Operations, described here:&nbsp; <a href="https://wiki.roll20.net/Dice_Reference#Order_of_Operations" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Order_of_Operations</a> The very first thing the dice engine does, is look for the values of any attributes in the macro. So if you replace any characters in that attribute call, the attribute isn't recognised because the html entities aren't recognised as valid characters. The point where html entities get parsed and converted into the characters they represent happens later.
On an aside, while doing this I noticed the baked in macros for some reason&nbsp; Were doing all that BS. Any idea why its doing that crazy stuff instead of just 1d20?&nbsp;
1563341805
Wes
Sheet Author
Sigh, that damn 4e sheet...&nbsp;&nbsp; (floor(4/21)*(2d10)) ~ Is Character Level (4) Divided by 21 (the level at which it will automatically add additional die to the damage roll). Floor rounds everything down so until you reach level 21 you will not get the extra damage added to the roll as it is multipyling by 0. + 2d10 + floor((19-10/2) ~ Is the actual damage dice + the calculation for the modifier for the selected attribute in this case it will resolve as 9 / 2 = 4.5 rounded down to 4. + 0 [ Weapon Enhance ]&nbsp;+ 3 [ Weapon Feat Bonus ] + 0 [ Weapon Class Bonus ] + 0 [ Weapon Misc Bonus ]&nbsp;+ 0 [ Power Damage Bonus ] All Totaling from your Image above: 21 damage.
Oh ok now I see it. Thanks.