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

Link spell in chat without using spell slot

August 30 (4 years ago)

So I'm using the 5th Edition OGL Sheet and Companion API, and one of my players is wondering if there is a way to link spells in chat without necessarily having them be "cast." That way they don't have to keep changing the number of spell slots they have available, but still maintain the spell slot tracking functionality of the script and sheet.

I've been trying to think of a way other than just having them increase their slot remaining number each time they link a spell, but I can't think of one.

August 30 (4 years ago)
Wes
Sheet Author

Do they want to display them to everyone or just post them to chat so they can check the details?

If its the latter they can use the /talktomyself chat function to prevent the api from triggering. 

Help Center: Chat Commands

August 30 (4 years ago)

It's more so everyone can see it is my understanding

August 30 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

This would be a welcome technique. I've struggled with many methods, but never found a decent answer.

August 30 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

I've posted a reference to this thread in the official feedback thread. If there is a dev response, that's where you'll see it:
D&D 5th Edition by Roll20

August 30 (4 years ago)

Thanks for the responses. I’ll monitor the other feedback thread. 

August 30 (4 years ago)
timmaugh
Pro
API Scripter

Can someone break this down for me? What is linking... What happens on the sheet... And what do you need to have happen in chat? (Always been more of a RM rather than D&D player, so I'm trying to understand...)

August 31 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Here's a good description of the feature being asked for. Basically, the ability to send a spell's details to chat, for reference, without actually casting the spell. It only makes a difference in games with the D&D 5th Edition by Roll20 Script running, and with spell tracking turned on. Under those conditions, clicking on a spell will decrement the number of spell slots available, and send an out-of-slots warning if need be.

Also, some spells are set to output as attacks, and others as spellcards. There is a hybrid solution which outputs attack+description, but the format for this usage would need to always be Spellcard, which gives you a chat output similar to what would be seen in the printed book. Ideally, the output should be styled to make it clear that the spell is being displayed, but not cast—greyed text, perhaps.

Universal Chat Menus can almost do this. It would need the addition of a few reporting features which are on the wish list. It could certainly be done with the API, probably be means of constructing a chat menu of spells.

Ideally, this would be a feature of the sheet, as in the linked request. It would be in line with other sections of the sheet, and not require a chat menu.

August 31 (4 years ago)

Edited August 31 (4 years ago)
timmaugh
Pro
API Scripter

Is it just a matter of reading from a repeating attribute? Or is there also figuring/processing that happens prior to what you would want to send to the chat? Because, while I understand that the ideal solution would be for the existing sheet/script to handle this themselves, there are scripts that will let you read an attribute into chat, right? InsertArg will produce a menu of buttons that would let you read an attribute...

That's just the buttons (without nice menu formatting) as a proof of concept. The output of these "reading" buttons (the bottom part of the image) is defaulted to whisper, but a public reading is a quick enough feature to add if this would solve the need at hand?

August 31 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

That would probably fit the bill nicely. I haven't investigate InsertArg too carefully, because I feared I would fail a Sanity Check. :D I understand the general idea, but until actually doing something with it, I fear it would confuse me.

September 01 (4 years ago)
timmaugh
Pro
API Scripter

LOL!

I would love to help craft something to make it work. I'll make sure there is an open "read to chat" version of the buttons, and add an example of building that sort of output from a system that I know. Unfortunately, not knowing the D&D system or sheet, that will only get us in the neighborhood, so you'll have to help bring it home...


...so get that Helm of Sanity polished up, get it freshly blessed by Maligvignant of the Marbles... and then plant some nice daffodils in it, or something, because I promise you won't need it. =D

September 01 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

That would be helpful and appreciated. I'm sure its just a cognitive gap I have to cross to grok InsertArg, and I learn best by wanting something and making myself do it. Feel free to PM me, post here or in InsertArgs. Let me know what you need from me.

September 01 (4 years ago)

Something like this with UCM ought to do the trick:

--separator: | : --title:Spell Descriptions --repeating_spell-1|spellname|spelldescription!

Instead of using the call to link the spell, putting 'spelldescription' with the ! on the end creates a default template to show the value of that one field.

September 01 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

I've used that approach, but it's very limited. I proposed some additions to the code last year that would allow for a complete spell display, rather than just the description field, but they are still on the wish list.

September 01 (4 years ago)

Edited September 01 (4 years ago)
Oosh
Sheet Author
API Scripter

Would ChatSetAttr be able to mostly achieve this as a workaround? An example:

1. backup values of spell

@{bob|repeating_spell-cantrip_$0_spellname} --> copy value to @{bob|repeating_spell-cantrip_$0_spellname|max}
@{bob|repeating_spell-cantrip_$0_spelllevel} --> copy value to @{bob|repeating_spell-cantrip_$0_spelllevel|max}
@{bob|repeating_spell-cantrip_$0_spelloutput} --> copy value to @{bob|repeating_spell-cantrip_$0_spelloutput|max}


2. set required values:

@{bob|repeating_spell-cantrip_$0_spellname} --> add '(Description)' to the end of the Attribute string (I think SetAttr does this?)
@{bob|repeating_spell-cantrip_$0_spelllevel} --> unsure what it needs to change to, something that does not trigger Companion API to burn a slot
@{bob|repeating_spell-cantrip_$0_spelloutput} --> SPELLCARD


3. send to chat

%{bob|repeating_spell-cantrip_$0_spell}


4. restore player's values

@{bob|repeating_spell-cantrip_$0_spellname|max} --> copy value to @{bob|repeating_spell-cantrip_$0_spellname}
@{bob|repeating_spell-cantrip_$0_spelllevel|max} --> copy value to @{bob|repeating_spell-cantrip_$0_spelllevel}
@{bob|repeating_spell-cantrip_$0_spelloutput|max} --> copy value to @{bob|repeating_spell-cantrip_$0_spelloutput}


Obviously it can't put the button on the sheet though.

If you wanted to show off, you could add this to @{bob|repeating_spell-cantrip_$0_spelldescription}, then remove it after output:

[Description Only](#" style="font-size:20px;color:red;border:1px solid;text-align:center;display:block;border-radius:5px;margin:2px;padding:5px)

For this effect:




As a scummy Plus member, I use a target macro with Compendium links to look up my party members' spells... obviously this only works for Compendium spells with no name change. I'll cut it off at the first cantrip, it's a very long macro (combines with Stylus to suppress missing slots):

&{template:npcaction}{{name=@{target|t1|character_name}}} {{rname=Spells}} {{description=**Spell Save DC: @{target|t1|spell_save_dc}**
**Spellcasting Ability Mod: [[@{target|t1|spellcasting_ability}@{target|t1|pb}]]**
***Cantrips***
[@{target|t1|repeating_spell-cantrip_$0_spellname}](https://app.roll20.net/compendium/dnd5e/@{target|t1|repeating_spell-cantrip_$0_spellname})}}

September 01 (4 years ago)

Edited September 01 (4 years ago)
timmaugh
Pro
API Scripter

Before I jump in with examples, I created a video of me walking through the build/usage of InsertArg to solve this problem, so if you want to see how these calls were derived and tested and finally implemented, you can click this link. If you just want to parse the commands yourself, I've included the invocations, below.

Here is an example using the InsertArg script... (this is for Hero 6E, but just change the attribute names)... This call to the script:

!ia --menu --title#puttext{{!!a#getme{{!!r#n !!frmt#uc}} !!b#` - Read Menu`}} --row#getrow{{!!r#elem !!t#Powers !!c##ffffff !!s#getrepeating{{!!c#getme{{}} !!s#powers !!sfxn#power_name !!sfxa#power !!op#bRe !!f#-^f^#`(` !!rlbl#Read !!frmt#o+}}}}

...produces this menu of buttons for a filtered set of powers from the repeating section (for D&D, this would be spells), ordered alphabetically...


And though the menu is whispered to the speaker, these buttons produce a chat readout of the specified field (in this case "power", but for D&D, maybe spell description?):


If you didn't like the 1-row-per-item output and just wanted buttons, here is the same filtered/ordered set just returned as buttons:

!ia --menu --title#puttext{{!!a#getme{{!!r#n !!frmt#uc}} !!b#` - Read Menu`}} --row#getrow{{!!t#Powers !!c##ffffff !!s#getrepeating{{!!c#getme{{}} !!s#powers !!sfxn#power_name !!sfxa#power !!op#bR !!f#-^f^#`(` !!frmt#o+}}}}

...and the output:


And, finally, if you didn't want to keep a different menu of read-to-chat buttons vs a menu of "use" buttons, here is a menu option that puts both together (using the set of buttons for the read-to-chat and the line-item buttons for the "use"). Here is the call:

!ia --menu --title#getme{{!!r#n !!frmt#uc}} --^^row#getrow{{!!t#READ POWERS !!f#.7 !!s#getrow{{!!t#`` !!c##ffffff !!s#getrepeating{{!!c#getme{{}} !!s#powers !!sfxn#power_name !!sfxa#power !!op#bR !!f#-^f^#`(` !!frmt#o+}}}}}} --row#getrow{{!!t#USE POWERS !!f#.7 !!s#getrow{{!!r#elem !!c##ffffff !!s#getrepeating{{!!c#getme{{}} !!s#powers !!sfxn#power_name !!sfxa#power !!op#bRe !!f#-^f^#`(` !!rlbl#Read !!frmt#o+}}}}}}

...and the output:


Let me know if anyone needs this broken down more. I know IA is pretty new to the scriptosphere, and not the easiest to grasp out of the gate, but I am actively working on it, and willing to add/change to make it easier or more helpful to a problem you have if you help me understand what you need it to do.



September 01 (4 years ago)

Can the 5e script be configured not to cast spells automatically? You could instead use the ammo script for decreasing the spell slots. Either as token actions, or as buttons that you paste in the spell description. I do the latter in my games, so a spell can be sent to chat and there's a button in the description to cast it.

September 04 (4 years ago)
timmaugh
Pro
API Scripter

As I understand things, Persephone, there is a request in to change the 5e script to give this option. But I'll let Keith speak to that.

In the meantime, I wanted to post what I have in the hopper based on some information I got from Keith as far as what is needed (specifically, how what I had previously posted wasn't going to be enough information for a spell card). This is a new output option for InsertArg...

This is from Hero  6E, but the output of the card is configurable to the system, provided all of the information you need comes from one repeating section. In this case, I selected some sub-attribute data points for a Power.

You will be able to produce this either directly (for one or more entries in a repeating list), or you will be able to produce buttons (menu style) for the specified list of entries from a repeating list. I will explain more when it's ready to go live -- I have to implement a little error-handling before release.

For now, does this look like it will fit the bill? When it is ready, would those who play 5e (or other systems that need this sort of output) be willing to test this out?

September 04 (4 years ago)

Edited September 04 (4 years ago)
timmaugh
Pro
API Scripter

OK, version 1.4 of InsertArg now includes the ability to output "cards" as well as card-producing buttons (for a menu). To utilize it, set your output (op) argument to be one of these values:

c                        ==>    card, whispered
C                        ==>    card, chatted
bc / bC                  ==>    button for a whispered card (lowercase c) or chatted card (uppercase)
beC / bCe / bec / bce    ==>    as bc/bC, except using external labels for line-item output to a

You'll also need to specify a pipe-separated list of attribute-suffixes from the repeating section that you want to include in the card (the name is included automatically). The argument is "sfxlist", and it only needs the suffixes of the sub-attributes (you can use the xray helper script at the same link to get these). You can use a space in each element of the list of suffixes to designate labels for each suffix.

For instance, in a Hero 6E game, I might want to know the name of a power, the base points, advantages, active points, limitations, and real points of a power, as well as a description. My sfxlist would look like this (every element is a suffix followed by the replacement label):

!!sfxlist#pow_base_points Base Points|pow_advantages Advantages|pow_active_points Active Points|pow_limitations Limitations|pow_real_points Real Points|power Power Description

That, used in a getrepeating call, would produce a card like the one in my previous post in this thread. Here is the full call for that card:

!ia --whisper --show#getrepeating{{!!c#-M4jpPEy0ScLWE54K2gM !!s#powers !!sfxn#power_name !!l#Telekinetic Shield !!op#c !!sfxlist#pow_base_points Base Points|pow_advantages Advantages|pow_active_points Active Points|pow_limitations Limitations|pow_real_points Real Points|power Power Description}}

You can see that the mapArg (the first argument following the api handle) was set to 'whisper' to match my image. If I wanted to broadcast the card, I would set the mapArg to 'chat', instead. But that only matters for when your output (op) argument is set to cards ('c'). If you want to produce buttons, the mapArg would control whether your *buttons* are whispered or chatted (or involved in a menu), but the ultimate whispered/chatted volume of the *card* readout will be controlled by the output argument's 'c' character... meaning that you produce buttons that will send cards to whisper with 'bc', but you produce buttons that send cards to chat with 'bC'. For the purposes of the original poster, this means you would choose to chat the results of the card, since you want to share the information with other players, too.

An Example (with call breakdown)

Here is an example from that Hero6E character. I'll include the call, and then an image that shows the button output followed by one of the buttons clicked to show the card readout. After that, I'll breakdown the call so you can reproduce for your system. I'll include line breaks in the call for readability, but in game you would want to remove those.

!ia
--whisper
--show#getrepeating{{
    !!c#Heretic 
    !!s#powers 
    !!sfxn#power_name 
    !!op#bC 
    !!l#+|Telekinetic Shield+Restorative Field+Katana+The Oneness 
    !!sfxlist#pow_base_points Base Points|pow_advantages Advantages|pow_active_points Active Points|pow_limitations Limitations|pow_real_points Real Points|power Power Description 
    !!frmt#o+
}}

...produces this output...

Breaking down the call...

!ia
--whisper
--show#getrepeating{{

The first line is the api handle.

The second line is telling InsertArg to whisper the result of the call to me. Whisper (used like this) provides a command line of "show", so our third line is saying how we want to replace that word in our command line... with the results of a getrepeating function call. After this, we get our arguments to getrepeating...

    !!c#Heretic 
    !!s#powers 
    !!sfxn#power_name 

The first line is the character (c) we are going to produce this for. This could be a name or an id, or it could use the internal function "getme" to get the speaking character.

The second line is the repeating section (s) from which to pull the elements. This could be spells, powers, skills, whatever your sheet has. You can use the xray helper script to discover the name to use.

The third line is the naming suffix (sfxn). In other words, for all of the sub-attributes associated with a single entry in the repeating section, which one contains the identifying name? It only requires the suffix (again, determinable with xray).

    !!op#bC 
    !!l#+|Telekinetic Shield+Restorative Field+Katana+The Oneness 

Next (the argument order doesn't matter, this is just the order they appear in the example) comes the way we want to output (op) the results. By using 'bC' we are saying we want buttons (b) that output (themselves) chatted cards (C).

The next line is the list (l) of elements to use. If it isn't provided, all of the elements of the repeating section will be included (and can be filtered using the 'f' argument). I wanted four of my repeating powers, so I designated a delimiter (the plus before the pipe), then I followed the pipe with the names of the elements, separated with the delimiter. The list will try to identify each entry using a number of potential formations (including if the character name is included -- see the help for more information).

Now that we know what items to include from the repeating section, what do we want to see from them? What information do we need to see on our card? That comes next...

    !!sfxlist#pow_base_points Base Points|pow_advantages Advantages|pow_active_points Active Points|pow_limitations Limitations|pow_real_points Real Points|power Power Description 
    !!frmt#o+

The sfxlist argument is as I mentioned, above... each suffix from a sub-attribute, followed by a space and then the way I would like to relabel the information on the card. The list is separated with pipes. It will appear on the card in the order you provide the sub-attribute suffixes. Remember, too, that the naming element (already provided as the sfxn) is included automatically.

Finally, the last argument is a format (frmt) option to specify ascending order of the buttons.

Applying To Other Systems

Provided all of the information you need for a "card" comes from an entry in a single repeating section, this will work for you. Investigate the section with xray to find the suffixes you need, and replace the components of the call as necessary. You can enter your own static list of elements to include, or skip the list and use the filter (f) argument to arrive at a dynamic rendering of your entries at the time you run the call.

Including In a Menu

The getrepeating{{...}} function call is a discrete element that can be provided to hooks or an argument from another function in the InsertArg api. That means that you could use it in a menu call, and feed it to the source (s) argument of a row (remember to remove new lines from the following)...

!ia
--menu
--title#Card Menu
--row#getrow{{!!t#Powers !!s#getrepeating{{...}}}}

...which can, of course, be tweaked and made more pretty, but that is covered in other posts discussing using InsertArg.

September 09 (4 years ago)
timmaugh
Pro
API Scripter

Keith really cracked this open in this post in the InsertArg thread, applying the above process (along with some tweaks he requested) to the D&D spell world... his help in game-testing the final product was priceless to getting this dialed in.

Take a look at that post (and the linked macro text in a Gist) if you want to see a way to handle this dynamically, in game.