#Basic Checkbox Question

1 messages · Page 1 of 1 (latest)

hushed juniper
#

Is there a simple way to tell a set of checkboxes to only permit one of them to be marked at one time (the thing I'm doing will already effectively ignore the lower-value input anyway, it just looks messy.)

ebon viper
#

It may be easier to use radio buttons instead, if that would work for you

#

Otherwise if you're using JS, you could make an onchange event function to uncheck all of the other checkboxes in a set when one is checked

#

If you're using input() in MTScript then it can't be done (unless using RADIO as above)

hushed juniper
#

Might be. To complicate the issue, I have two sets of three options (no bonus damage from two different sources, some bonus damage, and more bonus damage. So there are effectively six cases).

ebon viper
#

Should be alright with radio, you just may need to split the two sources into two separate radio inputs (if they can stack). Or keep them as one radio input if they can't

hushed juniper
#

They can. I was trying not to ask for input twice which is why I initially went with the checkboxes.

#

I'm not exactly expert with forms, so I was tyring to avoid going there.

ebon viper
#

Ah, I misunderstood - I thought each source had 3 options associated with it, not that it was 6 total permutations

#

In that case you could just replicate the checkboxes completely as different radio options, shouldn't be an issue there

hushed juniper
#

You're sort of right; one adds 0, 1D6 or 2D6, the other adds 0, 1D10 or 2D10, and the first and second categories can stack.

ebon viper
#

and it sounds like your checkboxes are something like:

  • 1d6 only
  • 1d6 and 1d10
  • 2d6 and 1d10
  • etc?
hushed juniper
#

When you do them as separate radio options, do they display at once? I'm trying to keep handling on the macro low since it'll be used a lot in combat.

#

Sort of. You know, hold on, let me show the experimental version so it just is clearer (this isn't complete, its just a test version).

ebon viper
#

The options all show at once - as opposed to LIST, where you'd have to click into the menu to see what the options are

hushed juniper
#
[h: WeaponTraits = "None"]
[h: ROFAdd = 0]
[h: SkillRollAdd = 0]
[h:status=input(
    "A|1|Option A|CHECK",
    "B|0|Option B|CHECK",
    "C|0|Option C|CHECK",
    "D|1|Option D|CHECK",
    "E|0|Option E|CHECK",
    "F|0|Option F|CHECK"
    )]
[h:abort(status)]
[h,if(A==1): ROFAdd = 0]
[h,if(B==1): ROFAdd = 1]
[h,if(C==1): ROFAdd = 2]
[h,if(D==1): SkillRollAdd = 0]
[h,if(E==1): SkillRollAdd = 1]
[h,if(F==1): SkillRollAdd = 2]
[h:MacroName = getMacroName()]
[h:Total = (BaseDamage + ROFAdd + SkillRollAdd)]
[MacroName] is Base Damage [BaseDamage] plus ROF [ROFAdd] plus Roll Bonus [SkillRollAdd] = [Total]; Weapon Traits are: [WeaponTraits]
ebon viper
#

you want three ticks (same button as the tilde, without holding shift)

hushed juniper
#

Yeah, I misremembered.

#

Basically, in the final the 1 and 2 outputs will be replaced by D6/2D6 and D10/2D10 adds.

#

This works, its just sloppy.

ebon viper
#
[h: WeaponTraits = "None"]
[h: ROFAdd = 0]
[h: SkillRollAdd = 0]
[h:status=input(
    "bonusChoice|Option A,Option B,Option C,Option D,Option E,Option F| Which Option?|RADIO"
    )]
[h:abort(status)]
[h,switch(bonusChoice):
  case 0: ROFAdd = 0;
  case 1: ROFAdd = 1;
  case 2: ROFAdd = 2;
  case 3: SkillRollAdd = 0;
  case 4: SkillRollAdd = 1;
  case 5: SkillRollAdd = 2
]
[h:MacroName = getMacroName()]
[h:Total = (BaseDamage + ROFAdd + SkillRollAdd)]
[MacroName] is Base Damage [BaseDamage] plus ROF [ROFAdd] plus Roll Bonus [SkillRollAdd] = [Total]; Weapon Traits are: [WeaponTraits]```
#

Pretty sure this should work. Bit rusty on my MTScript

hushed juniper
#

I'll give it a check and let you know. Thanks for the help.

ebon viper
#

no problem!

hushed juniper
#

Okay, only problem with this version is since it only allows you to do one radio button, I'd have to have more of them and spell out, since there's actually nine cases (No skill bonus/1 skill bonus/2 skill bonus, no weapon bonus/1 weapon bonus/2 weapon bonus, combined with each other). I mean, I could do nine radio buttons but I suspect it'd be easier for people to just be able to check the relevant boxes and let the individual variable handle it. But them I'm back to the sets-of-three check boxes not being exclusive, which doesn't hurt the output the way I have it (since the higher value in each case takes priority by coming later in the calculation) but just looks odd.

little temple
#

It just sounds like you want two lines in your input() statement. Something like:

[h: status = input(
”choiceROF|Option A, Option B, Option C|ROW Option?|RADIO”,
“choiceSkill|Option D, Option E, Option F|Skill Option?|RADIO”)
)]

Then use the choiceROF and choiceSkill variables to decide what the values should be for ROFAdd and SkillAdd.

#

That separates the radio buttons into two sets, one that allows a single choice for ROF and one that allows a single choice for Skill.

hushed juniper
little temple
#

It’s a single input() function so a single dialog. 🙂

hushed juniper
#

Then I'll give it a look. As always, thanks for the help.

hushed juniper
#

One more question here: I'm getting an error message and I don't actually understand the syntax of the line reference (I've found this confusing before with MT). It reads:
"line 1:28: expecting '|', found 'O'"

That makes no sense with line 1, and there is no line 28 so I'm a bit confused to where to even look for the problem.

little temple
#

You likely have a typo, probably a double quote.

#

Also, the second variable had been auto-corrected to “ChoiceSkill” with a capital letter, so I changed it to lowercase in my code example.

hushed juniper
hallow tree
hushed juniper
#

Heh. Though the error message still leaves me baffled, the actual problem apparently was that I hadn't noticed Azhrei had used typographical quotation marks rather than dumb quotation marks, and apparently Maptool was Not A Fan. When I changed them to dumb quotation marks it worked fine.

little temple
#

Glad you found it.

Yeah, discord and/or the autocorrect must’ve done that. It’s always risky to copy/paste text; paste into a dumb editor first, then into the MT editor.

hushed juniper
hushed juniper
#

Okay, tried to proceed further with this, but ran into a problem when I tried to go from a flat add in the ROFAdd and SkillRollAdd fields to a die roll. The macro will run, but the output on those two fields is always zero.

Current code for the macro:

[h: WeaponTraits = "None"]
[h: ROFAdd = 0]
[h: SkillRollAdd = 0]
[h: status = input(
"ChoiceROF|Option A, Option B, Option C|ROW Option?|RADIO",
"ChoiceSkill|Option D, Option E, Option F|Skill Option?|RADIO")
)]
[h,if (ChoiceROF == 0): (ROFAdd == 0)]
[h,if (ChoiceROF == 1): (ROFAdd == 1D10)]
[h,if (ChoiceROF == 2): (ROFAdd == 2D10)]
[h,if (ChoiceSkill == 0): (SkillRollAdd == 0)]
[h,if (ChoiceSkill == 1): (SkillRollAdd == 1D6)]
[h,if (ChoiceSkill == 2): (SkillRollAdd == 2D6)]
[h:MacroName = getMacroName()]
[h:Total = (BaseDamage + ROFAdd + SkillRollAdd)]
[MacroName] is Base Damage [BaseDamage] plus ROF [ROFAdd] plus Roll Bonus [SkillRollAdd] = [Total]; Weapon Traits are: [WeaponTraits]```
#

I even tried to use CODE for the second part in case that was necessary for some reason and it didn't seem to help, so I'm assuming there's something about using a die roll with this kind of construct I don't know and am not doing.

ebon viper
#

You shouldn't be doing SkillRollAdd == 1d6 or similar - just one equals sign. You're asking it to compare the SkillRollAdd to the roll, which is always false (0)

#

(maybe other issues, that's just what I saw quick while I'm supposed to be working 😁)

hushed juniper
#

When I make those assigns a single equal, I get this:

"java.lang.NullPointerException: Cannot invoke "antlr.collections.AST.getType()" because "node" is null error executing expression (SkillRollAdd = 1D6)."

#

And I should note it does that even when the equal is referencing a fixed value (such as 1) it just says the expression is "SkillRollAdd=1"

#

Oh, good gods. It doesn't like the parentheses. I'd never have called that one.

#

Though you're corret the double = was a mistake (I didn't think it was right, but was kind of flailing around.) But once I removed the parentheses on the if assign lines it works.

ebon viper
#

Ah - yeah, because parentheses are okay for separating out different statements but they shouldn't be involved when setting values (e.g. you wouldn't do [(SkillRollAdd=1)] when outside of the switch)