#Kind of complicate macro failing out.

1 messages · Page 1 of 1 (latest)

fathom geyser
#

Okay, I tried to do something kind of complicated here, and I suspect I tried to do something in lines 27-29 that's a no-no, because its throwing a syntax error; I looked at the wiki's entry for if statements, and at prior use I'd made in a slightly simpler macro, and nothing is jumping out at me as a no-no (its always possible I'm missing a parenthesis or bracket somewhere and just can't see it of course).

In any case, I'd appreciate any help. The code is in the next post.

#

(And yes, I know there's probably a more elegant way to do what I was doing with those three lines, but I wanted to do something about the fact I'd otherwise be trying to multiply 0 by two in that part of the code).

thorn pilot
#

Line 6: extra comma at the end of the last input field
Lines 14-24: cannot run the separate commands like that, need to wrap them in a code block
Lines 25-29: extra bracket after ChoiceSize

e.g. for Line 14

[h,if (ChoiceWarhead == 0): BaseDamage = 0, SkillRollAdd = 0, WeaponTraits2 = "Blinding", Area = "Uniform (50m)"]

would become:

[h,if (ChoiceWarhead == 0), code: {
    [h: BaseDamage = 0]
    [h: SkillRollAdd = 0]
    [h: WeaponTraits2 = "Blinding"]
    [h: Area = "Uniform (50m)"]
}]
#

Alternatively, you could use json and reduce the code repitition, e.g.:

[h: BaseDamage = 0]
[h: WeaponTraits = "None"]
[h: SkillRollAdd = 0]

[h: '<!-- load data into nested json objects -->']
[h: vWarheads = json.set("{}", 
    "Dazzler", json.set("{}", "BaseDamage",0, "WeaponTraits2","Blinding", "Area", "Uniform  (50m)"),
    "EMP", json.set("{}", "BaseDamage",3D10, "WeaponTraits2","Disables Radios, Damage to Nanoswarms Only", "Area", "Uniform (20m)")
)]

[h: '<!-- use the parent json object keys for the radio input values and return the selection as string rather than the index number -->']
[h: input1 = input(
"ChoiceWarhead|" + json.fields(vWarheads) + "|Warhead?|RADIO|VALUE=STRING",
"ChoiceSize|Micromissile/Minigrenade, Minimissile/Standard Grenade, Standard-Missile|Warhead Size?|RADIO|SELECT=0",
"ChoiceSkill|No Superior, Superior 1, Superior 2|Skill Option?|RADIO"
)]

[h: '<!-- stop macro execution if the user cancels the input dialog -->']
[h: abort(input1)] 

[h: SkillRollAdd = roll(ChoiceSkill,6)]

[h: '<!-- get the attributes for the selected choice, and convert them to variables -->']
[h: json.toVars(json.get(vWarheads, ChoiceWarhead))]

[h, if(ChoiceSize == 0): WarheadDamage = BaseDamage]
[r, if(ChoiceSize == 1): WarheadDamage = BaseDamage + 1D10]
[h, if(ChoiceSize == 2), code: {
    [h: BaseDamage = BaseDamage + 1.25]
    [h: WarheadDamage = (BaseDamage * 2) - 2.5]
}]
[h: MacroName = getMacroName()]
[h: Total = WarheadDamage + SkillRollAdd]
fathom geyser
#

I wondered if it might be that trick of attempting to do it with simply commas wouldn't work, but didn't want to go back and rework all that just to find out it wasn't the problem.
I'm only seeing one open and one closed bracket in lines 25-29; what am I missing?
I usually avoid messing with json sets, but it might be worth it here, since otherwise that's going to make this ruddy long...

#

Oh, wait, you meant parenthesis. Don't know how I missed that.

fathom geyser
#

Let me go address all this and see how it goes. In any case, thanks for your assistance.