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

Is there an If/Then/Else api that can output text based on true/false result of the condition? If not, how can I make one?

I need to be able to output text based on a calculation. In this case I am comparing an input variable to a target's AC. I currently have it setup like this: [[?{Attack Strength}+1-@{target|Defender|npc_ac}]],0}>1 } ]]t[HitResponse] ]] which displays "Hit!" if the variable is greater than or equal to the defender's AC, but if it less than the target's AC, it displays "0". I want it to display "Miss!". Any help would be greatly appreciated! Thank you!
1642886774
timmaugh
Forum Champion
API Scripter
To answer the question you asked, APILogic. That will let you do conditional output. With that and ZeroFrame, you can output basic messages that hit the chat. To answer what you're actually trying to do, you could accomplish it with some clever roll mechanics and two separate tables - one for "Hit!" and one for "Miss!" But, since you're pro, you can use the APILogic script pretty easily...  !{& if [[?{Attack Strength}+1-@{target|Defender|npc_ac}]].value > 0}Hit!{& else}Miss!{&end}{&simple} You can do that in a roll template if you want to include more information: !&{template:default}{{name=@{selected|token_name} attacks @{target|Defender|token_name}}}{{Attack Strength=?{Attack Strength}}}{{Attack Roll=[[?{Attack Strength}+1-@{target|Defender|npc_ac}]]}}{{Result={& if [[?{Attack Strength}+1-@{target|Defender|npc_ac}]].value > 0}Hit!{& else}Miss!{&end} }}{&simple} REQUIRED SCRIPTS : APILogic, ZeroFrame
timmaugh said: To answer the question you asked, APILogic. That will let you do conditional output. With that and ZeroFrame, you can output basic messages that hit the chat. To answer what you're actually trying to do, you could accomplish it with some clever roll mechanics and two separate tables - one for "Hit!" and one for "Miss!" But, since you're pro, you can use the APILogic script pretty easily...  !{& if [[?{Attack Strength}+1-@{target|Defender|npc_ac}]].value > 0}Hit!{& else}Miss!{&end}{&simple} You can do that in a roll template if you want to include more information: !&{template:default}{{name=@{selected|token_name} attacks @{target|Defender|token_name}}}{{Attack Strength=?{Attack Strength}}}{{Attack Roll=[[?{Attack Strength}+1-@{target|Defender|npc_ac}]]}}{{Result={& if [[?{Attack Strength}+1-@{target|Defender|npc_ac}]].value > 0}Hit!{& else}Miss!{&end} }}{&simple} REQUIRED SCRIPTS : APILogic, ZeroFrame Thank you! Is there a way you can whisper the output?
CRL will do things when specific things pass chat and it can parse crits and fumbles.  
Never mind, I figured it out: add "/w gm" in the sub sections (or whatever they are called). Do you have a tutorial on how to use ZeroFrame?
DM Eddie said: CRL will do things when specific things pass chat and it can parse crits and fumbles.   Which one is CRL?
Andrew E. said: DM Eddie said: CRL will do things when specific things pass chat and it can parse crits and fumbles.   Which one is CRL? customizeable roll listener, its very finicky and everytime I have ever gotten it to work it spams my sandbox with an error but it still works.  Nobody ever picked up the mantle on it and fixed it up its a very old script I think.  
1642911189
timmaugh
Forum Champion
API Scripter
The ZeroFrame thread has info, and links to a second thread, too. <a href="https://app.roll20.net/forum/post/10005704/meta-script-zeroframe-one-script-to-control-them-all" rel="nofollow">https://app.roll20.net/forum/post/10005704/meta-script-zeroframe-one-script-to-control-them-all</a> Here is the Meta Toolbox thread with links to the other script threads (like APILogic): <a href="https://app.roll20.net/forum/post/10005695/script-set-the-meta-toolbox" rel="nofollow">https://app.roll20.net/forum/post/10005695/script-set-the-meta-toolbox</a> And I have plenty of examples of using ZF on the site I can point to, if necessary.