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

[help] Why does sendChat() not interact with roll queries as expected?

1640795761

Edited 1640795875
Josh
Pro
In order general-to-specific, with the question at the bottom: I am familiar with coding, but not development: I am very comfortable banging out some Matlab or C++ or VB to process some data or simulate something, but have much less experience working inside a larger environment. My knowledge of JS is fairly superficial, but I didn't have much trouble figuring out basic Roll20 I/O. I am trying to build an automated Traveller character generator (LBB method) in the API. I recognize that there are more standard ways to make a character builder, but for various reasons I think this will be a better option overall. Essentially, it's a pure console-based flowchart follower, but the console piece has to run through the Roll20 chat. I would prefer to work with modal dialogs instead of with chat menus. That's primarily an aesthetic choice, and I can give it up if necessary.  To do that, I'm trying to use roll queries as the modal dialog.  I expect that I can do (test code to understand the behavior):     sendChat(TravMakerNS.msgWho, "?{Choose a Roll|STR,5 |DEX,4 |CON,3}",          function(obj){             log('hello');             log(obj[0].content);             return 0;         }     ); This logs "hello" and content, but does not show any message or dialog. I expected it to show a dialog, and have a way to extract the selected choice from the callback. Removing the callback entirely shows  ?{Choose a Roll|STR,5 |DEX,4 |CON,3}  in chat, and does not display a dialog. I expected it to show a dialog and put the corresponding number in the chat. Posting  ?{Choose a Roll|STR,5 |DEX,4 |CON,3}  in chat manually behaves as expected: a dialog pops up, and it returns a number corresponding to the selection.  What's going on, and how do I fix it? I have read the wiki without finding an answer, and I don't know of any other documentation source.
1640798599
Kurt J.
Pro
API Scripter
Josh said: In order general-to-specific, with the question at the bottom: I am familiar with coding, but not development: I am very comfortable banging out some Matlab or C++ or VB to process some data or simulate something, but have much less experience working inside a larger environment. My knowledge of JS is fairly superficial, but I didn't have much trouble figuring out basic Roll20 I/O. I am trying to build an automated Traveller character generator (LBB method) in the API. I recognize that there are more standard ways to make a character builder, but for various reasons I think this will be a better option overall. Essentially, it's a pure console-based flowchart follower, but the console piece has to run through the Roll20 chat. I would prefer to work with modal dialogs instead of with chat menus. That's primarily an aesthetic choice, and I can give it up if necessary.  To do that, I'm trying to use roll queries as the modal dialog.  I expect that I can do (test code to understand the behavior):     sendChat(TravMakerNS.msgWho, "?{Choose a Roll|STR,5 |DEX,4 |CON,3}",          function(obj){             log('hello');             log(obj[0].content);             return 0;         }     ); This logs "hello" and content, but does not show any message or dialog. I expected it to show a dialog, and have a way to extract the selected choice from the callback. Removing the callback entirely shows  ?{Choose a Roll|STR,5 |DEX,4 |CON,3}  in chat, and does not display a dialog. I expected it to show a dialog and put the corresponding number in the chat. Posting  ?{Choose a Roll|STR,5 |DEX,4 |CON,3}  in chat manually behaves as expected: a dialog pops up, and it returns a number corresponding to the selection.  What's going on, and how do I fix it? I have read the wiki without finding an answer, and I don't know of any other documentation source. The API doesn't have any interaction with the game UI. Further, even if it could, lets say you have 5 players and a GM. There is no way for the API to know who should be prompted to answer the question. The API doesn't run "as" anyone in particular, and even the SpeakingAs parameter only impacts what name is displayed at the top of the chat. With ScriptCards, I create buttons that get sent to chat (or whispered to a player) that have the roll query embedded in it, so when the player clicks the button the UI thinks they are typing the macro out and prompts the person who clicked. Without that click from the player, there is unfortunately no way to have the prompt show up.
Kurt J. said:  The API doesn't run "as" anyone in particular,  Dang. That makes perfect sense, unfortunately.  Thanks.
1640968452
The Aaron
Roll20 Production Team
API Scripter
You can think of the API as a remote user with no user interface. They get notices of things happening and they issue some response as a result, but can't do a thing else.