If I want to use a function I create using the Javascript API, how do I then access that function from a macro? How do I pass a value to it from within the macro, and then return that function's result into the macro?
!tt paramNo text is displayed automatically as a result of commands that begin with !
on('chat:message',function(msg){ 'use strict'; if('api' !== msg.type) { return; } var args = msg.content.split(/\s+/); if('!tt' === args.shift() ) { sendChat('my API', 'received parameters: '+args.join(', ') ); } });
var handleInput = function (msg) {
var message = _.clone(msg);
if ( 'api' !== message.type || '!aoedrawer' !== message.content.split(/\s+/)[0] ) {
return;
}
switch(message.content.split(/\s+/)[1]) {
case 'menu':
//do stuff
break;
case 'toggleMenu':
//do stuff
break;
case 'toggleOnDefault':
//do stuff
break;
case 'state':
SotSA.CheckState();
break;
default:
//do stuff
break;
}
},
What you're talking about is not possible. As Aaron said, the macro is executed, passing information to the API, which then processes the input and potentially generates output.Tenacious Techhunter said:
Well yes, but you're only calling the one thing that way. I'm talking about passing a variable to the API and returning a result back to the macro so the macro can continue to parse. Would that work in the dead middle, or at the very end, of a dice roll macro?
Tenacious Techhunter said:
Nice thought, but no. I have a YX problem. People keep thinking I want to do X, but I want to do Y. Because they have no experience with why doing Y would be a good idea, they cannot fathom why I would be asking how to do Y, so they tell me how to do X, in spite of the fact that I'm asking, "How do I do Y, if it is at all possible, which it might not be?". At which point, it is far more helpful for people to simply say, "No, sorry, Roll20 fails to support doing Y just now.", than to tell me how to do X, or Z, or whatever.
Why I want to do Y: There didn't used to be a "floor" function; now there is. That's what I want to do; add functions to my diceroller (and maybe even override some that the Roll20 devs screwed the pooch on). Why? Because everyone has access to the diceroller. Not everyone has access to the APIs; it's way better to give your players the system support they need to come up with their own solutions than it is to can all the ones you can manage yourself exclusively through the API, or from some well-intentioned character sheet effort, that may not be enough for a specific use case. So unless you've got a way to use the API to add to the list of functions available to the macro engine, it's just not what I was asking for, which I went to considerable effort to clearly specify from the very beginning.
Thank you for your effort, though.
We'll have to agree to disagree on that; I don't think many could have done a more explicit job of stating what I was asking for.Ken L. said:
As a side note to the little side arguement: it's still helpful to express what you're gunning at tech. For myself it still wasn't clear in the OP what you wanted or the behavior you wanted to see was possible, especially compared to other API questions.
Tenacious Techhunter said:
We'll have to agree to disagree on that; I don't think many could have done a more explicit job of stating what I was asking for.Ken L. said:
As a side note to the little side arguement: it's still helpful to express what you're gunning at tech. For myself it still wasn't clear in the OP what you wanted or the behavior you wanted to see was possible, especially compared to other API questions.
The Aaron said:
Note that nothing is ever actually returned to the macro.