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

ChatSetAttr + Hunter's Mark question

March 03 (1 month ago)

Edited March 03 (1 month ago)

Hey folks! 

So I'm trying to combine ChatSetAttr with the Hunter's Mark script using the 2014 R20 5e sheet in a jumpgate game. My goal is to give my player the ability to add her mark to a target token to indicate who has hunter's mark (the HM script does this very reliably) and then to also turn on the additional damage the spell does by using ChatSetAttr to turn on the top slot in the global damage modifier list. 

I've used ChatSetAttr to do the second part of that before, so I think it should work?

Here's the script I'm using in a macro:

!setattr --sel  --silent  --repeating_damagemod_$0_global_damage_active_flag|1
!hunters-mark @{selected|character_id} @{target|token_id}


Each of them individually do what they're supposed to, but when I put them together as above in a single macro, the HM script works, but the ChatSetAttr doesn't, and I get the error message below. 

Any suggestions on how to get this to work? if possible? 

thanks!



March 04 (4 weeks ago)
timmaugh
Pro
API Scripter

Hmm.

Is that the sum total of your macro verbiage?

!setattr --sel  --silent  --repeating_damagemod_$0_global_damage_active_flag|1
!hunters-mark @{selected|character_id} @{target|token_id}

I am having trouble replicating this in my game, but it might* be because I have SelectManager installed and configured.

* "might be" because the message, as you have reported it, doesn't seem to be something that would trip the necessity of SelectManager's protections.

The short explanation of why SelectManager can help is that SM bridges certain gaps when messages would normally drop selected tokens. When a message would normally show up to a script for processing but NOT have selected tokens, you could get an error like this. SelectManager works behind the scenes and within the message processing to make sure things don't get to this point.

That's... a pretty drastic simplification, but let's just see if SM helps, in this case, before I go into more detail.

To see if SM can help, install the MetascriptToolbox. A bunch of scripts will get installed. Don't worry. They all do good things.

Once your sandbox is back up, run this command one time from your chat:

!smconfig +playerid +who

SelectManager should report that it has made configuration changes. (You should not have to run this command again.)

Now try your ChatSetAttr + Hunter's Mark macro again and let us know if you have better luck.

March 04 (4 weeks ago)

Edited March 04 (4 weeks ago)

I tried adding selectmanager, and it didn't seem to help, but let me try fiddling with it some more. One of the behaviors I noticed with SM was that the tag from HM would disappear after a few moments?

And yes, that is the whole of the verbiage in the macro -- I've tried switching the order of the commands, but it doesn't seem to make a difference. Oh, and the player's token is selected at time of hitting the macro.

I'll mess with SM a bit more and report back. 


Thanks for your help!

March 04 (4 weeks ago)
timmaugh
Pro
API Scripter

Hmm... SelectManager doesn't take any action on status markers on a token. It can read them (passively) if you wanted to use them as a criteria statement for a {&select} tag, but it doesn't set them anywhere.

That has to be something else going on...

March 04 (4 weeks ago)
is there a way to just get each of the two commands to fire separately in the same macro? they each work independently?
March 04 (4 weeks ago)

Hi, resident script-ignorant macro writer here - if the problem is in ChatSetAttr not maintaining select, would it not reasonable that resolving select into a name or character id earlier in the order of operations would work? So replacing --sel with --@{selected|character_id}, for instance? I mean, you're already doing it with HM as is.

March 04 (4 weeks ago)

Ah, good idea, Tuo, but it didn't seem to change anything. 

the hunter's mark fires as expected, but the chattsetattr command just fires an error, and the damage mod isn't toggled on.

I'm super clueless about how all this works, so I really appreciate the help! thanks, folks!

here's the verbiage currently

!setattr --@{selected|character_id}  --silent  --repeating_damagemod_$0_global_damage_active_flag|1
!hunters-mark @{selected|character_id} @{target|token_id}


the hunter's mark part works as expected, but the settattr command just throws an error.


I've also tried 


!setattr --sel  --silent  --repeating_damagemod_$0_global_damage_active_flag|1
!hunters-mark @{selected|character_id} @{target|token_id}


which behaves the same as the previous one.

March 05 (4 weeks ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Does reversing the order change anything? --sel is an abstraction, as opposed to @{selected|character_id}, which is directly resolved. Worth trying, anyway.

March 05 (4 weeks ago)
timmaugh
Pro
API Scripter

Try this formation:

!{{
  !setattr --sel  --silent  --repeating_damagemod_$0_global_damage_active_flag|1
  !hunters-mark @{selected|character_id} @{target|token_id}
}}

That will batch them up to be a single message, which ZeroFrame will then parse out to dispatch each individually.


March 05 (4 weeks ago)

reversing the order doesn't do anything.


the addition of the brackets just made it not recognize the hunter from the hunters-mark api.

March 05 (4 weeks ago)

and thanks for the suggestions!

March 05 (3 weeks ago)

Edited March 05 (3 weeks ago)
timmaugh
Pro
API Scripter


Ken R. said:

the addition of the brackets just made it not recognize the hunter from the hunters-mark api.

First, just to be clear, you do have the entire Metascript Toolbox installed and not JUST SelectManager, correct? The double-brace formation comes from ZeroFrame (another of the metascripts in the Toolbox).

Second, if you do have the Toolbox installed, I did make an error in my suggested command line. In my haste I overlooked the fact that by combining command lines (into a single ZeroFrame batch enclosed by the double braces), then the entire message would be affected by the "you can't have targeted tokens and selected tokens in the same message" problem that has been the longstanding way Roll20 handles targeting.

Two formation options will get you around this; just take your pick.

Option 1

With the MetascriptToolbox installed, you can use a SelectManager {&select} tag to add the selected token back to the message after Roll20 would have dropped it:

!{{
  !setattr --sel --silent --repeating_damagemod_$0_global_damage_active_flag|1
  !hunters-mark @{selected|character_id} @{target|token_id}
}} {&select @{selected|token_id} }


Option 2

You can go back to the ChatSetAttr call that explicitly uses the character ID of the selected token (rather than the --sel argument):

!{{
  !setattr --@{selected|character_id}  --silent  --repeating_damagemod_$0_global_damage_active_flag|1
  !hunters-mark @{selected|character_id} @{target|token_id}
}}

That way, ChatSetAttr isn't looking for a selected token that will no longer be there.