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

Button in chat from character sheet/roll template

Hello, I am trying to do something very similar to the 5e roll20 sheet where if you click on the weapon name in the chat, it acts like an API/Ability button and calls another roll template in chat to show damage.  I tried looking through the 5e character sheet code... but its a bit noisy for my lack of knowledge. Currently I have it partially there (I think).  I have a roll template that works and it kicks out what I kind of want the button to look like (just need to bold it). When I click on the text in the chat to roll the damage, it sends me to a 404 webpage.  What I think I want it to do is to reference ANOTHER button within the same repeating section (thats hidden) that kicks out a roll template that rolls the damage dice. I am thinking that I need to do something with the reference to the button and using that whole repeating_0_something referencing, but I am not certain. Currently the second button is %geardamage and I am using  [@{geardmg}](%geardamage) as the button. <!-- ROLL TEMPLATE --> <rolltemplate class="sheet-rolltemplate-gear"> <div class="sheet-template-container"> <div class="sheet-template-header">{{rollname}}</div> <div class="sheet-template-row">Attr: {{attribute}}    Skill: {{skill}}</div> <div class="sheet-template-row">Skill Check: {{skillcheck}}</div> {{#rollGreater() downstep 0}}<div class="sheet-template-row">Downsteps: {{downstep}}</div>{{/rollGreater() downstep 0}} {{#rollGreater() upstep 0}}<div class="sheet-template-row">Upsteps: {{upstep}}</div>{{/rollGreater() upstep 0}} {{#rollGreater() plotpoints 0}}<div class="sheet-template-row">Plot Points: {{plotpoints}}</div>{{/rollGreater() plotpoints 0}} <div class="sheet-template-row">Damage: {{damage}}</div> </rolltemplate> <fieldset class="repeating_gear"> <input type="text" class="Itemname" name="attr_gear" Placeholder="Gear"/> <input class="sheet-Itemqty" style="width:200px;" type="text" name="attr_gearnote" placeholder="Description"/><input class="sheet-Itemqty" type="text" name="attr_gearrng" placeholder="Range"/><input class="sheet-Itemqty" type="text" name="attr_gearammo" placeholder="Ammo"/><input class="sheet-itemqty" type="number" name="attr_gearqty" placeholder="Qty" style="width: 60px;"/><input class="sheet-Itemqty" type="text" name="attr_geardmg" placeholder="Rating"/><input class="sheet-Itemqty" type="text" name="attr_geartrait" placeholder="Trait"/> <button class="taco" type='roll' name='roll_gear' value='&{template:gear} {{rollname=@{gear}}} {{attribute=@{gearattributename}}} {{skill=@{gearskillname}}} {{skillcheck=[[d@{gearattribute} [attr] + @{gearmod} [mod] + (d[[ [[@{gearskill}-(?{downstep|0}*2) ]]-([[{[[@{gearskill}-(?{downstep}*2) ]]-12,0}k1]])]] + [[floor([[@{gearskill}-(?{downstep}*2) ]]/13)]]d[[{[[@{gearskill}-(?{downstep}*2) ]]-12,0}k1]]) [skill] + [[ceil(@{gearextra}/13)]]d[[@{gearextra}]] [extra] + {d[[(?{plot points|0}-floor((?{plot points}-1)/6)*(?{plot points}-6))*2]]+d[[{0,(2*[[?{plot points}-6]])}kh1]]cs99, ?{plot points}+d0cs1}kh1 [plot points]]]}} {{downstep=[[?{downstep}]] }} {{upstep=[[(?{downstep}*-1)]]}} {{plotpoints=[[?{plot points}]] }} {{damage=[@{geardmg}](%geardamage)}}'></button> <input style="margin-left:-20px" type="checkbox" class="sheet-toggle-show1" /> <div class="sheet-body1"> <span class="smallfont">  Attribute:</span> <input type="text" style="width:80px;" class="sheet-skill_die2" name="attr_gearattributename" Placeholder="name"/> <select class="sheet-skill_die" name="attr_gearattribute"> <option value="0"></option> <option value="[[@{agility}]]">AGI</option> <option value="[[@{strength}]]">STR</option> <option value="[[@{vitality}]]">VIT</option> <option value="[[@{alertness}]]">ALT</option> <option value="[[@{intelligence}]]">INT</option> <option value="[[@{willpower}]]">WIL</option> </select> <span class="smallfont">   Mod:</span> <input type="number" class="sheet-skill_die2" name="attr_gearmod" Value="0" Placeholder="Mod"/> <span class="smallfont">     Skill:</span> <input type="text" style="width:80px;" class="sheet-skill_die2" name="attr_gearskillname" Placeholder="name"/> <select class="sheet-skill_die" style="width:70px" name="attr_gearskill"> <option value="0"></option> <option value="2">d2</option> <option value="4">d4</option> <option value="6">d6</option> <option value="8">d8</option> <option value="10">d10</option> <option value="12">d12</option> <option value="14">d12+d2</option> <option value="16">d12+d4</option> <option value="18">d12+d6</option> <option value="20">d12+d8</option> <option value="22">d12+d10</option> <option value="24">d12+d12</option> </select> <span class="smallfont">   Extra:</span> <select class="sheet-skill_die" name="attr_gearextra"> <option value="0"></option> <option value="2">d2</option> <option value="4">d4</option> <option value="6">d6</option> <option value="8">d8</option> <option value="10">d10</option> <option value="12">d12</option> </select> <textarea style="width:650px; height:50px; margin-left:10px;" name="attr_gearnotebox" placeholder="Notes" style="border: solid black 1px;"></textarea> <button hidden="true" name="roll_geardamage" value="&{template:gear} {{damage=[[@{geardmg}]]}}"/> </div> </div> </fieldset> css .sheet-rolltemplate-gear div.sheet-template-container { border: 2px solid #000 !important; border-radius: 3px 3px 3px 3px; } .sheet-rolltemplate-gear .sheet-template-header { background-color: rgba(255, 255, 255, 1); color: #000; padding: 2px; border-bottom: 1px solid black; line-height: 1.6em; font-size: 10px; font-family: "Krona One", Gadget, sans-serif; } .sheet-rolltemplate-gear div { padding: 0.5px; border-bottom: 1px solid black; } .sheet-rolltemplate-gear .sheet-template-row { background-color: rgba(217, 217, 214,1); font-size: 8px; font-family: "Krona One", Gadget, sans-serif; } .sheet-rolltemplate-gear .inlinerollresult { display: inline-block; min-width: 1.5em; text-align: center; border: 2px solid rgba(167, 168, 170,1); } .sheet-rolltemplate-gear .inlinerollresult.fullcrit { border: 2px solid #3FB315; } .sheet-rolltemplate-gear .inlinerollresult.fullfail { border: 2px solid #B31515; } .sheet-rolltemplate-gear .inlinerollresult.importantroll { border: 2px solid #4A57ED; }
1597558046
GiGs
Pro
Sheet Author
API Scripter
So, this is your damage button {{damage=[@{geardmg}](%geardamage)}} You are very nearly there. You have two problems. The first is this is the wrong syntax. You want to be using this syntax: {{damage=[@{geardmg}](~geardamage)}} The second problem is, this is inside a repeating section. Remember that attribute and button names inside a repeating section are partial. Say, for example, you wanted to roll the %{gear} button in a macro, you would need to supply the following pieces of information: The character whose attribute you want to check The repeating section name the row number the attribute name within the repeating section. So you might end up with an button call like %{selected|repeating_gear_$0_gear} When you refer to the attribute from within the repeating section, roll20 already knows which character it is (you are clicking it on a character sheet, so roll20 uses that character), and which repeating section, and which row. It gets them all from where you clicked. So it magically adds those bits - but if you examine the the chat log, you can see its added those bits. But, when you print a button to chat, and plan to click it from the chat, roll20 doesnt know which character the button is from, nor repeating section it belongs in, or what row its from. If you give it the character and section, it'll fill in the row automatically. So the solution here is to change your button code from this: {{damage=[@{geardmg}](%geardamage)}} to this {{damage=[@{geardmg}](~repeating_gear_geardamage)}} I cant remember off-hand if you need to do the same with the button title. If so, you'd need to do this: {{damage=[@{ repeating_gear_ geardmg}]( ~repeating_gear_geardamage) }} But I dont think you need to do that. Doing it this way, roll20 will supply the character and row id when your button gets printed to chat.
Here I have inserted a button into an action on the 5e sheet that references to another character sheet. If they fail their save I can call the short term madness table from the second sheet. Or it could reference back to its own sheet for anything (dmg, spell, whatever). Sorry if I’m off-track with what you are trying to do.
1597597357
GiGs
Pro
Sheet Author
API Scripter
The suggestion i gave was under the assumption you were creating a custom character sheet. I have no experience with the 5e sheet. What I was suggesting was a long-winded way of suggesting making a tiny change to this line: <button class="taco" type='roll' name='roll_gear' value='&{template:gear} {{rollname=@{gear}}} {{attribute=@{gearattributename}}} {{skill=@{gearskillname}}} {{skillcheck=[[d@{gearattribute} [attr] + @{gearmod} [mod] + (d[[ [[@{gearskill}-(?{downstep|0}*2) ]]-([[{[[@{gearskill}-(?{downstep}*2) ]]-12,0}k1]])]] + [[floor([[@{gearskill}-(?{downstep}*2) ]]/13)]]d[[{[[@{gearskill}-(?{downstep}*2) ]]-12,0}k1]]) [skill] + [[ceil(@{gearextra}/13)]]d[[@{gearextra}]] [extra] + {d[[(?{plot points|0}-floor((?{plot points}-1)/6)*(?{plot points}-6))*2]]+d[[{0,(2*[[?{plot points}-6]])}kh1]]cs99, ?{plot points}+d0cs1}kh1 [plot points]]]}} {{downstep=[[?{downstep}]] }} {{upstep=[[(?{downstep}*-1)]]}} {{plotpoints=[[?{plot points}]] }} {{damage=[@{geardmg}](%geardamage)}}'></button> Right at the end of that line is this: {{damage=[@{geardmg}](%geardamage)}}'></button> Change that to  {{damage=[@{geardmg}](~repeating_gear_geardamage)}}'></button> and see if it works.
Yeah I am creating a custom.  I think Stavros was point out on how to do it via macro (which still helps as it confirms the repeating item issue, so thank you Stavros!) Thank you GiGs!  I wasn't understanding the ~ and % difference I guess.  It makes sense to use the correct one... and to utilize the repeating section call since it is no longer 'in the character sheet' like you mentioned before! GiGs said: The suggestion i gave was under the assumption you were creating a custom character sheet. I have no experience with the 5e sheet. What I was suggesting was a long-winded way of suggesting making a tiny change to this line: <button class="taco" type='roll' name='roll_gear' value='&{template:gear} {{rollname=@{gear}}} {{attribute=@{gearattributename}}} {{skill=@{gearskillname}}} {{skillcheck=[[d@{gearattribute} [attr] + @{gearmod} [mod] + (d[[ [[@{gearskill}-(?{downstep|0}*2) ]]-([[{[[@{gearskill}-(?{downstep}*2) ]]-12,0}k1]])]] + [[floor([[@{gearskill}-(?{downstep}*2) ]]/13)]]d[[{[[@{gearskill}-(?{downstep}*2) ]]-12,0}k1]]) [skill] + [[ceil(@{gearextra}/13)]]d[[@{gearextra}]] [extra] + {d[[(?{plot points|0}-floor((?{plot points}-1)/6)*(?{plot points}-6))*2]]+d[[{0,(2*[[?{plot points}-6]])}kh1]]cs99, ?{plot points}+d0cs1}kh1 [plot points]]]}} {{downstep=[[?{downstep}]] }} {{upstep=[[(?{downstep}*-1)]]}} {{plotpoints=[[?{plot points}]] }} {{damage=[@{geardmg}](%geardamage)}}'></button> Right at the end of that line is this: {{damage=[@{geardmg}](%geardamage)}}'></button> Change that to  {{damage=[@{geardmg}](~repeating_gear_geardamage)}}'></button> and see if it works.
Haha, damnit! I forgot type='roll' in the hidden button.   It is working now!  Thank you so much GiGs 
1597605261
GiGs
Pro
Sheet Author
API Scripter
Oh yes, I missed that too :) You're welcome!
Hopefully one final question on this topic. Is there a way to CSS the purple API button?  I do not understand how to get to it in the character sheet builder.  Like I see I can edit it via inspect in chrome, but I can't follow the path back.  
1597609288
GiGs
Pro
Sheet Author
API Scripter
This isnt obvious. The button is actually a hyperlink, so you can target it with .sheet-rolltemplate-gear a[href^="~"] { /* your style here */ } This will target all buttons in the rolltemplate. You can give them a class or put them inside a div with a class if you want to target specific buttons.