
Can't nest, but you can just add AND $Ammo.total >= 1 to the attack roll lines.
FGIsembard said:
Hello. I'm having trouble with Macros, I haven't tried anything complex but i am getting me this message in Chat:
!power {{ --name|PowerCard Test --!Test|This is a test. }}
FGIsembard said:
Hello. I'm having trouble with Macros, I haven't tried anything complex but i am getting me this message in Chat:
Hoping some one can suggest what I have done wrong. I have tested a few other people macros to check, but get the same message.
Thanks
!ammo @{selected|token_id} rangedammo1 -1 !power {{ --charid|@{character_id} --emote|@{selected|token_name} pulls back a @{rangedweaponname1} and fires at @{target|token_name}! --format|COMBAT --corners|10 --titlefont|Arial --titlefontsize|9 --subtitlefont|Arial --name|**Ranged Attack** --leftsub|**@{rangedweaponname1}** --rightsub|**Range 80/320** --Target:|$$#ff0000|**@{target|token_name}**$$ --Ammo:|[[ [$Ammo] @{rangedammo1} - 1 ]] out of [[ @{rangedammo1|max} ]] --Attack:|[[ [$Atk] @{AdvDisadv} + @{dexterity_mod} + @{prof_bonus} ]] vs AC --?? $Atk.total < @{target|npc_AC} AND $Atk.base <> 1 AND $Atk.base <> 20 AND $Ammo >= 1 ?? Miss:|The attack missed! --?? $Atk.base == 1 AND $Ammo >= 1 ?? Critical Miss:|The attack was fumbled! --?? $Atk.total >= @{target|npc_AC} AND $Atk.base <> 1 AND $Atk.base <> 20 AND $Ammo >= 1 ?? Hit:|You hit for [[ @{rangeddmg1} + @{dexterity_mod} ]] @{rangeddmgtype1} damage! --?? $Atk.base == 20 AND $Ammo >= 1 ?? Critical Hit:|You decimate the **@{target|token_name}** for [[ (@{rangeddmg1} + @{dexterity_mod}) * 2 ]] @{rangeddmgtype1} damage! --?? $Ammo.total <= 1 ?? Out of Ammo: You cannot attack with your @{rangedweaponname1}. }}
HoneyBadger said:
Actually you should already be able to use --whisper|self,gm. If not, that would be easy to fix.
!ammo @{selected|token_id} rangedammo1 -1 !power {{ --name|**Ranged Attack** -- ?? $Ammo < 0 ?? Out of Ammo:| You cannot attack [...]. -- ?? $Ammo >= 0 ?? 1 ammo used:|[[ [$Ammo|TXT] @{selected|rangedammo1} - 1 + 0d0 ]] of [[ [TXT] @{selected|rangedammo1|max} + 0d0 ]] now remaining. -- ?? $Ammo >= 0 ?? Attack:|[[ [$Atk] 1d20 ]] vs AC -- ?? $Ammo >= 0 AND $Atk.base == 1 ?? Critical Miss:|The attack was fumbled! -- ?? $Ammo >= 0 AND $Atk.base <> 1 AND $Atk.base <> 20 AND $Atk < @{target|npc_AC} ?? Miss:|The attack missed! -- ?? $Ammo >= 0 AND $Atk.base <> 1 AND $Atk.base <> 20 AND $Atk >= @{target|npc_AC} ?? Hit:|You hit [...]! -- ?? $Ammo >= 0 AND $Atk.base == 20 ?? Critical Hit:|You decimate [...]! }}I made quite a few alterations/redactions (most for functionality; some for flavor) and a few corrections (e.g. added missing | to Out of Ammo: tag; added 0d0 to inline roll that defines $Ammo) to the core of your macro, Craig. Please let me know if you have any questions.
_.each(PowerCard.whisper.split(","), function(y) { var resip = ('self' === y.trim() ? msg.who : y.trim()); sendChat(msg.who, "/w " + resip + " " + Display); });
Silvyre said:
HoneyBadger said:
Actually you should already be able to use --whisper|self,gm. If not, that would be easy to fix.
--whisper|self,foo,gm will output to foo and gm but not to self
--Ammo:|[[ [$Ammo] @{rangedammo1} - 1 + 0d0 ]] of [[ @{rangedammo1|max} + 0d0 ]] remaining. --?? $Ammo < 0 ?? Out of Ammo:|You cannot attack with your @{rangedweaponname1}. --?? $Ammo > 0 ?? Attack:|[[ [$Atk] @{AdvDisadv} + @{dexterity_mod} + @{prof_bonus} ]] vs AC --?? $Ammo > 0 AND $Atk.total < @{target|npc_AC} AND $Atk.base <> 1 AND $Atk.base <> 20 ?? Miss:|The attack missed! --?? $Ammo > 0 AND $Atk.base == 1 ?? Critical Miss:|The attack was fumbled! --?? $Ammo > 0 AND $Atk.total >= @{target|npc_AC} AND $Atk.base <> 1 AND $Atk.base <> 20 ?? Hit:|You hit for [[ @{rangeddmg1} + @{dexterity_mod} ]] @{rangeddmgtype1} damage! --?? $Ammo > 0 AND $Atk.base == 20 ?? Critical Hit:|You decimate the **@{target|token_name}** for [[ (@{rangeddmg1} + @{dexterity_mod}) * 2 ]] @{rangeddmgtype1} damage!
!power {{ --charid|@{selected|character_id} --emote|//@{selected|token_name} is attempting a Quick test...// --orowbg|#F5DEB3 --erowbg|#FFFFF0 --name|Quick Test --leftsub|Attribute (roll under) --hroll| Attribute [[ [$ATType] ?{Roll Type:|Quick, 0|Initiative, 1} +0d0 ]] --?? $ATType == 0 ?? !Roll0:|**Quick:** [[ [nh|$ATQCK] 1d20]] vs [[@{selected|Quick} + ?{Roll Modifier|0}]] --?? $ATType == 0 AND $ATQCK > @{selected|Quick} ?? ^Failure| --?? $ATType == 0 AND $ATQCK <= @{selected|Quick} ?? ^Success| --?? $ATType == 1 ?? !Roll1:|**Initiative:** [[ [nh|trkr] @{selected|Quick}d1]] ^^**Tiebreak:** [[1d20]] }}
!power {{ --charid|@{selected|character_id} --emote|//@{selected|token_name} is attempting a Quick test...// --orowbg|#F5DEB3 --erowbg|#FFFFF0 --name|Quick Test --leftsub|Attribute (roll under)
?{Roll Type| Quick, --!Roll0:|**Quick:** [[ [nh|$ATQCK] 1d20]] vs [[@{selected|Quick} + ?{Roll Modifier|0}]] -- ?? $ATQCK > @{selected|Quick} ?? ^Failure| -- ?? $ATQCK <= @{selected|Quick} ?? ^Success| | Initiative, --!Roll1:|**Initiative:** [[ [nh|trkr] @{selected|Quick}d1]] ^^**Tiebreak:** [[1d20]] }
}}
The Aaron said:
All rolls are evaluated on the client side. Powercards just adjusts which ones are displayed. I think there might be a work around you can use for initiative, but I don't remember it off the top of my head.
Silvyre said:
Here's a workaround that involves nesting tags within a Roll Query:!power {{ --charid|@{selected|character_id} --emote|//@{selected|token_name} is attempting a Quick test...// --orowbg|#F5DEB3 --erowbg|#FFFFF0 --name|Quick Test --leftsub|Attribute (roll under)
?{Roll Type| Quick, --!Roll0:|**Quick:** [[ [nh|$ATQCK] 1d20]] vs [[@{selected|Quick} + ?{Roll Modifier|0}]] -- ?? $ATQCK > @{selected|Quick} ?? ^Failure| -- ?? $ATQCK <= @{selected|Quick} ?? ^Success| | Initiative, --!Roll1:|**Initiative:** [[ [nh|trkr] @{selected|Quick}d1]] ^^**Tiebreak:** [[1d20]] }
}}
Silvyre said:
Just keep in mind that if you'd have to replace the commas in such a list with HTML entities.
HoneyBadger said:
Silvyre said:
Just keep in mind that if you'd have to replace the commas in such a list with HTML entities.
Not in this case I believe. It would be --whisper|?{Whisper to|} and he would type the names in.
HoneyBadger said:
Silvyre said:
Just keep in mind that if you'd have to replace the commas in such a list with HTML entities.
Not in this case I believe. It would be --whisper|?{Whisper to|} and he would type the names in.
TypeError: Cannot read property 'substring' of undefinedHere is the code:
!power {{ --charid|@{character_id} --emote|**@{selected|token_name}** is speaking in ?{What language are you speaking?} --name|Languages --whisper|?{Whisper to?} ?{Message..} }}Any ideas?
Silvyre said:
The only thing that should be placed within whisper tag is a list of names separated by commas. You'll need to place your message Roll Query within another tag.
!power {{ --charid|@{character_id} --emote|**@{selected|token_name}** is speaking in ?{What language are you speaking?} --name|Languages --whisper|?{Whisper to?} --!Message|?{Message..} }}
Silvyre said:
Arthur, would you mind troubleshooting your issue by incrementally removing tags from your macro until your error ceases to pinpoint its source?
HoneyBadger said:
Do this as a macro for me please: @{character_id} and copy/paste the id here. I want to see what part of the character id is throwing it off.
TypeError: Cannot read property 'substring' of undefined
%{B-R8|04-Arcane-Armor})I'd like to create one of these as well for 5e spells. Sorry, I'm a little "wet behind the ears" with how the API works and interacts. Thanks!
The fruits of your assistance... (EDIT: Added in castings per day that change as used (with !ammo script))!power {{ --orowbg|#F5DEB3 --erowbg|#FFFFF0 --name|**Spellbook** --leftsub|**Power: 1** --whisper|self --!Blank1|~~~ --!Rank0|~C**Rank 0 Spells**~C --!Blank2|~~~ --!Spells0|[[ @{B-R8|ArcaneArmor} + 0d0 ]] [**Arcane Armor**](! %{B-R8|04-Arcane-Armor}) ^^ [[ @{B-R8|MagicDart} + 0d0 ]] [**Magic Dart**](! %{B-R8|07-Magic-Dart}) ^^ [[ @{B-R8|MagicLock} + 0d0 ]] [**Magic Lock**](! %{B-R8|05-Magic-Lock}) ^^ [[ @{B-R8|SenseMagic} + 0d0 ]] [**Sense Magic**](! %{B-R8|03-Sense-Magic}) ^^ [[ @{B-R8|SecureSite} + 0d0 ]] [**Secure Site**](! %{B-R8|02-Secure-Site}) --!Blank3|~~~ --!Rank1|~C**Rank 1 Spells**~C --!Blank4|~~~ --!Spells1|[[ @{B-R8|Evade} + 0d0 ]] [**Evade**](! %{B-R8|06-Evade}) ^^ [[ @{B-R8|UnerringDarts} + 0d0 ]] [**Unerring Darts**](! %{B-R8|08-Unerring-Darts}) }}
Arthur B. said:
HoneyBadger said:
Do this as a macro for me please: @{character_id} and copy/paste the id here. I want to see what part of the character id is throwing it off.
This is what I got when I did that:TypeError: Cannot read property 'substring' of undefined
When I do the @{selected|character_id} everything works fine with all the character id's.Silvyre said:
Arthur B. said:
HoneyBadger said:
Do this as a macro for me please: @{character_id} and copy/paste the id here. I want to see what part of the character id is throwing it off.
This is what I got when I did that:TypeError: Cannot read property 'substring' of undefined
Could you copy, paste and enter @{selected|character_id} into the text chat after selecting the token that's linked to the Character that you're having difficulty with?
HoneyBadger said:
Wait... is this TypeError in chat with an orange background or in the api console?
Arthur B. said:
HoneyBadger said:
Wait... is this TypeError in chat with an orange background or in the api console?
In chat.
Craig L. said:
Do the buttons call off to another macro to fire off the spell? Which part of the formula is doing that?
Is it this part?%{B-R8|04-Arcane-Armor})
Craig L. said:
Hey Calhanol (or whomever else can answer),
I'd like to learn more about that awesome spellbook PowerCard you created. Do the buttons call off to another macro to fire off the spell? Which part of the formula is doing that?
Is it this part?%{B-R8|04-Arcane-Armor})I'd like to create one of these as well for 5e spells. Sorry, I'm a little "wet behind the ears" with how the API works and interacts. Thanks!The fruits of your assistance... (EDIT: Added in castings per day that change as used (with !ammo script))!power {{ --orowbg|#F5DEB3 --erowbg|#FFFFF0 --name|**Spellbook** --leftsub|**Power: 1** --whisper|self --!Blank1|~~~ --!Rank0|~C**Rank 0 Spells**~C --!Blank2|~~~ --!Spells0|[[ @{B-R8|ArcaneArmor} + 0d0 ]] [**Arcane Armor**](! %{B-R8|04-Arcane-Armor}) ^^ [[ @{B-R8|MagicDart} + 0d0 ]] [**Magic Dart**](! %{B-R8|07-Magic-Dart}) ^^ [[ @{B-R8|MagicLock} + 0d0 ]] [**Magic Lock**](! %{B-R8|05-Magic-Lock}) ^^ [[ @{B-R8|SenseMagic} + 0d0 ]] [**Sense Magic**](! %{B-R8|03-Sense-Magic}) ^^ [[ @{B-R8|SecureSite} + 0d0 ]] [**Secure Site**](! %{B-R8|02-Secure-Site}) --!Blank3|~~~ --!Rank1|~C**Rank 1 Spells**~C --!Blank4|~~~ --!Spells1|[[ @{B-R8|Evade} + 0d0 ]] [**Evade**](! %{B-R8|06-Evade}) ^^ [[ @{B-R8|UnerringDarts} + 0d0 ]] [**Unerring Darts**](! %{B-R8|08-Unerring-Darts}) }}
--!Blank1|~~~ --!Rank0|~C**Rank 0 Spells**~C --!Blank2|~~~ --!Spells0|[[ @{B-R8|ArcaneArmor} + 0d0 ]] [**Arcane Armor**](! %{B-R8|04-Arcane-Armor}) ^^ [[ @{B-R8|MagicDart} + 0d0 ]] [**Magic Dart**](! %{B-R8|07-Magic-Dart}) ^^ [[ @{B-R8|MagicLock} + 0d0 ]] [**Magic Lock**](! %{B-R8|05-Magic-Lock}) ^^ [[ @{B-R8|SenseMagic} + 0d0 ]] [**Sense Magic**](! %{B-R8|03-Sense-Magic}) ^^ [[ @{B-R8|SecureSite} + 0d0 ]] [**Secure Site**](! %{B-R8|02-Secure-Site})is what calls to the spells for the buttons in the PowerCard.
--!Blank1|~~~ --!Rank0|~C**Rank 0 Spells**~C --!Blank2|~~~ --!Spells0|[[ @{B-R8|ArcaneArmor} + 0d0 ]]^^^This part creates the frame for the buttons.
[**Arcane Armor**](! %{B-R8|04-Arcane-Armor})^^^The first part here [**Arcane Armor**] - shows what goes in the button the ** ** makes it bold. the second part calls to the macro of the character, this one calls 04-Arcane-Armor macro for the character B-R8. So altogether you have [bold**button name**](call to macro! and then you need to use HTML entities (carriage return)%(@ symbol{B-R8(chracter name)|04-Arcane-Armor-(Macro)}
Arthur B. said:
EDIT: You beat me to it Silvyre, but did I do a good job explaining it? I was so happy I could actually answer one of these, thanks to all the help I got from the rest of you!
...A bunch of stuff above this... --Ammo:|[[ [$Ammo] (@{selected|rangedammo1} - 1) + 0d0 ]] of [[ @{selected|rangedammo1|max} + 0d0 ]] remaining. --?? $Ammo <= 0 ?? Out of Ammo:|You cannot attack with your @{selected|rangedweaponname1}. --?? $Ammo > 0 ?? Attack:|[[ [$Atk] @{AdvDisadv} + @{selected|dexterity_mod} + @{selected|prof_bonus} + 0d0 ]] vs AC ....A bunch of stuff below this....If I were to run the macro and let's say the PC has 10 arrows before attacking. The macro is run, the ammo script will subtract the one arrow, the PowerCard displays, but if I didn't have the "-1" in there it would display "10" instead of "9". Plus, none of the later conditionals would be evaluating the right value. Additionally, when the attribute hits "0" then the display is showing "-1". Very annoying!