If I were to create a conditional branch, is there any way I would be able to make the conditions that if one variable is a certain amount above or below another variable, the conditional branch is triggered?
Question About Conditional Branches
RPG Maker MV SupportInput this script in a conditional branch:
$gameVariables.value(a) == ($gameVariables.value(b) + c)
a is the number of the variable you want to check.
b is the variable you want to compare it with.
c is the certain amount of change you want.
For example:
$gameVariables.value(1) == ($gameVariables.value(2) + 10)
If you have that script in the conditional, you are checking if the variable #1 is equal to variable #2 + 10.
If you want to change the amount of c frequently when use this:
$gameVariables.value(a) == ($gameVariables.value(b) + $gameVariables.value(c))
Were you can control each time the difference between the two variables, by changing the value of variable #c
$gameVariables.value(a) == ($gameVariables.value(b) + c)
a is the number of the variable you want to check.
b is the variable you want to compare it with.
c is the certain amount of change you want.
For example:
$gameVariables.value(1) == ($gameVariables.value(2) + 10)
If you have that script in the conditional, you are checking if the variable #1 is equal to variable #2 + 10.
If you want to change the amount of c frequently when use this:
$gameVariables.value(a) == ($gameVariables.value(b) + $gameVariables.value(c))
Were you can control each time the difference between the two variables, by changing the value of variable #c
make a temporary variable that is the given amount higher than the other one (control variable command) and then compare to this modified temporary variable
You could do something like this (similar to what Andar was saying)...

Variables used:
The first 4 steps in this event set the values for the variables you want to use for comparison. Next you compare if your value you're checking is greater than or equal to the value plus your range value (that would have been set elsewhere, or somewhere in this event - that is up to you). If it comes back true, you want to do the stuff that you planned on. Good place for a common event call. If it is false, you need to compare if it is less than or equal to your range value. If that's true, you need to do the stuff you planned on. Again, good place for a common event call as it will prevent duplication of event "code." If it's false, you can either do something in that case, or simply omit the Else here to have it do nothing at all.

Variables used:
- Test 1: This is the actual variable whose value you want to test.
- Range: This is the amount you want to check above and below the Test 1 variable.
- Test 1 + Range: This is the value of adding Range to Test 1 (first 2 steps in the event).
- Test 1 - Range: This is the value of subtracting Range from Test 1 (second 2 steps in the event).
The first 4 steps in this event set the values for the variables you want to use for comparison. Next you compare if your value you're checking is greater than or equal to the value plus your range value (that would have been set elsewhere, or somewhere in this event - that is up to you). If it comes back true, you want to do the stuff that you planned on. Good place for a common event call. If it is false, you need to compare if it is less than or equal to your range value. If that's true, you need to do the stuff you planned on. Again, good place for a common event call as it will prevent duplication of event "code." If it's false, you can either do something in that case, or simply omit the Else here to have it do nothing at all.
Thanks for all of the answers, I think I will use @KanaX's way because it seems the simplest. Once again, thanks for everyone's answers.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Original thread: https://forums.rpgmakerweb.com/threads/question-about-conditional-branches.67067/