How to create triggers based on multiple variable ranges?

I am trying to create unique dialogue when a variable is between two values.

For example, if variable A is between 10 ~ 20, I want certain dialogue to show up, but if the variable is between 1 ~ 9, I would like different dialogue to appear. I know there is a range option under 'Control Variables' but this is for a randomised option, which is not what I am looking for.

In a separate thread someone said to use this script : $gameVariables.value(x) >= y && $gameVariables.value(x) <= z However, this does not seem to work.

Any help would be greatly appreciated.
However, this does not seem to work.
it should work if done correctly, you'll have to show where and how you've used the script to help with finding the mistake you made.

That said, you can either use two nested conditional branches or multiple event pages to trigger different results if you have too much problems with scripts.

In your example you would make an event with three pages.
Give the first page condition A>= 1, the second page A>=10 and the third page A>=20

Then the first page will activate on A between 1 and 9, the second page on A between 10 and 19, and the last page on A being 20 or greater.


The nested conditional branches would check for the two boundaries, and the inner commands would only run if both checks are true. Although you could use the same sequence of increasing values to thes with one limit each, but that would require rather carefull ordering of the values.
This is how the script is formed:


$gameVariables.value(3) >= 0 && $gameVariables.value(3) <= 9


This is one example. The variable is number 0003 in the list. This is for an example where the variable is between 0 and 9.

Also, adding to what you've said, how would I create a nested conditional branch?
1) this still does not show where it is used - please make a screenshot of the event where you used it, the entire event including properties and not only the content.

2) nested conditional branch means the second conditional branch command is inside the first one, so that it only executes if the first conditional branch is true.
Code:
if $gameVariables.value(3) <= 9
text below 9
else
if $gameVariables.value(3) <= 20
text between 10 and 20
else
if $gameVariables.value(3) <= 30
text between 20 and 30
end
end
end

easy peasy 🙂 (conditional branch)
1) this still does not show where it is used - please make a screenshot of the event where you used it, the entire event including properties and not only the content.

2) nested conditional branch means the second conditional branch command is inside the first one, so that it only executes if the first conditional branch is true.
Untitled.png
Code:
if $gameVariables.value(3) <= 9
text below 9
else
if $gameVariables.value(3) <= 20
text between 10 and 20
else
if $gameVariables.value(3) <= 30
text between 20 and 30
end
end
end

easy peasy 🙂 (conditional branch)
Hello I tried that but when the variable got above 9, it gave me syntax errors. Not sure what I'm doing wrong
@Notchella
and how would you know that the event in the screenshot doesn't work?
In that screenshot you have two different branches with an identical text, so you'll never know which one is selected if that text is displayed.

please add another show text with "Variable 3 is \V[3] and the selected branch is between x and y"
(replacing the x and y with the numbers for that branch conditions).

only then you can determine what value is currently stored in the variable and what the event had done with that.
@Notchella
and how would you know that the event in the screenshot doesn't work?
In that screenshot you have two different branches with an identical text, so you'll never know which one is selected if that text is displayed.

please add another show text with "Variable 3 is \V[3] and the selected branch is between x and y"
(replacing the x and y with the numbers for that branch conditions).

only then you can determine what value is currently stored in the variable and what the event had done with that.
I seem to have had a large oversight with that- the script does seem to be working now, I just stupidly didn't change the text so it seemed to be repeating! Thank you very much!
also a condition like

if (something)
true
end
if (something2)
true
end

this loop over everything

if (something)
false
else
if (something2)
true
end
end

than the 2nd will be runned, so you have to nest it with "else if" branch.
or it keep continue over all conditions which you don't want.
sometimes it can work if its a fix number, if its in between, use if else,
check 1 value if its lower.

complex if var X < 10 and Y > 20 so everything in between is skipped 😉

Original thread: https://forums.rpgmakerweb.com/threads/how-to-create-triggers-based-on-multiple-variable-ranges.179629/