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

Using api scripts in a sheet

Likely a n00b question. I can assign scripts to a game... but how do I call them? All the tutorials I've found are how to make them accessible to the game... but not how to use them with, say, macro buttons or anything else... any pointers on how to do this?
Scripts either work automatically (such as Aura/Tint Health Colors, which affects tokens when a bar value is changed), or have to be called with a chat command that starts with an exclamation point (such as TokenMod, which will need a command that starts with !token-mod). If a script takes a command, then depending on how it's written, it may also take/require additional arguments, such as for TokenMod (!token-mod --set bar1|+1 ). If you post which scripts you are trying to use, then I'm sure you'll get some information about how to use them if you can't figure it out from their respective wiki, help files, or thread posts.
1678144565

Edited 1678144577
Not sure exactly how you want to implement it, but  you might take a look at ScriptCards.  The author has a master script that simplifies all the actions, bonus actions, reactions on a chat card.  Also, it now supports triggers which are kicked off when a character, token, turnorder or attribute changes.  There is a bit of a learning curve, but the user community is generally good about helping others.
1678149523
Andrew R.
Pro
Sheet Author
I mostly put them in the Abilities on the Attributes & Abilities tab of a Journal entry.  For example, all my 13th Age monsters have a Journal with an Ability for every Attack etc., in the stat block.  I have a Macro Mule for all the Conditions so there’s a row of buttons along the bottom of my screen: AFK, Dead, Dying, Staggered, etc., 
Do you call your script with a chat command? Like to execute your script, do you type into chat something like: !MelvinIsCool If so then you can make a macro that literally has nothing but that command in it. Then when you run the macro, it enters the command into chat (which nobody sees as the api grabs it insted) and the script runs. When you create the macro, there are check boxes that can make it A) a token action, in which case whenever that sheets token is selected, there will be a macro button in the top left OR B) the other check box that will make the macro appear at the bottom of your screen all the time. There are also places on your sheet, such as in the descriptions of spells and attacks, where you can create your own button to run the macro. This is my favorite thing to do. For example I can put a button in the description of my black tentacles spell that will run a macro. The macro runs the script. Then the script will create an FX, play a sound, and create a giant token for the tentacles, move it to the back, and link it to a sheet with information about the tentacles.  I will edit this post to add the button code when I am on a pc. I can't remember the syntax right now.
I just realized, I think you are adding scripts to your game from the library. If you tell us one or more of the scripts you are using someone can give you more pointed answers. GroupInitative is a really popular one. Are you using that one?
I am using Initiative Duplicator for a palladium game I'm in
Go to the "Collections" tab in your game. Its between the jukebox and settings. Select the "Show macro quick bar" check box. Click "+Add" Give your macro a name, Like "InitDuper" In the "Actions" box, enter the following:      !dup-turn ?{Enter the number of actions|2} Click "Save Changes" Next to the new macro listed, check the "In Bar" box On the game, select a token and add the initiative as normal. Make sure the token is still selected, then click the macro button on the bottom left of your screen. Adjust the number of actions as needed, and hit submit.
Thanks! That kind of example was what i was missing. Also turns out that some other scripts end up mucking that up. Interesting! More to explore!
1678204238

Edited 1678206225
Kraynic
Pro
Sheet Author
You can also use an attribute to supply the number of attacks as mentioned here:&nbsp; <a href="https://wiki.roll20.net/Palladium_Fantasy_1E#Initiative_Duplicator_Macro" rel="nofollow">https://wiki.roll20.net/Palladium_Fantasy_1E#Initiative_Duplicator_Macro</a> There is a similar note on the wiki page for all 3 of my sheets, I believe.&nbsp; I should probably add in the attribute for rate of fire for ranged weapons on the 1E page, now that I am looking back. Depending on which Palladium system you are running, the number of attacks may be all you need, since ranged weapons and casting all use the same actions in later versions of the system.&nbsp; Since I run the older fantasy system, I tend to put together a chat menu for characters that have multiple options between different rates of fire for ranged weapons, casting, and melee.&nbsp; I generally put those on the individual character sheets (Attributes &amp; Abilities tab). If you are using Grinning Gecko's Rifts sheet, then the same principles should apply.&nbsp; You will just need to right click on an input field and select the "Inspect" option to find out what the attribute name is.
Thanks, Kraynic. We're 2e players. And yes, I'm doing that as the base value for the query. Sometimes there's conditional additional attacks. Sadly, I found Gecko's Rifts sheets counter-intuitive, so we use the basic sheets. It's bee over 15 years since I've done javascript... ugh
1678222556
Kraynic
Pro
Sheet Author
I haven't tested this, but you might want to try: !dup-turn [[@{selected|hth_numberattacks}+?{Modifier?|0}]] I haven't tried using an inline roll with that script, but it should(?) work.&nbsp; Then you would automatically be pulling the normal number of attacks, and then could enter a modifier if necessary, but be able to simply hit enter to proceed if the default number is fine.
Kraynic said: I haven't tested this, but you might want to try: !dup-turn [[@{selected|hth_numberattacks}+?{Modifier?|0}]] I haven't tried using an inline roll with that script, but it should(?) work.&nbsp; Then you would automatically be pulling the normal number of attacks, and then could enter a modifier if necessary, but be able to simply hit enter to proceed if the default number is fine. I do that with this: &amp;{template:custom} {{color=black}} {{title=**@{selected|character_name}'s**}} {{subtitle=Initiative}} {{Initiative=@{m|initiative.roll}}} !dup-turn ?{Enter the number of actions|@{selected|numberattacks}}
1678244778
Kraynic
Pro
Sheet Author
Ok, maybe I misunderstood the additional additional attacks.&nbsp; What I posted would (in theory at least) pull in the regular number while allowing you to add more if needed.
We just do the same thing, except the default is numberofattacks. Our players can change the number