Conditional actions in Vayl allow you to create logic-based behavior for your chatbot. These actions evaluate Python-style expressions, executing specific actions based on whether the condition evaluates to true
or false
.
Each conditional has three key components:
- Condition: A Python expression that determines the logical outcome (
true
orfalse
). - True Actions: A list of actions executed if the condition evaluates to
true
. - False Actions: A list of actions executed if the condition evaluates to
false
.
If working on an individual conditional (conditionals/conditional_name.yml)
:
condition: "<if-statement expression>"
true:
- <action_1> ; <arguments>
- <action_2> ; <arguments>
false:
- <action_3> ; <arguments>
If working on a nested conditional ("conditional_name" within conditionals/conditional_name.yml)
:
conditional_name:
condition: "<if-statement expression>"
true:
- <action_1> ; <arguments>
- <action_2> ; <arguments>
false:
- <action_3> ; <arguments>
condition: '[rnumber:10-30] > 50'
true:
- chat ; Number is higher!
false:
- chat ; Number is lower or equal to
- Condition:
[rnumber:10-30] > 50
checks if a random number between 10 and 30 is greater than 50. - True Actions: Sends the chat message:
"Number is higher!"
- False Actions: Sends the chat message:
"Number is lower or equal to"
condition: '[counter:health] < 20 and [text:status] == "paralysed"'
true:
- chat ; Player is on low health AND paralysed!
false: []
- Condition:
[counter:health] < 20 and [text:status] == "paralysed"
- Checks if the
health
counter is below 20 and thestatus
variable equals"paralysed"
.
- Checks if the
- True Actions: Sends the chat message:
"Player is on low health AND paralysed!"
- False Actions: No actions are taken.
You can use the following operators in your conditions:
- Comparison:
<
,>
,<=
,>=
,==
,!=
- Logical:
and
,or
,not
- Arithmetic:
+
,-
,*
,/
To trigger a conditional, you can now use either of the following formats:
conditional ; conditional_name
This format refers to a standalone file (e.g., conditionals/conditional_name.yml
) for evaluating the conditional.
conditional ; file_name:conditional_name
This format allows you to reference a specific conditional within a file (e.g., conditionals/file_name.yml
).
actions:
- conditional ; test
This triggers the test
conditional from the conditionals/test.yml
file.
actions:
- conditional ; healthcheck:low_health
This triggers the low_health
conditional from the conditionals/healthcheck.yml
file.
- Test Conditions: Ensure your conditions use valid Python syntax and reference existing tags, counters, or text variables.
- Organize Tags: Use descriptive names for variables and counters for better clarity.
- Simplify Logic: Avoid overly complex conditions to make debugging easier.
With conditional actions and tags, Vayl allows for dynamic and interactive functionality in your Twitch chat, tailored to your specific needs. Combine these features with other actions for a fully automated and intelligent chatbot.