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

Hide formula in a macro!!

Is there any way to hide the formula of an attack and damage? I want my players to see the final result of a monster or npc attack, but I don't want them to see the calculation when they pass over the result.  Here is the macro that i use for npc.. @{selected|wtype}&{template:npcaction} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{name=@{selected|npc_name}}} {{rname=Dagger}} {{r1=[[1d20 + 1]]}} @{selected|rtype}]]}} {{dmg1=[[1d4+1]]}} {{dmg1type=Piercing}} {{dmg2=[[0]]}} {{dmg2type=}} {{crit1=[[1d4]]}} {{description= Finesse, light, thrown (range 20/60)}} @{selected|charname_output} Maybe other different macro? :S
1608674609
Kraynic
Pro
Sheet Author
I think if you put another pair of brackets around the rolls, it will hide it. Basically, the outer set of brackets is what is displayed, so if an inner roll is already resolved as an inline roll, it will just show the number on mouse over.  Using your attack roll above, you would just get the result on mouse over if the roll was structured as: [[[[1d20+1]]]].
The only way that i know is the following.... but is very rustly &{template:desc} [[ {{desc= [[1d20 + 1]] Dagger attack, [[1d4 + 1]] piercing  }}
Kraynic   it works (the formula was hidden), but when i roll a critical hit, for any reason don't sum the result......  @ {selected | wtype} & {template: npcaction} {{attack = 1}} {{damage = 1}} {{dmg1flag = 1}} {{name = @ {selected | npc_name}}} {{rname = Dagger}} {{r1 = [[[[1d20 + 1]]]]}} @ {selected | rtype}]]}} {{dmg1 = [[[[1d4 + 1]]]]}} {{dmg1type = Piercing}} {{dmg2 = [[[[0]]]]}} {{dmg2type =}} {{crit1 = [[[[1d4]]]]}} {{description = Finesse, light, thrown (range 20/60)}} @ {selected | charname_output}
Is there any way to fix the critic?
1608676261
Kraynic
Pro
Sheet Author
I'm not sure.  I don't play 5E, so I'm not sure what all logic is working on the roll template for that sheet.  If nothing else, you could just put the entire critical damage calculation with the description to use if a crit is rolled.  Or just roll the attack again and add the second damage roll to the first if that works for crit damage calculation rules for 5E.
1608683128
Oosh
Sheet Author
API Scripter
You can't really fix that unfortunately, at least not without using a custom macro for each attack. The extra set of inline brackets basically turns the roll into a flat integer, so the crit no longer fires, and the crit sections of the roll template aren't triggered. I can't think of a non-API way around that.
1609008062

Edited 1609008082
now i have access to API.... can i do this now? :P
1609024464
Oosh
Sheet Author
API Scripter
Are you always rolling for NPCs using something similar to the above macro? And is it just the total for {{r1}} and {{r2}} that you wanted to display in public chat?
Yep, NPC (hide the formula)
1609030318
Oosh
Sheet Author
API Scripter
Here's an API script that should (hopefully) work. It'll trigger on a roll from an NPC sheet that contains at least {{r1}}, is whispered to the GM, and is on a template with 'npc' in the name (npcaction, npcatk, npcfullatk): const npcRollInfo = (() => { // eslint-disable-line no-unused-vars const handleInput = (msg) => { if (msg.target === 'gm' && msg.inlinerolls && msg.rolltemplate && msg.content.match(/r1=\$\[\[(\d+)\]\]/i)) { if (!msg.rolltemplate.match(/npc/i) || msg.inlinerolls.length < 1) return; let attack1_index = msg.content.match(/r1=\$\[\[(\d+)\]\]/i)[1] let attack2_index = (msg.content.match(/r2=\$\[\[(\d+)\]\]/i)) ? msg.content.match(/r2=\$\[\[(\d+)\]\]/i)[1] : null; let attack1_total = (msg.inlinerolls[attack1_index].results.total > 0) ? msg.inlinerolls[attack1_index].results.total : null; let attack2_total = (attack2_index && msg.inlinerolls[attack2_index].results.rolls[0].dice > 0) ? msg.inlinerolls[attack2_index].results.total : null; let attack_string; if (attack1_total) { if (attack2_total) { let advantage = (msg.content.match(/\{\{advantage=1\}\}/i)) ? 1 : (msg.content.match(/\{\{disadvantage=1\}\}/i)) ? -1 : 0; if (advantage !== 0) { if ((attack1_total >= attack2_total && advantage === 1) || (attack1_total <= attack2_total && advantage === -1)) { attack_string = `**Attack Roll 1: ${attack1_total}**<br>Attack Roll 2: ${attack2_total}`; } else attack_string = `Attack Roll 1: ${attack1_total}<br>**Attack Roll 2: ${attack2_total}**`; } else attack_string = `Attack Roll 1: ${attack1_total}`; } else attack_string = `Attack Roll 1: ${attack1_total}`; let npcName = (msg.content.match(/\{\{name=([^}]+)/i)) ? msg.content.match(/\{\{name=([^}]+)/i)[1] : 'NPC'; let npcAttackName = msg.content.match(/\{rname=([^}]+)/i) ? msg.content.match(/\{rname=([^}]+)/i)[1] : 'Attack'; if (npcAttackName.match(/\(~.+\)/g)) npcAttackName = npcAttackName.replace(/\(~.+\)/g, '(#" style="color:darkred)'); let output = `&{template:npcaction} {{rname=${npcAttackName}}} {{name=${npcName}}} {{description=${attack_string}}}` sendChat(``, output); } return; } }; const registerEventHandlers = () => { on('chat:message', handleInput); }; on('ready', () => { registerEventHandlers(); }); return { }; })(); If there is no Advantage/Disadvantage, it only shows roll 1. It should also boldify the relevant roll when Advantage/Disadvantage is used. It currently picks up the {{advantage}} property from the template, if you're using any custom macros with some 2d20kh1 rolls in there, it might need some tweaking. Let me know if anything breaks, it might need some extra error checking in there.
1609339430

Edited 1609339583
Jordan C.
Pro
API Scripter
Here is a non-API way of doing this (using Oosh's trick of inline styling): @{selected|wtype}&{template:npcaction} {{attack=0}} {{damage=1}} {{dmg1flag=1}} {{name=@{selected|npc_name}}} {{rname=Dagger}} {{r1= [[[1d20 + 1]]](#" style="color:black;)}} {{always=1}} {{r2= [[[1d20 + 1]]](#" style="color:black;)}} {{dmg1= [[[1d4+1]]](#" style="color:black;)}} {{dmg1type=Piercing}} {{dmg2=[[[0]]](#" style="color:black;)}} {{dmg2type=}} {{crit1=[[[1d4]]](#" style="color:black;)}} {{description= Finesse, light, thrown (range 20/60)}} @{selected|charname_output} I took out the @{selected|rtype}]]}} which contains the values for showing the NPC's name and the r2 value. I put in {{always=1}} so that needs to be changed if you don't  want the name shown. Edit: Welp, this causes crits to get lost and won't roll the extra damage. Shucks. Maybe there's a way to get around that but I don't know what it would be yet.
1609342799

Edited 1609343364
With critical damage no problem Jordan C., (at least with the damage roll) only add a button "called critical" to roll additional damage and that's all .... :) (the critical button is another macro rolling a simple die or dice) For de hit roll, the only solution that i think, is put a /w desc template in which you put the critical hit roll.... for example npc with +2 to hit, rolls a critical hit with a result of 22 (20 + 2). For example: (added an extra line to your code at the end) @{selected|wtype}&{template:npcaction} {{attack=0}} {{damage=1}} {{dmg1flag=1}} {{name=@{selected|npc_name}}} {{rname=Dagger}} {{r1= [[[1d20 + 1]]](#" style="color:black;)}} {{always=1}} {{r2= [[[1d20 + 1]]](#" style="color:black;)}} {{dmg1= [[[1d4+1]]](#" style="color:black;)}} {{dmg1type=Piercing}} {{dmg2=[[[0]]](#" style="color:black;)}} {{dmg2type=}} {{crit1=[[[1d4]]](#" style="color:black;)}} {{description= Finesse, light, thrown (range 20/60)}} @{selected|charname_output} [``Critical hit``](!
#d4-piercing)