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

[calling 2 scripts from 1 macro] 2nd script isn't called most of the time

Hello, is there a trick to call 2 scripts inside a macro (on the caracter sheet) ? My macro is like  !command1 param1 ... !command2 param1 ... For information I created a macro for my players resting which allow them to reset their spellused and their power point. Most of them have spell or power but the cleric have both (I manage the power to dismiss undead like a power) and something unexpected occurs when the macro is called : Occasionnaly both scripts are called (and works) but most of the time only the first one is executed... According to my log it's like the 2nd message isn't sent. Both script are ok and if I swicth the order of the command it's the new first which is called. Did I miss something ?
1599928781
Ziechael
Forum Champion
Sheet Author
API Scripter
It should work as expected, although there can be unexpected results depending on the actual macro used. To properly help we'd need to see your macro in full really.
I've experienced this same problem, rather consistently. To fix this, I wrote a script function that in turn calls the series of functions the macro did, and changed the macro to call that single function. Macros work fine when calling a single script function, but regularly fail when calling two or more. Calling four or more functions will always miss calling at least one, and it isn't always the last function called. So a macro that relies on function 3 to happen for function 4 to run successfully will be problematic.
1599931021
GiGs
Pro
Sheet Author
API Scripter
Actually you should be able to run multiple script commands without issue, as long as they dont depend on each other. Include the exact code you use so it's possible to spot what might be the issue. If this is on a character sheet, it's possible the rolltemplate is interfering, so give as much info about how you have this set up as you can.
1599933778

Edited 1599934328
My macro : !spellbook -resetSpellUsed 1 @{selected|token_id} !ki -reset @{selected|token_id} 0 do you need the code of each one ? In both I'm sending a default template in the chat message (independant of the other) but according the log it doesn't run untils this point
1599934385
GiGs
Pro
Sheet Author
API Scripter
I'm not familiar with either of those scripts. If you wrote them yourself, it would be best to follow Mike's suggestion of combining them in a single script. If they were written by different people, yes, you'll need to post the code so we can see what's going on.
1599939249

Edited 1599939686
Yes I wrote them myself with some help of community when I encounter some problems. The fist one generate the spellebook, spell track the used, parse spell handout to display the spell description and calculate the variable number, generate spell master handout and will provide sfx for spell. The second manage powerpoint and some specifi abilties I thought it was best to make one script by function but maybe I will merge them. Another possibility is to call the 2nd form the first one. But it seems sendChat doesn't interpret it neither
1599976716
GiGs
Pro
Sheet Author
API Scripter
Calling scripts within another script can be tricky if you are relying on selections, because its the script  that is calling the second script, not the player. The script is not a player, so it cant have any tokens selected.
Thanks for the tips, till then I'm essentially passing the tokenId by parameters so it's ok but I keep in mind no selection