This post has been closed. You can still view previous posts, but you can't post any new replies.

[Script] PowerCards 3 (Thread 3)

1455557877

Edited 1455563550
Phoxounet
Pro
Sheet Author
Translator
Hi there ! I submit a little problem I have to complete my powercards. Here is the code : !power {{ --charid|@{character_id} --emote|**@{character_name}** attacks with is **@{Weap1}** ! --name|Close Combat --leftsub|Attack --rightsub| **@{Weap1}** --Attack :|[[ [$Atk] 1D(?{risk|no,10|yes,20}) + @{Cap_Off1} ]] --?? $Atk.base == 1 OR $Atk.base == 11 ?? Critical Failure:| it's a Critical Failure --?? $Atk.base <> 1 AND $Atk.base <> 11 ?? Damage :| Damages are : [[@{Dam1}]] }} As you can see, there is a choice about using a risky dice or not. 1 is always a critical failure. Choosing a D10 die makes all values available as success except 1. Using a D20 die makes all even values as successes, 1 and 11 are critical failures and all other odd values are automatic failures. I could easily use conditionnals so that all odd values are failures (except 1 and 11 that are critical failures) but 3, 5, 7 and 9 would be considered as failures when choosing a D10 die whereas there should not.. I'm not sure if I can make a functioning macro using Powercards. Any help welcomed ! Regards. :)
1455562555

Edited 1455563157
Silvyre
Roll20 Mod Team
Hey, Phoxounet . Although this shouldn't really affect the performance of the PowerCard, I notice your 4th line is a bit messed up (a line break went bad?) There's also a stray } at the end of your inline roll within your Attack tag. You can add a "Failure" tag for using risk: add "AND ?{risk} == 20" "use conditionnals so that all odd values are failures (except 1 and 11 that are critical failures) but 3, 5, 7 and 9 would be considered as failures" Does that make sense? --?? $Atk.base <> 1 AND $Atk.base <> 11 AND ?{risk} == 10 ?? Damage :| Damages are : [[@{Dam1}]] --?? $Atk.base == 2 OR $Atk.base == 4 OR $Atk.base == 6 OR $Atk.base == 8 OR $Atk.base == 10 OR $Atk.base == 12 OR $Atk.base == 14 OR $Atk.base == 16 OR $Atk.base == 18 OR $Atk.base == 20 AND ?{risk} == 20 ?? Damage :| Damages are : [[@{Dam1}]] --?? $Atk.base == 3 OR $Atk.base == 5 OR $Atk.base == 7 OR Atk.base == 9 OR $Atk.base == 13 OR $Atk.base == 15 OR $Atk.base == 17 OR $Atk.base == 19 AND ?{risk} == 20 ?? Failure:| it's a Failure --?? $Atk.base == 1 OR $Atk.base == 11 ?? Critical Failure:| it's a Critical Failure
1455564131
Phoxounet
Pro
Sheet Author
Translator
Well not. Here is the whole thing. You can choose a normal roll (1D10) and 1 is a critical failure and all other values are ok. You can choose a 1D20 (as a risky die). 1 and 11 are critical failures. All odd values are considered 0. All even values keep their values. With your macro, all D10 rolls have odd values displayed as failures >< 
1455564848
Silvyre
Roll20 Mod Team
Oops, I should have put the ?{risk} = X in front! Try this: !power {{ --charid|@{character_id} --emote|**@{character_name}** attacks with is **@{Weap1}** ! --name|Close Combat --leftsub|Attack --rightsub| **@{Weap1}** --Attack :|[[ [$Atk] 1D(?{risk|no,10|yes,20}) + @{Cap_Off1} ]] --?? ?{risk} == 10 AND $Atk.base <> 1 AND $Atk.base <> 11 ?? Damage :| Damages are : [[@{Dam1}]] --?? ?{risk} == 20 AND $Atk.base == 2 OR $Atk.base == 4 OR $Atk.base == 6 OR $Atk.base == 8 OR $Atk.base == 10 OR $Atk.base == 12 OR $Atk.base == 14 OR $Atk.base == 16 OR $Atk.base == 18 OR $Atk.base == 20 ?? Damage (Risk) :| Damages are : [[@{Dam1}]] --?? ?{risk} == 20 AND $Atk.base == 3 OR $Atk.base == 5 OR $Atk.base == 7 OR Atk.base == 9 OR $Atk.base == 13 OR $Atk.base == 15 OR $Atk.base == 17 OR $Atk.base == 19 ?? Failure:| it's a Failure --?? $Atk.base == 1 OR $Atk.base == 11 ?? Critical Failure:| it's a Critical Failure }}
1455573239

