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 .
×
May your rolls be merry + bright! 🎄
Create a free account

Nesting Queries

Ello, I am working on nesting a drop down box within a dropdown box within a dropdown box, The first drop down is for the damage type (energy, explosive, impact, rending), the 2nd is for the location (head, body, arm, leg) and the 3rd goes into the damage amount (1-10) I can get the drop downs to work, going from level to level to level, its when I get into the actual text result that I run into an issue. I try to put in a comma using the & amp ; # 44 ; but it doesn't recognize it, and just cuts the sentence off as below:  Critical Damage Energy The attack smashes the arm I tried double amping, but not sure I did that right, and I tried putting a space between the word arm and the html but that didn't work, and I'm not entirely sure what else to try next, so any help would be appreciated.  Thank you! 
Or I guess it does recognize it but I need to go a layer deeper with the commas in the result part, so how do you go to the next level from amp?
1651431820
GiGs
Pro
Sheet Author
API Scripter
If I'm following you, you can't do what you want with a macro. When the macro starts (right att he moment it starts), the macro collects all attributes and queries, and then runs with those values and can't change them again. So you can't have a query dependent on the result of another query in the same macro.
1651432779

Edited 1651432980
GiGs said: If I'm following you, you can't do what you want with a macro. When the macro starts (right att he moment it starts), the macro collects all attributes and queries, and then runs with those values and can't change them again. So you can't have a query dependent on the result of another query in the same macro. Sorry let me try to explain this again, I have 3 drop downs built into each other, so after you know the damage amount from other rolls or another macro you then run this macro to find out what kinda critical damage you've taken, choosing the type of damage in the first drop down, then the 2nd drop down you choose the location and then the 3rd you choose the amount 1-10, so when I choose the number 1-10 in the third drop down it will start the sentence but if it runs into a comma replacement, & amp ; # 44 , it comes to a stop there, so I think what my issue is is that I need to go another level down in html replacement, so I guess the question I have really is: is there another level beyond the amp for html replacement? (otherwise I'll just take the commas out and run on sentence it.) So like: ?{Type|  Energy, ?{Location| Arm, ?{Amount| 1&#44, Blah blah blah I want to put a comma after the blah, but if I try to use the &#44 it just cuts it off. 
1651432994

Edited 1651433068
GiGs
Pro
Sheet Author
API Scripter
If the issue is depth of amp replacement, you can just keep adding amp to get extra levels (I forget the exact syntax). It would be easier to figure out the issue (for those so inclined; personally I stay away from nested macros these days - that way lies madness), if you posted the complete code and said where it was failing.
GiGs said: If the issue is depth of amp replacement, you can just keep adding #amp to get extra levels. It would be easier to figure out the issue (for those so inclined; personally I stay away from nested macros these days - that way lies madness), if you posted the complete code and said where it was failing. The code is ginormous so I will toss an example of where I am trying to go:  ?{Type|  Energy, ?{Location| Arm, ?{Amount| 1&#44, Blah blah blah I want to put a comma after the blah, but if I try to use the &#44 it just cuts it off. So what would be the next step down? &#amp;44 ? 
1651433613

Edited 1651433632
GiGs
Pro
Sheet Author
API Scripter
For a nested macro, you really need to post the full thing, so people (not me) can try it out and see where its breaking - or suggest alternative approaches that work just as well.
GiGs said: For a nested macro, you really need to post the full thing, so people (not me) can try it out and see where its breaking - or suggest alternative approaches that work just as well. Alright I will post the whole of where I am at.   The point where it breaks that I am trying to figure out (and I know it breaks in other places too its still very much a work of progress) is when you choose Energy, Energy, Arm, 2. It displays out to the comma (The attack smashes the arm) and then stops there, so I am trying to figure out what needs to go there in place of the comma html that I have.  &{template:default} {{name= Critical Damage}} {{?{Critical Damage Type|    Energy |    Explosive }= ?{Type|    Energy, ?{Location 1|    Arm, ?{Amount 1-1|    1, A blast to the arm leaves it all numb and tingly. Tests made involving the arm are at -30 for 1 Round. |    2, The attack smashes the arm , sending currents of energy crackling down to the fingers and up to the shoulder. The arm is useless for [[1d5]] Rounds and the character takes 1 level of fatigue. |    3, The attack burns the targets arm leaving them Stunned for 1 Round and inflicts 2 levels of Fatigue. The arm is useless for [[1d5]] rounds. |    4, The shock of the attack makes the target vomit. They are Stunned for 1 Round and take 3 levels of Fatigue. The arm is useless for [[1d10]] Rounds. |    5, The arm suffers superficial burns inflicting no small amout of pain on the target. The target's WS and BS are halved (round down) for 1 Round and the target takes [[1d5]] levels of fatigue. |    6, The attack wreathes the arm in flame, scorching clothing and armour, and temporarily fusing together the target's fingers. The target halves WS and BS for [[1d10]] Rounds, takes [[1d5]] levels of Fatigue, and must pass a Challenging (+0) Toughness Test or lose the use of the hand permanently. |    7, With a terrible snapping sound, the heat of the attack boils the marrow in the target's arm, causing it to shatter. The target's arm is broken and until it is repaired the target counts as only having one arm. The target is Stunned for 1 Round and also takes [[1d5]] levels of Fatigue. |    8, Energy sears through the arm at the shoulder, causing the limb to be severed from the body. The target must make a Difficult (-10) Toughness Test or become Stunned for 1 Round. In addition the target takes [[1d10]] Levels of Fatigue and is suffering from Blood Loss. The target now only has one arm. |    9, Fire consumes the target's arm, burning the flesh to a crisp right down to the bone. The target must make an immediate Hard (-20) Toughness Test or die from shock. If they survive, however, the target takes [[1d10]] levels of Fatigue and is Stunned for 1 Round. The target now only has one arm. |    10+, The attack reduces the arm to a cloud of ash and sends the target crumbling to the ground where they immediately die from shock, clutching the smoking stump. } |    Body, ?{Amount 1-2|    1, A blow to the target's body steals a breath from their lungs. The target can take only a Half Action on their next turn. |    2, The blast punches the air from the target's body, inflicting 1 level of Fatigue upon them. |    3, The attack cooks the flesh on the chest and abdoment, inflicting 2 levels of Fatigue and leaving the target Stunned for 1 Round. |    4, The energy ripples all over the character, scorching their body and inflicting [[1d10]] levels of Fatigue. |    5, The fury of the attack forces the target to the ground, helplessly covering his face and keening in agony. The target is knocked to the ground and must make a Challenging (+0) Agility Test or catch on fire. The target takes [[1d5]] levels of Fatigue and must take the Stand Action to regain their feet. |    6, Struck by the full force of the attack, the target is sent reeling to the ground, smoke spiralling out of the wound. The target is knocked to the ground, Stunned for [[1d10]] rounds, and takes [[1d5]] levels of Fatigue. In addition, they must make a Challenging (+0) Agility Test or catch fire.  |    7, The intense power of the energy attack cooks the target's organs, burning their lungs and heart with intense heat. The target is Stunned for [[2d10]] Rounds and reduces their Toughness by half (rounding down). |    8, As the attack washes over the target, his skin turns black and peels off while body fat seeps out of his clothing and armour. The target is Stunned for [[2d10]] Rounds and reduces their Toughness by half (rounding down). |    9, The target is completely encased in fire, melting their skin and popping their eyes like superheated eggs. They fall to the ground a blackened corpse. |    10+, The target is completely encased in fire, melting their skin and popping their eyes like superheated eggs. They fall to the ground a blackened corpse. In addition, if the target is carrying any ammunition, there is a 50% chance it explodes. [[1d100]] (Less than 50 means it does not explode.) Unless they can make a successful Dodge Test, all creatures within [[1d5]] meters take [[1d10+5]] X Damage. If the target carried any grenades or missiles, one round after the Damage was dealt they detonate where the target's body lies with the normal effects. } |    Head, ?{Amount 1-3|    1, A grating blow to the head frazzles the target's senses, imposing a -10 penalty to all Tests (except Toughness) for 1 Round. |    2, The blast of energy dazzles the target, leaving them blinded for 1 Round. |    3, The attack cooks off the target's ear, leaving them stunned for 1 Round and inflicting 1 level of Fatigue. |    4, The energy attack burns away all of the hairs on the target's head as well as leaving them reeling from the injury. The attack deals 2 levels of Fatigue and the target is blinded for [[1d5]] Rounds. |    5, A blast of energy envelopes the target's head, burning their facea nad hair, and causing them to scream like a stuck Grox. In addition to losing their hair, they are blinded for [[1d10]] Rounds and take 3 levels of Fatigue. |    6, The attack cooks the target's face, melting their features and damaging their eyes. The target is blinded for the next [[1d10]] hours and permanently reduces their Fellowship Characteristic by [[1d10]] points. The target also takes [[1d5]] levels of Fatigue. |    7, In a gruesome display, the flesh is burned from the target's head, exposing charred bone and muscle underneath. The target is permanently blinded and takes [[1d10]] levels of Fatigue. Also, [[1d10]]. This is the target's new Fellowship unless their Fellowship is already 10 or less, in which case nobody really notices the difference. |    8, The target's head is destroyed in a convocation of fiery death. They do not survive. |    9, Superheated by the attack, the target's brain explodes, tearing apart their skull and sending flaming chucks of meat flying at those nearby. The target is no more. |    10+, Superheated by the attack, the target's brain explodes, tearing apart their skull and sending flaming chucks of meat flying at those nearby. The target is no more. Then the target's entire body catches fire and runs off headless [[2d10]] meters in a random direction ( [[1d10]] use the scatter diagram on page 248.). Anything flammable it passes, including characters, must make a Challenging (+0) Agility Test or catch fire.  } |    Leg, ?{Amount 1-4|    1, A blow to the leg leaves the target gasping for air. The target gains 1 level of Fatigue. |    2, A grazing strike against the leg slows the target for a bit. The target halves all movement for 1 Round. |    3, A blast breaks the target's leg leaving them Stunned for 1 Round and halving all moment for [[1d5]] Rounds. |    4, A solid blow to the leg sends electric currents of agony coursing through the target. The target takes [[1d5]] levels of Fatigue and halves all movement for [[1d5]] Rounds. |    5, The target's leg endures horrific burn damage, fusing clothing and armour with flesh and bone. The target takes 1 level of Fatigue and moves at half speed for [[2d10]] Rounds. |    6, The attack burns the target's foot, charring the flesh and emitting a foul aroma. The target must successfully make a Hard (-20) Toughness Test or lose the foot. On a success, the target's movement rates are halved until they receive medical attention. In addition to either result, the target takes 2 levels of Fatigue. |    7, The energy attack fries the leg, leeaving it a mess of blackened flesh. The leg is broken and until repaired, the target counts as having lost the leg. The target must make a Difficult (-10) Toughness Test or become Stunned for 1 Round. In addition the target gains [[1d5]] levels of Fatigue. |    8, Energy sears through the bone, causing the leg to be severed. The target must make a Hard (-20) Toughness Test or become Stunned for 1 Round. In addition the target gains [[1d10]] levels of Fatigue and is suffering from Blood Loss. The target now only has one leg. |     9, The force of the attack reduces the leg to little more than a chunk of sizzling gristle. The target makes a Challenging (+0) Toughness Test or dies from shock. The leg is utterly lost. |    10+, In a terrifying display of power, the leg immolates and fire consumes the target completely. The target dies in a matter of agonising seconds. } } |    Explosive, ?{Location 2|    Arm, ?{Amount 2-1|    1, The attack throws the limb backwards, painfully jerking it away from the body, inflicting 1 level of Fatigue |      2, The attack sends a fracture through the limb. The target drops anything held in the hand and takes 2 levels of Fatigue. |     3, The explosion takes [[1d5]] fingers from the target's hand. The target takes 3 levels of Fatigue and anything carried in the hand is destroyed. If this is an explosive, it goes off. Messy. |    4, The blast causes the target to howl in agony. They take [[1d5]] levels of Fatigue, are stunned for 1 Round, and the limb is useless until medical attention is received. |    5, Fragments from the explosion tear into the target's hand, ripping away flesh and muscle alike. They must immediately make a Hard (-20) Toughness Test or lose the hand. Even on a success, the hand is useless until medical attention is received. The target takes [[1d5]] levels of Fatigue.    6, The explosive attack shatters the bone and mangles the flesh turning the target's arm into a red ruin, inflicting [[1d5]] levels of Fatigue. The target's arm is broken and until repair the target counts as having only one arm. In addition, the horrendous nature of the wound means that they now suffer from Blood Loss. |    7, In a violent hail of flesh, the arm is blown apart. The target must immediately make a Challengin (+0) Toughness Test or die from shock. On a success, the target is Stunned for [[1d10]] Rounds, takes [[1d10]] levels of Fatigue, and suffers Blood Loss. The target now only has 1 arm. |    8, The arm disintegrates under the force of the explosion taking a good portion of the shoulder and chest with it. The target is sent screaming to the ground, wherethey die in a pool of their own blood and organs. |    9, With a mighty bang the arm is blasted from the target's body, killing the target instantly in a rain of blood droplets. In addition, if the target was carrying a weapon with a power source in their hand (such as a power or chain sword) then it explodes, dealing [[1d10+5]] I damage to anyone within 2 meters. |    10+, With a mighty bang the arm is blasted from the target's body, killing the target instantly in a rain of blood droplets. In addition, if the target was carrying a weapon with a power source in their hand (such as a power or chain sword) then it explodes, dealing [[1d10+5]] I damage to anyone within 2 meters. If the target is carrying any ammunition this also explodes dealing [[1d10+5]] I Damage to anyone withing [[1d10]] meters. If the target is carrying any grenades or missiles, these too detonate on their person. } |    Body, ?{Amount 2-2|    1, The target is blown backwards [[1d5]] meters and takes 1 level of Fatigue per meter travelled. They are prone where they land. |    2, The target is blown backwards [[1d10]] meters and takes 1 level of Fatigue per meter travelled. If they strike a solid object, they take [[1d5]] additional levels of Fatigue. |    3, The explosion destroys whatever armour protected the body. If the target were none, the target is blown backwards [[1d10]] meters and takes 2 levels of Fatigue per meter travelled. |    4, The explosion sends the target sprawling to the ground. They take [[1d5]] levels of Fatigue, are stunned for 1 Round, and must spend a Full Action to regain their feet. |    5, Concussion from the explosion knocks the target to the ground and tenderises their innards. The target falls down stunned for 1 Round and takes [[1d10]] levels of Fatigue. |    6, Chunks of the target's flesh are ripped free by the force of the attack leaving large, weepon wounds. The target is Stunned for 1 Round, takes [[1d10]] levels of Fatigue, and is now suffering Blood Loss. |    7, The explosive force of the attack ruptures the target's flesh and scrambles their nervous system, knocking them to the ground. The target falls down, is Stunned for [[1d10]] Rounds, and takes [[1d10]] levels of Fatigue. In addition, they are now suffering Blood Loss and can only take Half Actions for the next [[1d10]] hours as they try to regain control of their body. |    8, The target's chest explodes outward, disgorging a river of partially cooked organs onto the ground, killing them instantly. |    9, Pieces of the target's body fly in all directions as they are torn into bloody gobbets by the attack. They are dead. In addition, if the target is carrying any ammunition, it explodes dealing [[1d10+5]] I Damage to anyone within [[1d10]] meteres. If the target is carrying and grenades or missiles, these too detonate on the target's person. |    10+, Pieces of the target's body fly in all directions as they are torn into bloody gobbets by the attack. They are dead. In addition, if the target is carrying any ammunition, it explodes dealing [[1d10+5]] I Damage to anyone within [[1d10]] meteres. If the target is carrying and grenades or missiles, these too detonate on the target's person. In addition, anyone within [[1d10]] meters of the target is drenched in gore and must make a Challenging (+0) Agility Test or suffer a -10 penalty to Weapon Skill and Ballistic Skill tests for 1 Round as blood fouls their sight. } |    Head, ?{Amount 2-3|    1, The explosion leaves the target confused. They can only take a Half Action on their next turn and take 1 level of Fatigue. |    2, The flash and noise leaves the target blind and deaf for 1 round. The target takes 2 levels of Fatigue. |    3, The detonation leaves the target's face a blood ruinfrom scores of small cuts. The target takes 2 levels of Fatigue. |    4, The force of the burst knocks the target to the ground and Stuns them for 1 Round. The target takes 2 levels of Fatigue. |    5, The explosion flays the flesh from the target's face and bursts their eardrums with its force. The target is Stunned for [[1d10]] Rounds and is permanently deafened. The target takes [[1d5]] levels of Fatigue and can only take Half Actions for [[1d5]] hours. Finally , the target's Fellowship drops by [[1d10]] due to the hideous scarring. |    6, The target's head explodes under the force of the attack, leaving their headless corpses to spurt blood from the neck for the next few minutes. Needless to say this is instantly fatal. |    7, Both head and body are blown into a mangled mess, instantly killing the target. In addition, if the target is carrying any ammunition it explodes dealing [[1d10+5]] I damage to any creatures within [[1d5]] meters. If the target was carrying grenades or missiles, these too explode on the target's person. |    8, In a series of unpleasant explosions the target's head and torso peel apart, leaving a gory mess on the ground. For the rest of the fight, anyone moving over this spot must make a Challenging (+0) Agility Test or fall prone. |    9, The target ceases to exist in any tangible way, entirely turning into a kind of crimson mist. You don't get much deader than this except... |    10+, The target ceases to exist in any tangible way, entirely turning into a kind of crimson mist. You don't get much deader than this, though such is the unspeakably appalling manner in which the target was killed, that any of the target's allies who are within 2 meters of where the target stood, must make an immediate Challenging (+0) Willpower Test or spend their next Turn fleeing from the attacker. } |    Leg, ?{Amount 2-4|    1, A glancing blast sends the character backwards 1 meter. |    2, The force of the explosion takes the target's feet out from beneath them. They land Prone and take 1 level of Fatigue. |    3, The concussion cracks the target's leg, leaving them Stunned for 1 Round and halving all movement for [[1d5]] Rounds. The target takes 1 level of Fatigue. |    4, The explosion sends the taget spinning through the air. The target travels [[1d5]] meters away from the explosion and taks 1 level of Fatigue per meter travelled. It takes the target a Full Action to regain their feet and they halve all movement for [[1d10]] Rounds. |     5, Explosive force removes part of the target's foot and scatters it over a wide area. The target must make an immediate Challenge (+0) Toughness Test or permanently lose the use of their foot, inflicting [[1d5]] levels of Fatigue. On a success, the target takes [[1d5]] levels of Fatigue and halves their movement until they receive medical attention. |    6, The concussive force of the blast shatters the target's leg bones and splits apart their flesh, inflicting [[1d10]] levels of Fatigue. The leg is broken and until repaired, the target counts as having only one leg. In addition, the horrendous nature of the wound means that they are now suffering from Blood Loss. |    7, The explosion reduces the target's leg into a hunk of smoking meat. The target must immediately make a Challenging (+0) Toughness test or die from shock. On a successful test, the target is still Stunned for [[1d10]] Rounds, takes [[1d10]] levels of Fatigue, and suffers Blood Loss. The target now has only one leg. |    8, The blast tears the leg from the body in a geyser of gore, sending them crashing to the ground, blood pumping from the ragged stump. Instantly fatal. |    9, The leg explodes in an eruption of blood, killing the target immediately and sending tiny fragments of bone, clothing, and armour hurtling off in all directions. Anyone within 2 meters of the target takes [[1d10+2]] I Damage. |    10+, The leg explodes in an eruption of blood, killing the target immediately and sending tiny fragments of bone, clothing, and armour hurtling off in all directions. Anyone within 2 meters of the target takes [[1d10+2]] I Damage. In addition, if the target is carrying any ammunition, it explodes dealing [[1d10+5]] I Damage to anyone within [[1d10]] meters. If the target is carrying any grenades or missiles, these too detonate on the target's person. } } } }}
The easy work around is to just make 4 macros one for each damage type and that would pull out one level, but if there is a way to do it all in one i'd like to do that over having 4 seperate ones.
1651441923
GiGs
Pro
Sheet Author
API Scripter
You might want to look into Chat Menus .
GiGs said: You might want to look into Chat Menus . Now that looks interesting, I will look at that, thank you.
1651466233

Edited 1651466269
Oosh
Sheet Author
API Scripter
No way I'm touching that giant macro, but just to illustrate what GiGs (accurately) said - you're essentially just escaping the ampersand more for everything after the first level of escaping: ?{Color|Blue, ?{Number|1, ?{Animal|Dog,Blue/1/Dog|Cat,Blue/1/Cat} |2, ?{Animal|Dog,Blue/2/Dog|Cat,Blue/2/Cat} } |Red, ?{Number|1, ?{Animal|Dog,Red/1/Dog|Cat,Red/1/Cat} |2, ?{Animal|Dog,Red/2/Dog|Cat,Red/2/Cat} } } If you use tabs to keep track of how deeply you're nested, using the | pipe as an example: | | | | | First layer: no escape Second layer: standard escape Third layer: escaped twice: | ==> | ==> | Fourth layer: escaped thrice: | ==> | ==> | ==> | You just keep escaping the ampersand one extra time for each level of nesting. I think Roll20 does 99 unescapes before it gives up. If you need more than that *and* have an otherwise functioning macro, you're probably an AI.   I would definitely use a chat menu. Whilst getting a gigantic nested macro working is an achievement in itself, maintaining it is horrible.
Oosh said: No way I'm touching that giant macro, but just to illustrate what GiGs (accurately) said - you're essentially just escaping the ampersand more for everything after the first level of escaping: ?{Color|Blue, ?{Number|1, ?{Animal|Dog,Blue/1/Dog|Cat,Blue/1/Cat} |2, ?{Animal|Dog,Blue/2/Dog|Cat,Blue/2/Cat} } |Red, ?{Number|1, ?{Animal|Dog,Red/1/Dog|Cat,Red/1/Cat} |2, ?{Animal|Dog,Red/2/Dog|Cat,Red/2/Cat} } } If you use tabs to keep track of how deeply you're nested, using the | pipe as an example: | | | | | First layer: no escape Second layer: standard escape Third layer: escaped twice: | ==> | ==> | Fourth layer: escaped thrice: | ==> | ==> | ==> | You just keep escaping the ampersand one extra time for each level of nesting. I think Roll20 does 99 unescapes before it gives up. If you need more than that *and* have an otherwise functioning macro, you're probably an AI.   I would definitely use a chat menu. Whilst getting a gigantic nested macro working is an achievement in itself, maintaining it is horrible. I'm going to play with chat menus now, but thank you for explaining how that worked, I was trying to add additional & where I only needed amp; I really appreciate both of your help with this thank you very much!