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

We lose some functionality when creating a token action

1739892892

Edited 1739893006
Joel
Pro
We are playing Mongoose Traveller 2nd Edition with the sheet for that. When you make an attack roll, it calculates the difference between your 2d6+mods attack roll and the number 8, the result is called the Effect. So a total 2d6+mods roll of 11 would have an Effect of 3 (ie 11 - 8 = 3). The Effect is shown in the chat template, and if the Effect is positive, it is automatically added to your damage. This works as expected when rolling from the sheet. But when I copy and paste the chat entry and create a token action, everything works except the Effect, which is always displayed as 0 and therefore nothing is added to the damage. I imagine there is something behind the scenes in the combat template or something, but I am curious if anyone can see a way I could trick it into working from the token action. For all I know, I just need to insert a single quote or a backtick or some other obscure formatting that will fix this and make it work the same from the token action as it does from the sheet. The chat entry looks like this (and works), and I emboldened the Effect part just to draw your attention to it. The token action is identical but the Effect does not work. @{Jerry|whispertoggle}&{template:combat@{Jerry|alt_rolltemplate_val}} {{character=@{Jerry|character_name}}} {{weapon=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_name-rep}}} {{effect=[[0D6]]}} @{Jerry|ro_default_rolltype} + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_DM-rep}[DM] + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_skill-rep}[Skill] @{Jerry|ro_default_mod}]]}}  {{damage=[[{2D6-3,1D1}KH1+0]]}} {{range=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_range-rep}}}
1739901097
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
The calculation is done by the sheet. When you make a token action this way, you are only making a static roll. The better way to make a token action is to call the actual button on the aheoon your token action. You can find the name of the button by right clicking on it and selecting "inspect". This will bring up a window in the browser showing the underlying html. Look for the name property of the highlighted button element. The name of the button will be in the format "act_button_bame" or "roll_button_name". Remove the act_ or roll_ prefix and add the repeating section information as an ability call: %{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_button_name} Now, when you call the token action, it will actually call the relevant button on the sheet and all logic that the sheet would normally run will be activated.
%{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_button_name} We're halfway there! Thank you, your instructions for the act_ / roll_ were spot on, that part is working fine now. But the last part is now not working... I didn't bring it up before but I'm using the Ammo API, so at the end of the token action, the last line has always been !ammo @{selected|token_id} repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_magazine-rep -1 which has always worked fine, even when the Effect wasn't working. Now that I followed your instructions, the Effect is working perfectly, but for some reason the Ammo API isn't doing anything. The API sandbox is fine, and the API still works with the old token action, it only doesn't work with this new token action. 
Scott C. said: %{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_button_name} I tried putting the firing of the weapon into its own macro and calling that from the token action, then the !ammo, but no luck. Tried the opposite, putting the !ammo in its own macro and calling it from the token action, but no luck. I even tried putting both actions into separate macros and calling them from the token action, but no luck. LOL. So right now it looks like we can either have it automatically calculate the Effect, or we can have it automatically reduce the ammo, but not both, at least not the way I currently have it set up.
1739921440

Edited 1739979168
Joel
Pro
As a sloppy workaround, this works, but isn't as automated as I would like. !ammo @{selected|token_id} repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_magazine-rep -1 [Fire Weapon](~Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_roll-weapon-rep) I'd love for it to work as seamlessly and automatically as the 5e sheet does with arrows.
1739977378

Edited 1739980182
Joel
Pro
Anyone know why I can't get it to perform the %roll and then run the !ammo command? Or even do it the other way round? I've been searching for ways to make this work, but come up with nothing. ChatGPT gave me about 18 things to try, none of them worked. In a single token action, calling the %attack-roll first and then the !ammo command second does not work. %{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_roll-weapon-rep} !ammo @{selected|token_id} repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_magazine-rep -1 That token action does not work, even though the two elements separately work just fine. When combined into one token action, it makes the roll, but ignores the !ammo. Reversing the order of the two lines does not work either, it still makes the roll but ignores the !ammo. After trying many variations, the only way I have gotten it to do both is to make the attack roll a chat button. I'm hoping someone can see a simple fix that will make both of those commands work from one token action without needing to press a second button. Thank you for any insights. 
1739979692
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Doesn't surprise me that chatgpt gave you nothing. They are large language models and need a huge amount of data in order to predict anything and can't really do anything new. It's not clear from your posts, but have you tried: %{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_button_name} !ammo @{selected|token_id} repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_magazine-rep -1
1739980418

