Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Math Puzzle

What is a calculation you can do to turn an unknown number to 0 if it's non-0 and to 1 if it's 0, never knowing the original number?
1497317227
The Aaron
Pro
API Scripter
For an attribute: [[ 1 - ceil((  @{SOMETHING}  )*0.00001) ]] (assuming it's 10000 or less...) for dice, just replace the @{SOMETHING} with the formula. This works by first making the number really small or 0  (0*0.00001 == 0, something less than 10000 but greater than 0 will be a positive number greater than 0 and less than 1.  Then ceil() turns it into 1, unless it's 0.  then 1- (it) flips it from 0 to 1 or from 1 to 0.
1497317812
Silvyre
Forum Champion
This would also work: [[ {?{num}, -1}=0 ]]
1497317868
The Aaron
Pro
API Scripter
There you go making math seem easy Silvyre!! =D
The formulas work in stripped down testing, thanks guys, but when I add them to my macro the pulldown menu breaks, not sure what I'm missing here... /w gm &{template:npcatk} {{attack=1}} {{always=1}} ?{Select Saving Throw | Strength Save, {{rname=Strength Save}} {{name=@{selected|token_name} ([[ [[(@{selected|strength_save_bonus}*({@{selected|npc_str_save_flag},-1}=0))+(@{selected|npcd_str_save}+@{selected|strength_save_prof})]][Str+Prof]@{selected|globalsavingthrowbonus}]])}} {{r1=[[1d20@{selected|halflingluck}+[[(@{selected|strength_save_bonus}*({@{selected|npc_str_save_flag},-1}=0))+(@{selected|npcd_str_save}+@{selected|strength_save_prof})]][Str+Prof]@{selected|globalsavingthrowbonus}]]}} {{r2=[[1d20@{selected|halflingluck}+[[(@{selected|strength_save_bonus}*({@{selected|npc_str_save_flag},-1}=0))+(@{selected|npcd_str_save}+@{selected|strength_save_prof})]][Str+Prof]@{selected|globalsavingthrowbonus}]]}} | Dexterity Save, {{rname=Dexterity Save}} {{name=@{selected|token_name} ([[ [[(@{selected|dexterity_save_bonus}*({@{selected|npc_dex_save_flag},-1}=0))+(@{selected|npcd_dex_save}+@{selected|dexterity_save_prof})]][Dex+Prof]@{selected|globalsavingthrowbonus}]])}} {{r1=[[1d20@{selected|halflingluck}+[[(@{selected|dexterity_save_bonus}*({@{selected|npc_dex_save_flag},-1}=0))+(@{selected|npcd_dex_save}+@{selected|dexterity_save_prof})]][Dex+Prof]@{selected|globalsavingthrowbonus}]]}} {{r2=[[1d20@{selected|halflingluck}+[[(@{selected|dexterity_save_bonus}*({@{selected|npc_dex_save_flag},-1}=0))+(@{selected|npcd_dex_save}+@{selected|dexterity_save_prof})]][Dex+Prof]@{selected|globalsavingthrowbonus}]]}} }
I managed to get the pulldown menus working using Aaron's formula, still can't figure out why Silvyrel's formula broke them, both worked great on their own.
1497327667
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Because you need to do advanced roll queries for Silvyre's (replace the } with }
1497331373

Edited 1497345691
I had removed the query, this is the code I used [[{@{selected|npc_con_save_flag},-1}=0]] which brace needs to be replaced?
1497345725

Edited 1497345780
Ziechael
Forum Champion
Sheet Author
API Scripter
Craig said: I had removed the query, this is the code I used [[{@{selected|npc_con_save_flag} , -1 } =0]] which brace needs to be replaced? The one in bold, html replacements aren't needed for attribute calls but for any queries, groupings etc they are. If html replacements are needed due to nesting please note that this will apply to the bolded comma as well as any non-attribute call '|' too.