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

[Question] Non Coder Using Hidden Roll API Script and needs help

1396528501

Edited 1396528661
Hey everyone I am using the hidden roll script Here is the script: on("chat:message", function(msg) { if(msg.type == "api" && msg.content.indexOf("!hi") !== -1) { var numdice = msg.content.replace("!hi", ""); sendChat("Hidden Role", "/gr " + numdice + " Sent by: " + msg.who); } }); I have a macro set up to allow the my PC's to choose the target they are attacking I then have it set to send me the AC of the enemy they are attacking. Currently it only works if I put a dice roll into it, but I was wondering how I can get it to just send text Here is it working with the dice roll in: /em @{selected|token_name} attacks with @{selected|weapon1Name} [ATTACK ROLL = [[1d20+@{selected|dex|max}+@{selected|weapon1Name|max}]] vs @{target|Target1|token_name} !hi 1d1 vs AC: @{target|Target1|armorClass} I would like to to work like this: /em @{selected|token_name} attacks with @{selected|weapon1Name} [ATTACK ROLL = [[1d20+@{selected|dex|max}+@{selected|weapon1Name|max}]] vs @{target|Target1|token_name} !hi vs AC: @{target|Target1|armorClass} The above chat log is how I would like it to output, if I use this version the player can see the AC of the enemy. Any ideas would be GRAND! Thanks for reading, Casey P.S. An even cooler version would be if it would tell me HIT or MISS by comparing the roll vs the Target AC. I saw the comparison code, but currently it's over my coding pay-grade. ha ha.
Hi Casey, Your problem is with the roll mechanic. You are using their built in. Based on what you are asking, I would change your script: on("chat:message", function(msg) { if(msg.type == "api" && msg.content.indexOf("!hi") !== -1) { var numdice = msg.content.replace("!hi", ""); sendChat("Hidden Role", "/gw " + numdice + " Sent by: " + msg.who); }}); Also, I would remove the 1d1 from your macro.
Hey Josh, Thanks for the reply. I tried using that script and it shoots my back and error.
Try "/w gm " instead of "/gw ". Basically, the original script was sending the command to send a roll to the GM (a shorter version of /gmroll), but you want to send any text, so use the GM whisper. I think Josh just got the syntax wrong. Although, upon further thought, I'm not sure that you need this script at all. You could probably just use: /gm w vs AC: @{target|Target1|armorClass} and I think it would do approximately the same thing. (I don't have time to test it right now, sorry.)
Hey Rendelle, If you use /gm it allows the player to see the Stat as well. This seems to be working I just need to test it with a player around. Thanks both for the combined awesomeness! Casey
So after further research, my player can see the whisper so they can see the Armor Class which is no good. Any ideas?
I see a typo in my post, I accidentally flipped it around the second time I said it. So if you do: /w gm vs AC: @{target|Target1|armorClass} then that shows the AC to the player who whispered it? What about if you edit the script you have to just say "/w gm" instead of "/gr"? Because I would think that then the chat message is coming from the API and not the player, and therefore they would not see it. (I don't have a current game, with players in it, in order to test this myself...)