Edited 1739980912
Joel
Pro
Scott C. said: Doesn't surprise me that chatgpt gave you nothing. They are large language models and need a huge amount of data in order to predict anything and can't really do anything new. It's not clear from your posts, but have you tried: %{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_button_name} !ammo @{selected|token_id} repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_magazine-rep -1 You and I both realized it wasn't clear at the same time. I edited my last post to include the full code that is not working. But to answer you directly, yes, I have tried that. To be fair to ChatGPT, it is what told me to try making the roll a chat button, which did work, for whatever that is worth. But I was hoping there was some esoteric knowledge that I needed to put a reverse-semi-colon or something after the roll in order to break them up into two separate commands. If only it was as simple as adding some curly brackets or umlauts or something.
1739991062
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, something is funky then, cause that should work. I'll see if I can replicate in a game.
Awesome, thanks. I thought maybe I should start a new post with this new problem as the subject, in case someone was like "ok, I know that one"... so if you see that one, that's why I started a new post.
1739993595
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Looks like there is something going on with action buttons on sheets and combining them with any other content in the chat message. I think this is new behavior (aka a bug), but checking with some folks about that.
I'm not familiar with this particular sheet, but couldn't you just reconstruct the correct roll in the template and call the relevant attributes from the sheet, and get around this whole sheet button issue? It looks like you're all overcomplicating what's really just a rather simple inline roll in a template.
I'm unfamiliar with the game, but assuming the mod you mentioned is the same as the modifier setting that adds a query to the effect, this should do the trick: @{Jerry|whispertoggle}&{template:combat@{Jerry|alt_rolltemplate_val }} {{character=@{Jerry|character_name} }} {{weapon=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_name-rep} }} {{effect:[[2d6 @{ro_default_mod} -8]] }} @{Jerry|ro_default_rolltype} + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_DM-rep}[DM] + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_skill-rep}[Skill] @{ro_default_mod}]]}}  {{damage=[[{2D6-3,1D1}KH1+0]] }} {{range=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_range-rep}}} I'm not quite certain why the sheet makes it more complicated than it needs to be, but it's probably because of how it handles the modifier setting. And if you're saving this in the character sheet to use as a token action, you don't need any of the Jerry| parts in the attribute calls, as the shorthand form works just fine on the sheet. EDIT: Removed an errant +
1740070550
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
That is what Joel originally did, which you can see in their original post. This sheet has additional roll processing that is done by the sheet though, and that can't be triggered just by replicating the output.
1740073563

Edited 1740074207
Joel
Pro
Tuo said: I'm unfamiliar with the game, but assuming the mod you mentioned is the same as the modifier setting that adds a query to the effect, this should do the trick: @{Jerry|whispertoggle}&{template:combat@{Jerry|alt_rolltemplate_val }} {{character=@{Jerry|character_name} }} {{weapon=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_name-rep} }} {{effect:[[2d6 @{ro_default_mod} -8]] }} @{Jerry|ro_default_rolltype} + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_DM-rep}[DM] + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_skill-rep}[Skill] @{ro_default_mod}]]}}  {{damage=[[{2D6-3,1D1}KH1+0]] }} {{range=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_range-rep}}} I'm not quite certain why the sheet makes it more complicated than it needs to be, but it's probably because of how it handles the modifier setting. And if you're saving this in the character sheet to use as a token action, you don't need any of the Jerry| parts in the attribute calls, as the shorthand form works just fine on the sheet. EDIT: Removed an errant + I appreciate the effort, and I see what you did there with the Effect. It has a little typo of a colon instead of an equal sign, but when fixed it doesn't calculate the Effect properly, maybe I could figure out how to make that work, but it still doesn't add it to the damage correctly. There might be something here to work with and see if I can get it straight, but right now the Effect varies wildly from one roll to the next. It's math, it must be understandable but right now I'm at a lost. I've made 10 rolls and can't figure out the pattern yet, lol. Either I am hopeless or this quest is hopeless, lol, but I do appreciate your contribution and it'll give me something to puzzle over for a few days. I'll post some rolls in a few minutes...
Oh right, I forgot the part about adding it to the damage - this would do it, then: @{Jerry|whispertoggle}&{template:combat@{Jerry|alt_rolltemplate_val }} {{character=@{Jerry|character_name} }} {{weapon=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_name-rep} }} @{Jerry|ro_default_rolltype} + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_DM-rep}[DM] + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_skill-rep}[Skill] @{ro_default_mod}]]}}  {{damage=[[{2D6-3,1D1}KH1+{$[[1]],0}kh1 [Effect]]] }} {{range=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_range-rep} }} {{effect=[[ [[2d6@{ro_default_mod}-8]] ]]}}: }} This should work, though the effect will have some square brackets around it.
1740075132

