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

Hiding rolls from chat, even from GM, when rolling initiative

I have been working on an initiative script for my party's GM. The problem I am currently running into is at the very end of the script, when I am adding the NPCs to the tracker. Using sendChat(token,"/roll "+total+"&{tracker}"); sends the information to the tracker, but spams the GM's chat log up with a bunch of /roll commands. Is there any command or API tomfoolery I can use to add these tokens to the tracker without spamming up his chat window?
I solved the problem myself by manipulating the turn order directly. var token = findObjs({ _pageid: Campaign().get("playerpageid"), _type: "graphic", represents: user })[0] || 0; if(token != 0){ var turnorder; if(Campaign().get("turnorder") == ""){ turnorder = []; } else{ turnorder = JSON.parse(Campaign().get("turnorder")); } turnorder.push({ "id": token.id, "pr": total, "custom" : "" }); Campaign().set("turnorder",JSON.stringify(turnorder)); }
1430650324
Lithl
Pro
Sheet Author
API Scripter
For future reference, if you want to make use of Roll20's dice engine without filling up the chat log, you can pass a third argument to the sendChat function: sendChat('', '/roll 1d20+17', function(ops) { // ops[0] is basically the same thing as msg in a chat:message event }); If you supply the third argument, the message won't be sent to the chat, but you can process it in the callback function as though it had triggered a chat:message event.
1430660643
Gen Kitty
Forum Champion
Charles H., if you're looking for ideas, <a href="https://wiki.roll20.net/Script:Group_Initiative" rel="nofollow">https://wiki.roll20.net/Script:Group_Initiative</a> is a good script to peer at.
@Brian - I thought adding the callback would have intercepted it before it was added to the tracker.
1430665665
Lithl
Pro
Sheet Author
API Scripter
Charles H. said: @Brian - I thought adding the callback would have intercepted it before it was added to the tracker. I don't believe the &{tracker} syntax works from the API anyway, but then I haven't tried it myself.
1430669515
The Aaron
Pro
API Scripter
I don't think &{tracker} would work from the API as it relies on the currently selected token, which wouldn't exist for a sendChat() from the API.
Sorry it took me so long to follow up. You guys are correct. The tracker call doesn't work from the api. To give a little more insight to what I'm doing... I have a !register command that my players run at the start of a campaign with a token selected. It creates a 1:1 relationship in a permanent character, called "Data Store" that I use to permanent data storage in it's attributes. So, for example, my Data Store has an attribute called "PlayerCharactes", and in that attribute is an array of JSON objects with PlayerId, SpeakingAs, and CharacterId values. (SpeakingAs was included so active characters could be switched by changing the option in the dropdown below the chat window). This enabled me to simplify command inputs for some of my other gamers (and our GM) who aren't devs. Now, they can just type "!skill Tumble", and it knows which character to grab the tumble skill for, rolls it, and returns the result. In the case of the problem presented in this thread, they have !init command, which automatically rolls their initiative and adds it to the tracker. It accepts some arguments, but the main idea here was simplification. Since the script works now, they just type !init, it rolls their initiative, and if they have a token on the current player page, it adds that token to the tracker.