Edited 1455573956
Phoxounet
Pro
Sheet Author
Translator
I see the logic of your proposition. Smart one. However, it is not working.. I guess that not having a  $risk in the attack string is a problem. edit : damn bold characters Edit bis : my bad. i made a mistake. It is perfectly working !!!! Thank you so much !!!! :D
1455574176

Edited 1455574619
Sky
Pro
Silvyre, there is the modulo function that's available. Would make it easier to check for an odd value. --?? ?{risk} == 20 AND $Atk.base ~% 2 ?? Roll|Is Odd
1455575034

Edited 1455575251
Phoxounet
Pro
Sheet Author
Translator
I used it to modify the macro and is almost functioning. However, I don't see which order conditionals should have so that it correctly stops. If the critical failure is the first conditional, ( $Atk.base == 1 or $Atk == 11) it should stop at this line and not display damages, Right ? !power {{ --charid|@{character_id} --emote|**@{character_name}** attacks with his **@{weap2}** ! --name|Close Combat --leftsub|Attack --rightsub| **@{Weap2}** --Attack :|[[ [$Atk] 1D(?{risk|no,10|yes,20}) + @{Cap_Off2} }]] --?? $Atk.base == 1 OR $Atk.base == 11 ?? Critical Failure:| It's a Critical Failure --?? ?{risk} == 10 AND $Atk <> 1 ?? Damages :| Damages are [[@{Dam2}]] --?? ?{risk} == 20 AND $Atk.base % 2 ?? Damages :| Damages are [[@{Dam2}]] --?? ?{risk} == 20 AND $Atk.base ~% 2 ?? Failure :| The Risky Attack is Failure }}
1455576719
Sky
Pro
No, it will go through all conditionals, top to bottom. If you don't want damage to show, you need to add $Atk.base <> 1 AND $Atk.base <> 11.
1455577705
Phoxounet
Pro
Sheet Author
Translator
Well I made a mistake again. I forgot a .base at the second conditional. It messed up all conditions. Now, the critical failure is the last tested conditional and everything is perfectly working. Thank you so much, guys !! :D
1455595611
Silvyre
Roll20 Mod Team
HoneyBadger said: Silvyre, there is the modulo function that's available. Would make it easier to check for an odd value. When I was typing all that out, I knew there was an easier way to do it... but it eluded me! Need to use modulo more often! Glad you got it working, Phoxounet !
1455616045