Edited 1740075332
Joel
Pro
These are the results from your first attempt. (I'll work on your second one now.) I think it is re-rolling 2d6 to figure the Effect instead of using the existing Attack roll. And then it isn't applying the result to the damage. In the table below, the header shows what each calculation is supposed to be, and the rows show the actual results. I can't explain the result that is just (). Attack (2d6 + Mods) Effect (Attack - 8) Damage (2d6-3, minimum 1) Damage + Effect (if positive) 8 (4+2+2) 0 (2+6-8) 7 (4+6-3) 7 12 (4+6+2) 0 () 3 (3+3-3) 3 6 (2+2+2) 0 (5+3-8) 2 (2+2-3) 2 11 (6+3+2) 2 (5+5-8) 7 (5+5-3) 7 10 (5+3+2) 1 (4+5-8) 5 (6+2-3) 5 7 (4+1+2) 0 (6+2-8) 4 (3+4-3) 4 12 (5+5+2) -4 (3+1-8) 1 (3+1-3) 1 10 (6+2+2) -2 (2+4-8) 3 (2+4-3) 3 8 (1+5+2) -3 (3+2-8) 4 (2+5-3) 4 8 (5+1+2) -4 (3+1-8) 1 (1+2-3) min 1 1
1740075297

Edited 1740151246
Joel
Pro
Tuo said: Oh right, I forgot the part about adding it to the damage - this would do it, then: @{Jerry|whispertoggle}&{template:combat@{Jerry|alt_rolltemplate_val }} {{character=@{Jerry|character_name} }} {{weapon=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_name-rep} }} @{Jerry|ro_default_rolltype} + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_DM-rep}[DM] + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_skill-rep}[Skill] @{ro_default_mod}]]}}  {{damage=[[{2D6-3,1D1}KH1+{$[[1]],0}kh1 [Effect]]] }} {{range=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_range-rep} }} {{effect=[[ [[2d6@{ro_default_mod}-8]] ]]}}: }} This should work, though the effect will have some square brackets around it. I just saw this... the table of rolls is from the first way you wrote it. I'll update that post so it's clear, and then I will try this new one.
1740077077

