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

Pulling a list of weapons/attacks which a certain player has

Hello!

We are trying to make automated attacks for players using Macros + API methods.

Idea:

We want to make attack button for tokens which calls an attack for this token on selected target. Player can select token, press attack button, get list of his attacks, choose one of them and than choose a target. Get in chat results of attack roll, than get message with target's AC, than message with damage roll for this weapon.

Question:

How we can get a list of certain player/token attacks (weapons/skills which are in his character sheet, from where he basicly rolls his attacks) with their attributes using macros or API commands?

Using basic DnD 5e and Cyberpunk Red character sheets.

May 16 (1 year ago)
timmaugh
Forum Champion
API Scripter

Are you wanting to build your own script to do this?

Or are you looking to research it so you can then manually create buttons?

Or are you looking for a script that can present a dynamic menu of these items from the character sheet?

Prefered option is to make own script. Because i want to make it more complex later, but for start "a script that can present a dynamic menu of these items from the character sheet" is a good option for a reverse engeneering
May 16 (1 year ago)

Edited May 16 (1 year ago)
Gauss
Forum Champion

Hi Alergo, 

For the D&D 5e by Roll20 character sheet I suggest checking out Jarren's statblock. If it isn't what you want it could at least be the basis for an attacks macro or script. 
https://app.roll20.net/forum/post/11344849/d-and-d-5e-statblock-macro-mule-v3/?pageforid=11344849#post-11344849

May 16 (1 year ago)

Edited May 16 (1 year ago)
timmaugh
Forum Champion
API Scripter

Great! Welcome to the world of scripting!

I'm going to assume that you're at least comfortable in javascript. After that it's just a matter of conforming to the peculiarities of Roll20's sandbox.

This post has a bunch of information I think can help someone getting started on their scripting journey. I would direct you especially to the parts about the RMP template and the ways that the Inspector and ScriptInfo scripts can simplify your life.

Also spend some time with breaking down and parsing command lines. Think about that complexity you want to add, later, to make sure that the model you implement will scale up to everything you later want to do.

Now, as for getting items from the character sheet, you're most likely going to be getting attributes or abilities. You're going to want either/both of findObjs() and getObj() (you can find both of those in the function documentation linked from the above post). If you want to see a script that does this (gets a list of attributes or abilities and presents them as a menu of buttons), you can check out InsertArg

(It seems InsertArg has disappeared from the 1-click repo. You can find it in my personal repo.)

EDIT: I was mistaken. It's still in the 1-click.

The bits of code that deal with retrieving game objects begins on line 369 and goes through 451.

Post back with specific questions about what you are trying to do if you run into problems!

May 17 (1 year ago)

Edited May 17 (1 year ago)
David M.
Pro
API Scripter

For the 5e by Roll20 sheet, a lot of people use the Scriptcards-based 5e Action Menu. I don't, but I do use Scriptcards a lot. It's very powerful and customizable once you get familiar with the syntax.

Thank you! I'll go and research all of this! And yes, JS isn't a problem

May 17 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Other script option include:

Universal Chat Menus with specific 5e macros

Or Token Action Maker