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 need to do way more with this.....

1386194799
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
sendChat("Riley", "/roll 1d20+4", function(ops) { // ops will be an ARRAY of command results. var rollresult = ops[0]; //Now do something with rollresult, just like you would during a chat:message event... });
1386204303
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Is there a ways to send the ops[0] in the chat as a normal roll result?
1386220498
Lithl
Pro
Sheet Author
API Scripter
Um... call sendChat?
1386244963

Edited 1386245076
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
!r 1d20 ~myFunction~ That is what I am thinking of.... something like that. Then a collection of small cool functions could be made.... so...that request like this... Matyas H. said: Can somebody make me an API? There is an attribute called 'Andrenaline'. The player rolls a 1d6 and then decide if she wants to use some of his 'andrenaline' points as a modifier. 6>= is a success. The basics are really easy, right? /roll 1d6+?{modifier|0} But I would like if after setting the modifier, it's choosen value would have been automatically substracted from the attribute. It's not possible as a macro... could be.... !roll 1d6+?{modifier|0} ~ substractA ttribute ~@{selected|andrenaline}~ No real coding needed on the part of Matyas H. ... or anyone with a similar request... we just have a long list of stand alone "roll functions" to choose from... and they just drop all of them into one stand alone API script. Plus players would now be able to maintain and use these in their macro's and abilities (as long as the host had API and the scripts in place.)
+1
Looking further into this myself. Can this send a popup question and use the input as a return result? IE: sendChat("Riley", "?{Pick 1,2, or 3}", function(ops) The pop up would take the input, then you can use it in function(ops) ?
1386599109
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
You could I would think... I actually use popups for validation of button clicks for some API command. !resetAPI?{Are you sure?|No} And then I only execute on "yes" returns.
1386599314

Edited 1386599350
Yeah, but that's at the onset of the API call. I'm more looking for throwing additional requests at the user in the middle of the API using sendChat. Trying to work up a better inventory system than using the Handouts and having to refer to them. Just hit an API command and it brings up lists, with 1 for Previous Page, 2 for Next Page, etc. I'd check myself but I'm at work and being on forums is bad enough. No coding on company time. :P
1386599977
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
So... what I want is hyperlink chats that are trigger API interaction.. For example... I enter in "!help" ("!h") I get this list in the chat. It would nice if "!help Player" could be a hyperlink that when clicked send the chat entry "!help Player".
I don't know if that's possible, which is why I'm going through long prompt menus. You could instead have a popup menu with. 1. !help 2. !help Player 3. !help Language 4. !help GM And then have them put 1,2,3, or 4 in and it goes to that. That way it also doesn't seriously clog into the chat log as well.
1386606599

Edited 1386609050
Lithl
Pro
Sheet Author
API Scripter
Stephen S. said: So... what I want is hyperlink chats that are trigger API interaction.. I was about to say "no, that isn't possible," but then I started thinking about it. Your API code is loaded into the page, so in theory you should be able to create anchor tags which would call your API functions. It would take some deep magic to make use of Roll20's query window, but simply calling an API function when you click a link oughtn't be terribly difficult. Just use the /direct command from a sendChat call and include the JS code in onclick (followed by return false so the link doesn't go anywhere). Edit: Well, the API functions aren't in the global scope, and I'm having difficulty finding them. They must be somewhere, though.