Help with CODE roll and random quotation marks

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
ccarico
Kobold
Posts: 2
Joined: Sun Apr 06, 2014 7:33 am

Help with CODE roll and random quotation marks

Post by ccarico »

Hey guys! First time post, long time browser. Over the past couple of years I've been Frankensteining batches of code for my games with the help you guys have posted previously.

I've finally stepped up and started using CODE as a roll option for my macros and I think I have done decently to get this far without much P2P help. But, right now, I'm just stuck on a small issue that irks me.

The code I have (below) outputs everything fine roll wise, but there are two sets of random quotation marks that get inserted either before or after the attack and hit rolls. It is somehow linked to if the player is using a ranged or melee attack, but I just can't figure out where they come from.

Code: Select all

[h:WeaponState=Melee_0_Or_Ranged_1]
[h:IsMelee= if(WeaponState==0, 1, 0)]
[h:IsRanged= if(WeaponState==1, 1, 0)] 
[h:roll1=1d20] 
[h:roll2=1d20]

<table border='1' cellpadding='5' cellspacing='0' width='500'>
    <tr style="background-color: green">
        <td><span style='color: white; font-weight: bold'>Twin Strike - Ranger Attack 1</span></td>
    </tr>

    <tr style="background-color: #DAD9C6">
        <td style="font-style: italic">If the first attack doesn't kill it, the second one might.</td>
    </tr>

    <tr>
        <td><b>At-will • Martial, Weapon</b><br>
        <b>Standard Action • Melee weapon</b></td>
    </tr>

    <tr style="background-color: #DAD9C6">
        <td><b>Target:</b> One creature<br></td>
    </tr>

    <tr>
        <td><b>Attack Roll:</b> [t,IF(IsMelee==1),CODE: {[t:totalroll1=Roll1+7] (Longsword) & [t:totalroll2=Roll2+7] (Shortsword) vs. AC}] [t,if(IsRanged==1),CODE: {[t:totalroll1=Roll1+6] & [t:totalroll2=Roll2+6] (Longbow) vs. AC}] <span style='color:00E31A'>[r:if(Roll1==20,'Your first roll was a Critical Success!','')]</span><span style='color:C90000'>[r:if(Roll1==1,'Your first roll was a Critical Failure!','')]</span> <span style='color:00E31A'>[r:if(Roll2==20,'Your second roll was a Critical Success!','')]</span><span style='color:C90000'>[r:if(Roll2==1,'Your second roll was a Critical Failure!','')]</span></td>
    </tr>

    <tr style="background-color: #DAD9C6">
        <td><b>Hit:</b> [t,IF(IsMelee==1),CODE: {[t:if(Roll1==20, 8, 1d8)] (Longsword) & [t:if(Roll2==20, 6, 1d6)] (Shortsword) damage}] [t,if(IsRanged==1),CODE: {[t:if(Roll1==20, 10, 1d10)] & [t:if(Roll2==20, 10, 1d10)] (Longbow) damage}]</td>
    </tr>
Here are two examples of how they show up on both sides. Any help with this (or my general macro) would be greatly appreciated. THANKS A BUNCH!

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Help with CODE roll and random quotation marks

Post by wolph42 »

I haven't read you code but a stray " is usually a lacking else statement in an if code block:

[If,code:{}]
Will render a. "
[If,code:{};{}]
Will not.

ccarico
Kobold
Posts: 2
Joined: Sun Apr 06, 2014 7:33 am

Re: Help with CODE roll and random quotation marks

Post by ccarico »

wolph42 wrote:I haven't read you code but a stray " is usually a lacking else statement in an if code block:

[If,code:{}]
Will render a. "
[If,code:{};{}]
Will not.
You are completely right and I don't know why that didn't hit me sooner. I had the else statement, but didn't even relate it to the first line of code.

Thanks bunches <3


Post Reply

Return to “Macros”