#Basic Checkbox Question
1 messages · Page 1 of 1 (latest)
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)
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).
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
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.
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
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.
and it sounds like your checkboxes are something like:
- 1d6 only
- 1d6 and 1d10
- 2d6 and 1d10
- etc?
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).
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
[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]
you want three ticks (same button as the tilde, without holding shift)
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.
[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
I'll give it a check and let you know. Thanks for the help.
no problem!
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.
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.
Do you see them as one screen though? I'd like the players not to have to go through two steps, simply on handlng time grounds.
(As in, does it display the choices at one time or in succession).
Because otherwise, yeah, that sounds optimal.
It’s a single input() function so a single dialog. 🙂
Then I'll give it a look. As always, thanks for the help.
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.
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.
Yeah, I didn't see any obvious problem, but I'll give it another look (probably in a text file just so I can make it bigger) and then plop it in here if I still can't find anything.
Could probably just paste your "input" line initially so that folks can take a look at the formatting of that particular function.
Will do.
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.
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.
Noted. Soon as I copied them into the text editor to examine it, and they broke I had a pretty good idea.
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.
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 😁)
I thought I tried making it just one and it still didn't work, but I might have done the "try more than one thing at once" mistake. Let me go back and see if that works; its easy to check.
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.
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)