Explaining what comes next in this post:
I would like to suggest the addition of a new function type called “Condition nest” in the extensions. It would provide a way to organize and structure conditions within an event sheet.
What is a condition nest:
A condition nest is a function type that allows users to insert multiple conditions inside it. It functions similarly to the existing AND, OR, and NOT statements.
How would it work:
Its actually very simple, there are only two key features that the extension creator can utilize when working with condition nests:
-
An expression to retrieve the amount of conditions contained within the nest (It will threat AND, OR, and NOT statements as a single condition regardless of the number of events they contain).
-
A condition that will allow the extension creator to check whether a specific nested condition has returned true.
Quick example of how would the sentence look like after inserting it to the event sheet: “The condition at order PARAM1 has returned true”.
Here are examples of how they would be useful:
-
Condition nests open the door to (easily) be able to achieve more specific combinations, such as “If A is true, and either B or C is true, but D is not true.” These kinds of conditions can be (are) challenging but not impossible to express with the current logic elements.
-
Normally, how would we check if either A and B are true but not both at the same time? That is quite simple:
If {
and [
(a = true) && (b = false)
]
and [
(a = false) && (b = true)
]
}
But what happens if C decides to enter the party? How would we check if a maximum of two conditions are true but never three at the same time?
-
Method:
If {
and [
(a = true) && (b = false) && (c = false)
]
and [
(a = true) && (b = true) && (c = false)
]
and [
(a = true) && (b = false) && (c = true)
]
and [
(a = false) && (b = true) && (c = false)
]
and [
(a = false) && (b = true) && (c = true)
]
and [
(a = false) && (b = false) && (c = true)
]
} -
Method:
If {
and [
(a = true)
If (
(b = false) && (c = false)
(b = true) && (c = false)
(b = false) && (c = true)
)
]
and [
(b = true)
If (
(a = false) && (c = false)
(a = false) && (c = true)
)
]
and [
(c = true) && (a = false) && (b = false)
]
}
As you can see, just by adding a new condition it increases the amount of nested statements a lot.
If we were able to create our own condition nests, the process would be something like this:
// This will reset the counting (explained in the next events):
[ no conditions | action: change the number of the scene variable nestedConditionsTrue set to 0 ]
[ no conditions | action: change the number of the scene variable nestedLoopCheck set to 0 ]
// This repeat loop will iterate through all the conditions and check if they are true:
[ Repeat GetNestedConditionsAmount() times] {
[ condition: The condition at order Variable(nestedLoopCheck) has returned true | action: change the number of the scene variable nestedConditionsTrue add 1 ]
[ no conditions | action: change the number of the scene variable nestedLoopCheck add 1 ]
}
// (Outside of the repeat loop) → Check if atleast one condition is true but not all of them:
[ conditions:
The scene variable nestedConditionsTrue > 0
The scene variable nestedConditionsTrue < GetNestedConditionsAmount()
action: Set return value of the condition to true ]
//End.
In summary, the new function “condition nests” would allow extension creators and regular users to create a more expressive event logic. This feature would greatly enhance the capabilities of the developers and improve the overall user experience.