Edited 1455617776
Phoxounet
Pro
Sheet Author
Translator
Hi guys. Back again... !power{{ --charid|@{character_id} --emote|**@{character_name}** attacks with his **@{weap2}** ! --name|Close Combat --leftsub|Attack--rightsub|**@{Weap2}** --Attack:|[[ [$Atk] 1D(?{risk|no,10|yes,20}) + @{Cap_Off2} }]] --?? ?{risk} == 10 AND $Atk.base <> 1 ?? Damages :| Damages are [[@{Dam2}]] --?? ?{risk} == 20 AND $Atk.base % 2 ?? Damages :| Damages are [[@{Dam2}]] --?? ?{risk} == 20 AND $Atk.base ~% 2 AND $Atk.base <> 1 AND $Atk.base <> 11 ?? Failure :| The Risky Attack is Failure --?? $Atk.base == 1 OR $Atk.base == 11 ?? Critical Failure:| It's a Critical Failure }} First of all, the 3rd conditional isn't working as intended. For example, if $Atk=13, I only get the Attack line but not the content of the conditional line. (and nothing else). Every other conditionals work as intended and I don't see why it doesn't display the result of the conditional. Secondary, if i had a roll instead of attack like : --Roll :|[[ [$Roll] 1D(?{risk|no,10|yes,20})]] Is it possible to use the $Roll as a variable to calculate the attack value in the showed result of a conditional (like $Roll + Cap_Off2), using the correct syntax ? Edit : Well. I didn't find my error and wrote again the macro... it is now correctly working... I'm so unlucky these days ><
1455620018
Sky
Pro
The problem is that you have the same name for different tags. You can't re-use Damages: over and over. So in cases like this, I hide the real tag and add a fake tag as part of the content like this: --?? ?{risk} == 10 AND $Atk.base <> 1 ?? !Dmg1|**Damages:** Damages are [[@{Dam2}]] --?? ?{risk} == 20 AND $Atk.base % 2 ?? !Dmg2|**Damages:** Damages are [[@{Dam2}]]
1455620357
Sky
Pro
And no, it is not possible to use values stored as a roll ID in math. It's a complex task and undertaking that will take a major re-write of the script.
Not really a problem with a macro but stuck on how to write one. Wrote the following to handle low level weapon attacks but as we've leveled up im in need for a more versitle command one that lets me use conditional attacks, say im in point blank range, I use Rapid fire or I generally have more then one attack. !power {{ --tokenid|@{selected|token_id} --emote|//?{Description}// --name|Weapon Attack --leftsub|♦ @{selected|repeating_weapon_$0_name} (@{selected|repeating_weapon_$0_range}ft) --rightsub|^^♦ @{selected|repeating_weapon_$1_name} (@{selected|repeating_weapon_$1_range}ft) ♦ --title|[[ [$AtkWpn] ?{@{selected|repeating_weapon_$0_name} (0), @{selected|repeating_weapon_$1_name} (1), @{selected|repeating_weapon_$2_name} (2) } + 0d0 ]] --?? $AtkWpn == 0 ?? Weapon:| @{selected|repeating_weapon_$0_name} --?? $AtkWpn == 0 ?? Attack:|[[ [$AtkBow] 1d20cs>@{selected|repeating_weapon_$0_crit-target} + @{selected|repeating_weapon_$0_total-attack}]] vs **AC** --?? $AtkWpn == 0 AND $AtkBow.base >= @{selected|repeating_weapon_$0_crit-target} ?? Damage:|[[@{selected|repeating_weapon_$0_crit-multiplier}*[[@{selected|repeating_weapon_$0_damage-dice-num}d@{selected|repeating_weapon_$0_damage-die}]] + @{selected|repeating_weapon_$0_total-damage}]]**@{selected|repeating_weapon_$0_type}** --?? $AtkWpn == 0 AND $AtkBow.base < @{selected|repeating_weapon_$0_crit-target} ?? Damage:|[[@{selected|repeating_weapon_$0_damage-dice-num}d@{selected|repeating_weapon_$0_damage-die} + @{selected|repeating_weapon_$0_total-damage}]]**@{selected|repeating_weapon_$0_type}** --?? $AtkWpn == 1 ?? Weapon:| @{selected|repeating_weapon_$1_name} --?? $AtkWpn == 1 ?? Attack:|[[ [$AtkDag] 1d20cs>@{selected|repeating_weapon_$1_crit-target} + @{selected|repeating_weapon_$1_total-attack}]] vs **AC** --?? $AtkWpn == 1 AND $AtkDag.base >= @{selected|repeating_weapon_$1_crit-target} ?? Damage:|[[@{selected|repeating_weapon_$1_crit-multiplier}*[[@{selected|repeating_weapon_$1_damage-dice-num}d@{selected|repeating_weapon_$1_damage-die}]] + @{selected|repeating_weapon_$1_total-damage}]]**@{selected|repeating_weapon_$1_type}** --?? $AtkWpn == 1 AND $AtkDag.base < @{selected|repeating_weapon_$1_crit-target} ?? Damage:|[[@{selected|repeating_weapon_$1_damage-dice-num}d@{selected|repeating_weapon_$1_damage-die} + @{selected|repeating_weapon_$1_total-damage}]]**@{selected|repeating_weapon_$1_type}** --?? $AtkWpn == 2 ?? Weapon:| @{selected|repeating_weapon_$2_name} --?? $AtkWpn == 2 ?? Attack: *1|[[ [$AtkDag] 1d20cs>@{selected|repeating_weapon_$2_crit-target} + @{selected|repeating_weapon_$2_total-attack}]] vs **AC** --?? $AtkWpn == 2 AND $AtkDag.base >= @{selected|repeating_weapon_$2_crit-target} ?? Damage: *1|[[@{selected|repeating_weapon_$2_crit-multiplier}*[[@{selected|repeating_weapon_$2_damage-dice-num}d@{selected|repeating_weapon_$2_damage-die}]] + @{selected|repeating_weapon_$1_total-damage}]]**@{selected|repeating_weapon_$1_type}** --?? $AtkWpn == 2 AND $AtkDag.base < @{selected|repeating_weapon_$2_crit-target} ?? Damage: *1|[[@{selected|repeating_weapon_$2_damage-dice-num}d@{selected|repeating_weapon_$2_damage-die} + @{selected|repeating_weapon_$2_total-damage}]]**@{selected|repeating_weapon_$2_type}** --?? $AtkWpn == 2 ?? Attack: *2|[[ [$AtkDag] 1d20cs>@{selected|repeating_weapon_$2_crit-target} + @{selected|repeating_weapon_$2_total-attack}]] vs **AC** --?? $AtkWpn == 2 AND $AtkDag.base >= @{selected|repeating_weapon_$2_crit-target} ?? Damage: *2|[[@{selected|repeating_weapon_$2_crit-multiplier}*[[@{selected|repeating_weapon_$2_damage-dice-num}d@{selected|repeating_weapon_$2_damage-die}]] + @{selected|repeating_weapon_$1_total-damage}]]**@{selected|repeating_weapon_$1_type}** --?? $AtkWpn == 2 AND $AtkDag.base < @{selected|repeating_weapon_$2_crit-target} ?? Damage: *2|[[@{selected|repeating_weapon_$2_damage-dice-num}d@{selected|repeating_weapon_$2_damage-die} + @{selected|repeating_weapon_$2_total-damage}]]**@{selected|repeating_weapon_$2_type}** }} My current fix to rapid fire is attack 3 which is a separate attack listed on the character sheet. As you can see this is long and tidious to iplement. Any ideas or know a place I can grab macros already written? Cheers, ToastiePOP
1455647127
Silvyre
Roll20 Mod Team
If you're willing to delve into the realm of advanced Roll Queries , you might learn how to use a potentially more convenient* way of handling conditionally-active feats , and may also discover that you'll spare yourself conditionals by doing so. *For the user of the macro, probably not for the creator. :)
Silvyre said: If you're willing to delve into the realm of advanced Roll Queries , you might learn how to use a potentially more convenient* way of handling conditionally-active feats , and may also discover that you'll spare yourself conditionals by doing so. *For the user of the macro, probably not for the creator. :) We looked over this but had no luck getting any of the queries we created to work. Is it possible to grab a template of something similar to what I'm after as something to play with? Thanks again for the advice.
1455676747
I'd like to use the status symbol icons in my powercards, so i could do something like --Dazed Condition:| @ The creature is unable to act normally. A dazed creature can take no actions, but has no penalty to AC. and replace the @ with the status icon for something.  Is this possible, HB?
1455695066
Sky
Pro
GenKitty, do you mean having the image in the power card or automatically applying the status icon to the token?
!power {{ --tokenid|@{selected|token_id} --emote|//?{Description}// --name|Multi Attacks --Attack:#?{Number of Attacks|1}| [[1d20 + ?{Attack Modifier|0}]] VS **AC** ^^ **Damage**: [[?{Number of dice|1}d?{Sides of Dice|6} + ?{Damage Modifier|0}]] }} Is there currently a way to make it ask every iteration of a roll for a specific value eg. Attack bonus? Really trying to get Itterations to work =[
1455711702

Edited 1455711778
I mean having the image in the card.  This is Powercards, not TokenMods ;)  It's a WouldBeNice, not a GottaHave.
1455713468
Sky
Pro
ToastiePOP! said: !power {{ --tokenid|@{selected|token_id} --emote|//?{Description}// --name|Multi Attacks --Attack:#?{Number of Attacks|1}| [[1d20 + ?{Attack Modifier|0}]] VS **AC** ^^ **Damage**: [[?{Number of dice|1}d?{Sides of Dice|6} + ?{Damage Modifier|0}]] }} Is there currently a way to make it ask every iteration of a roll for a specific value eg. Attack bonus? Really trying to get Itterations to work =[ Nope. All it does is copy that tag|content that many times. Most people just hard code the iterative attacks anyway. 
1455714122
Sky
Pro
GenKitty said: I mean having the image in the card.  This is Powercards, not TokenMods ;)  It's a WouldBeNice, not a GottaHave. https://app.roll20.net/images/statussheet.png Possibly... but it may be difficult since all the status icons are one wide image and then only part of the image is shown via sprite-sheet-style scripting. Which is about the extent of my knowledge of that... lol. 
1455714429
Righty then.  I'll do without.
Would it be possible to check for status icons as a conditional? > double checks original post so I don't have to admit stupidity again <
1455716864
Sky
Pro
GenKitty said: Righty then.  I'll do without. Almost have it. :D  
1455717277
Sky
Pro
Khoros said: Would it be possible to check for status icons as a conditional? > double checks original post so I don't have to admit stupidity again < Ah, currently no... but I can probably add that eventually. That request will be a bit involved.
1455717572
Sky
Pro
Okay, got it working for the first icon. Now I just need to figure out the math for negative margin-left and it should be mostly done.
1455717653

Edited 1455717775
The Aaron
Pro
API Scripter
GenKitty said: I'd like to use the status symbol icons in my powercards, so i could do something like --Dazed Condition:| @ The creature is unable to act normally. A dazed creature can take no actions, but has no penalty to AC. and replace the @ with the status icon for something.  Is this possible, HB? That sounds like it would be really cool...  (I think you know where this is going... =D) !power {{   --name| Status Test %%pink%%   --Dazed Condition:| %%half-haze%% The creature is unable to act normally.  A dazed creature can take no actions, but has no penalty to AC. }} Code changes: New function at about line 882: function statusSymbol(symbol,altForReplace){     var statuses = [             'red', 'blue', 'green', 'brown', 'purple', 'pink', 'yellow', // 0-6             'skull', 'sleepy', 'half-heart', 'half-haze', 'interdiction',             'snail', 'lightning-helix', 'spanner', 'chained-heart',             'chemical-bolt', 'death-zone', 'drink-me', 'edge-crack',             'ninja-mask', 'stopwatch', 'fishing-net', 'overdrive', 'strong',             'fist', 'padlock', 'three-leaves', 'fluffy-wing', 'pummeled',             'tread', 'arrowed', 'aura', 'back-pain', 'black-flag',             'bleeding-eye', 'bolt-shield', 'broken-heart', 'cobweb',             'broken-shield', 'flying-flag', 'radioactive', 'trophy',             'broken-skull', 'frozen-orb', 'rolling-bomb', 'white-tower',             'grab', 'screaming', 'grenade', 'sentry-gun', 'all-for-one',             'angel-outfit', 'archery-target'         ],         statusColormap = ['#C91010', '#1076c9', '#2fc910', '#c97310', '#9510c9', '#eb75e1', '#e5eb75'],     i; symbol = altForReplace||symbol; if(_.contains(statuses,symbol)){         i=_.indexOf(statuses,symbol);         if(i<7) {             return '<div style="width: 22px; height: 22px; border-radius:100%; display:inline-block; margin: 0; border:0; background-color: '+statusColormap[i]+'"></div>';         }          return '<div style="width: 24px; height: 24px; display:inline-block; margin: 0; border:0; cursor: pointer;padding:0;background-image: url(\'https://app.roll20.net/images/statussheet.png\');background-repeat:no-repeat;background-position: '+((-34)*(i-7))+'px 0px;"></div>'; } return ''; } Line to call it in the formatters at about line 945: .replace(/%%(.*?)%%/g,statusSymbol)
1455717714
The Aaron
Pro
API Scripter
(I should probably refresh before I post, but hey.. feel free to grab my math if you want. =D )
1455718021
Sky
Pro
:P
1455718136
Sky
Pro
One issue... %% is already used for target info charms.
1455718459

Edited 1455718473
The Aaron
Pro
API Scripter
can use whatever in the replace: .replace(/\[\+(.*?)\]/g,statusSymbol)
1455718519
The Aaron
Pro
API Scripter
The problem I hadn't solved was getting the scale to the font, rathe than what the image want's to be.  Background sprites are a little weird.
1455718602

Edited 1455718617
Sky
Pro
Yeah. Scaling it to 75% of the width seemed to work for me, but that would throw off your math.
1455718778
The Aaron
Pro
API Scripter
just multiple the end result by .75  =D
1455719203
Sky
Pro
The css background-size: 75% auto; is getting stripped out. >_<
1455719326
The Aaron
Pro
API Scripter
yeah, I ran into that problem too..  might be easier just to host them as separate images...
1455719370

Edited 1455720183
The Aaron
Pro
API Scripter
Honestly, having them oversized isn't ideal, but also isn't too bad for as little use as they are likely to see (currently).  Still looking into solutions though. =D
1455720298

Edited 1455720358
Sky
Pro
Here's my temporary solution... added a float:left to the image div and a slight bit of padding on the left and right. Hid the !Tag and added **Dazed:** as a fake tag after the status icon.
1455720444
The Aaron
Pro
API Scripter
Sounds usable. =D
1455720588
Sky
Pro
Ah, idea. Need to add a configuration option for GenKitty to designate names for each status effect. So that instead of having to remember the names of the pictures, she can use the name of the status effect and the script converts it to the actual icon name.
1455721180
Sky
Pro
What is altForReplace in the statusSymbol function for?
1455721500
The Aaron
Pro
API Scripter
When you pass a function to .replace(), the first parameter is the entirely matched string, the second is the first group, etc.  Doing it like that means that you can call statusSymbol as  statusSymbol('overdrive'); or pass it to .replace() to get the symbol for the first group.  Kind of special purpose and lazy.  Probably I should have left that out and just called it like: .replace(/\[\+(.*?)\]/g,function(whole,symbolName){return statusSymbol(symbolName);})
1455722028

Edited 1455722242
Sky
Pro
Ok, tired now. Will finish modifying this later with a way to configure a list of status effects to roll20 icon names, so that you and your players can just use the actual status name instead of trying to remember which icon goes with what status effect. Big thanks to Aaron for putting this together so quickly.
1455722780

Edited 1455722858
The Aaron
Pro
API Scripter
(Aaron cheated and heisted it out of some existing code from TokenNameNumber.  =D ) For your translations, I'd leave statusSymbol "pure" and have a function that converts a name into a symbol name, something like: function translateSymbolAlias(aliasName){ return symbolAliases[aliasName]||aliasName; }  Then elsewhere you just have to load up symbolAliases with whatever: symbolAliases['dazed']='half-haze'; Calling: .replace(/\[\+(.*?)\]/g,function(whole,symbolName){return statusSymbol( translateSymbolAlias( symbolName ) );})
1455733139
You two are awesome.  I am perfectly fine with using whatever the names of the pictures are, but Aaron always has to get clever.  I look forward to the new release version! (And don't think I didn't see what that macro was named, HB: Yet Another GenKitty Request)
1455735810
The Aaron
Pro
API Scripter
We all know you're just here to make all scripts great. =D
1455738897

Edited 1455739117
Phoxounet
Pro
Sheet Author
Translator
Hi ! I'm using a conditional to see if a character keep his turn or loose it (substracting 10 from his initiative). Everything in the powercard works as intended (with the trkr tag). However, in the conditional result, I added [[10 &{tracker:-}]] when the test fails and the character loses his initiative. It is not functioning. Any idea someone ? :) !power {{ --charid|@{character_id} --emote|**@{character_name}** rolls for Domination ! --name|Combat --rightsub|Domination --CNC :|[[ [$Roll] 1D10cf<0cs>11 [trkr] ]] --?? $Roll.base <= @{CNC} ?? Success:| @{character_name} succeeds at his Domination test ! --?? $Roll.base > @{CNC} ?? Fail :| @{character_name} fails and lost his initiative  [[10 &{tracker:-}]] ! }}
1455739433

Edited 1455739987
Sky
Pro
This line should be: --CNC :|[[ [$Roll|TRKR] 1D10cf<0cs>11 ]] ... but I've never tried using the options to adjust initiative with powercards before. Not sure if that will work properly.