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 .
×

How I can call my own script in a macro?

Hello there, I'm trying to call a Script that I created in a powercard macro. I'm new with the roll20 API, so I'm not sure if there is some need of special "on" type that needs to be used in order to call the script event in macros. (With "on" type I mean: "chat:message", "add:character", "ready",...) This is how the script looks: on("chat:message", function(msg) {     if (msg.type !== "api") {         return;     }          if(msg.content == "!test_Script"){        sendChat("API", "TEST");     }          if(msg.content == "!reduceKi"){         var selected = msg.selected;         if(selected===undefined){                      sendChat("API", "Select character");             return;         }         var tok = getObj("graphic", selected[0]._id);         var character;         if (tok){             character = getObj("character", tok.get("represents"));         }         if(character) {           var attribute = findObjs({             type: "attribute",             characterid: character.get("_id"),             name: "class_resource"           }, {caseInsensitive: true})[0];           attribute.set("current",  attribute.get("current")-1);         }        } }); This is how the powercard macro looks: !power {{  --name | Flurry of Blows  --leftsub | 1 Ki point -- /*HERE IS WHERE I WANT TO USE THE SCRIPT TO REDUCE THE KI POINT*/  --Attack1: | [[ [$Atk1]  ?{Atk|Standar,1d20|Advantaje,2d20kh1|Disadvantaje,2d20kl1} + @{dexterity_mod} + @{pb} ]]  --?? $Atk1 >= @{target|ac} ?? Dmg 1: | [[ [$Dmg1] 1d4 + @{dexterity_mod} ]]  --Attack2: | [[ [$Atk2] ?{Atk|Standar,1d20|Advantaje,2d20kh1|Disadvantaje,2d20kl1} + @{dexterity_mod} + @{pb} ]]  --?? $Atk2 >= @{target|ac} ?? Dmg 2: | [[ [$Dmg2] 1d4 + @{dexterity_mod} ]]  --?? $Atk1 >= @{target|ac} ?? soundfx|_audio,play,nomenu|Puchs }} The Script above is the first one I have created, so I'm not sure what should I change in order to make it work. Thanks in advance.
1592707401
GiGs
Pro
Sheet Author
API Scripter
Since this is a Power Cards question, it's probably a good idea asking in the Power Cards thread. The people there will know how it works.