Edited 1740077950
Joel
Pro
Ok, we're getting closer. The first way you typed it up, in addition to the : vs = typo (completely understandable, not complaining), for some reason it just would not fire the template and instead I just got a lot of the code and inline rolls put into chat instead of it using the template. So rather than bother you with that, I took what had been working from my very first post and substituted your changes. That made the template work. As mentioned, the Effect (if positive) wasn't being added to the damage, but with your second take, the Effect does seem to get added to the damage. For some reason, the way you actually typed it out doesn't fire the template, it still returns just the code and some inline rolls in chat instead of using the template, but I again did my little substitution trick, copying my first post and only changing the things you changed. So now, using the code below, a mix-em-up of your code and mine, it does use the proper template, and it does add the Effect to the damage. The thing that is still not working is that it is still rolling a new 2d6-8 for the Effect, instead of using the main attack roll - 8. The last thing is just a formatting issue, but it's putting [[[ ]]] around the Effect (I now see that you actually mentioned that, sorry), and if the Effect is a negative number, it is displaying that negative number instead of the traditional 0. Honestly I can live with the formatting issues if they're the only hiccup, but thought I would mention it in case it helps clear up any issues or unnecessary brackets. If all the brackets are necessary, at least we might be able to get the math working correctly. So here is the code that is working with the exception that it is still rolling a new 2d6-8 for the Effect instead of using the existing attack roll - 8. @{Jerry|whispertoggle}&{template:combat@{Jerry|alt_rolltemplate_val}} {{character=@{Jerry|character_name}}} {{weapon=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_name-rep}}} @{Jerry|ro_default_rolltype} + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_DM-rep}[DM] + @{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_skill-rep}[Skill] @{Jerry|ro_default_mod}]]}}  {{damage=[[{2D6-3,1D1}KH1+{$[[1]],0}kh1[Effect]]]}} {{range=@{Jerry|repeating_weapons_-OJKuPdLUvaafCh66biC_weapon_range-rep}}} {{effect=[[ [[2d6@{ro_default_mod}-8]] ]]}}: }}
Oh, my bad, I didn't realize it was supposed to be the attack roll itself - how about this? @{whispertoggle}&{template:combat-alt} {{character=@{character_name} }} {{weapon=@{weapon_name-1} }} {{roll=$[[0.computed]]}} {{damage=[[4+0+$[[1]] ]] }} {{range=@{weapon_range-1} }} [[{{effect= [[ {[[2d6+@{weapon_DM-1}[DM] + @{weapon_skill-1}[Skill]@{ro_default_mod}]]-8,0}kh1 ]] }}]] change the "1" in weapon name, weapon range, weapon DM and weapon skill to whichever number fits the position of your attack on your attack list, I copied this from my test sheet where it works but I'm not absolutely sure if this is how the modifiers are supposed to apply. EDIT: the downside is that this way the boon/bane doesn't apply. I'll sit down and see if I can work around that. Looking at the sheet further, I guess that's not supposed to apply to attacks anyway? Anyway, edited the roll a little to show 0 for Effect if it's negative. EDIT2: Just paid attention to the auto-fire mode, that... is a lot more complicated. I won't say it's impossible to recreate with macro trickery, because I can think of a few things that *might* work to an extent, but it'd be far from simple.
1740089318
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Tuo said: @{whispertoggle}&{template:combat-alt} {{character=@{character_name} }} {{weapon=@{weapon_name-1} }} {{roll=$[[0.computed]]}} {{damage=[[4+0+$[[1]] ]] }} {{range=@{weapon_range-1} }} [[{{effect= [[ {[[2d6+@{weapon_DM-1}[DM] + @{weapon_skill-1}[Skill]@{ro_default_mod}]]-8,0}kh1 ]] }}]] You can't nest roll references unfortunately, so  [[4+0+$[[1]] ]]  will cause an error.
Scott C. said: Tuo said: @{whispertoggle}&{template:combat-alt} {{character=@{character_name} }} {{weapon=@{weapon_name-1} }} {{roll=$[[0.computed]]}} {{damage=[[4+0+$[[1]] ]] }} {{range=@{weapon_range-1} }} [[{{effect= [[ {[[2d6+@{weapon_DM-1}[DM] + @{weapon_skill-1}[Skill]@{ro_default_mod}]]-8,0}kh1 ]] }}]] You can't nest roll references unfortunately, so  [[4+0+$[[1]] ]]  will cause an error. It doesn't cause an error, because the original roll is delayed until after the roll where the reference is used. Please do try it before telling me my macro doesn't work, I made it completely character agnostic so all you have to do is create a test game, and a test character with an attack.
I will def try it tomorrow, thank you! Will let you know.
Thanks Tuo, that works as expected. I changed the bits you mentioned, and changed the damage to the more flexible @{weapon_damage} and everything seems to work exactly as expect. AND now the !ammo command works as well. It will be nice for simplicity's sake if the % bug/situation is fixed, but this does exactly what I wanted it to do, and I am grateful.