Marstead said:
EDIT: Read through more of the wiki documentation specifically on ZeroFrame and I think I understand how to do this sort of testing (Using a leading ! and {@simple} tag). If you get time to share an example though it'd still be helpful for me to wrap my head around it!
Yep, you've got it. All the metascripts work by changing the command line or the message object (where the data is, for scripts) before that message reaches its destination. So while the metascripts *COULD* listen for and attempt to modify a message that was headed straight for the chat panel... the message actually reaches the chat panel BEFORE the metascripts have a chance to change it (the message would hit in original form... then the metascripts would act... annnnnnnnnd... no one would see the alterations).
To get around that, we have to at least START the message as a bangsy message (beginning with a ! ). Then, if we want to output to chat, we use ZeroFrame's {&simple} tag to "redirect" the output from a mod script destination to the chat window, instead.
Here are some specific examples
Marstead said:
#1. Check if an attribute is greater than 0. If it is, I'd like to take some steps like adding an additional bonus to a roll, removing token markers, setting attribute changes elsewhere, using !deal to take or remove cards, setting the Attribute = Attribute -1, etc. If it's 0, I'd like nothing to happen.
Simple check syntax:
!{&if @{selected|hp} > 0}The creature is still standing, with @{selected|hp} hits.{&elseif @{selected|hp} = 0}The creature has 0 hp.{&else}The creature is dead{&end} {&simple}
Here is an example of using that sort of syntax to drive another script (or not, conditionally). This was a solution I helped someone with who had PMed me with a question. They wanted to enact a ChatSetAttr command to modify the hp_temp attribute only if the hp_temp attribute was 0. If hp_temp was something other than 0, they wanted to output a message announcing that the character couldn't gain temporary hp:
!{& if @{selected|hp_temp} = 0}setattr --sel --hp_temp|[[@{selected|level}*5]] {& else}Can't Gain Temp {&simple} {& end}
Note that the {&simple} is in the command, but it doesn't always activate. You wouldn't want it to activate if you were running the ChatSetAttr line... since you wouldn't want to redirect the message AWAY from a mod script destination. You only want it to run if the conditional check fails... so you include it within the ELSE block of text, so it only survives (and activates) for that portion of the conditional text.
If you want to use Fetch, you can replace the attribute calls -- like @{selected|hp} or @{selected|hp_temp} -- with a Fetch construction: @(selected.hp) or @(selected|hp_temp)
But if you're going to use Fetch it's probably to get at the information in a way that Roll20 doesn't natively offer. For instance, if you wanted to use the macro to check the hp of the token currently up in the Turn Tracker, you could replace the "selected" with "tracker" in a Fetch construction:
!{&if @(tracker.hp) > 0}The creature is still standing, with @(tracker.hp) hits.{&elseif @(tracker.hp) = 0}The creature has 0 hp.{&else}The creature is dead{&end} {&simple}
That allows you to check the character of the token currently up in the tracker without having to select it.
But, if you're going to check the Tracker, you might be working with some tokens that are just tokens... so let's look at getting token-specific properties...
Marstead said:
#2. Check if a token has a specific marker. If it does, I'd like to do operations on the token and its sheet similar to the ones in #1 above.
Simple check:
!{&if @(selected.status.Bloodied.is) = yes}The token is bloodied.{&else}The token is not bloodied.{&end} {&simple}
Or, if the Bloodied status has numbers that mean something to you (for instance... blood loss per round), you can get the value like this:
!{&if @(selected.status.Bloodied.is) = yes && @(selected.status.Bloodied > 0}The token is bleeding at a rate of @(selected.status.Bloodied) hits per round.{&else}The token is not bleeding.{&end} {&simple}
You can see how, based on whether the creature was bleeding, you could take action with another script (like a ChatSetAttr line decrementing the hp of the creature). In that case, you'd want to move the {&simple} command the same way I demonstrated, above, so that it was paired with ONLY the chat-output ELSE case, and not the true side of the IF conditional... since that's where you'd put the ChatSetAttr line.
That's all I have time for at the moment, but hopefully it gives you a place to start. I'll try to work up the other 2 cases you mentioned in your OP later.