Conditional between/with 2 numbers?

Hello, again, investigate more about the conditionals. I wanted to experiment and know ..
Can you make a conditional that verifies 2 numbers?

for example, we have this value
Code:
$game_actors [1] .face_index = 1 (shows that the Index is equal to 1)

I want the conditional to work if it is between 2 numbers, like 5 to 10
or that works, if it is in a specific number like 10 and 20

Example:
Code:
@>Conditional Branch: $game_actors[1].face_index = (5 ~ 8)
      @>Execute Action if Index is between 5 and 8 (numbers like 5, 6, 7, 8)
      @>
@>Else
      @>Execute Action if Index is different than 5, 6, 7, 8
      @>
@>Branch End
and
Code:
@>Conditional Branch: $game_actors[1].face_index = (10 & 20)
      @>Execute Action if Index is in 10 or 20 (doesn't include number in between)
      @>
@>Else
      @>Execute Action if Index is different than 10 or 20 (doesn't include number in between)
      @>
@>Branch End

It should also be mentioned that random variables work in this way:

Example:
Code:
$game_variables[1] = rand(10)

so that the variable can have a random number.
and I think it would still be possible to verify a variable with 2 numbers.

well, would this be possible to verify 2 numbers in a conditional?
In Ruby, you have the equals symbol and the 'is equal to' symbol. One sets a variable and one checks if a variable is equal to X.
Code:
$game_actors[1].face_index = 1
The code above sets actor 1's face index to be 1.

Code:
$game_actors[1].face_index == 1
The code above checks if actor 1's face index is equal to 1.

There is a method in Ruby for integers called between? You can use it like so:
Code:
$game_actors[1].face_index.between?(5, 8)
It's a shorter way of writing:
Code:
$game_actors[1].face_index >= 5 && $game_actors[1].face_index <= 8

To check if a variable is either X or Y, you can do this:
Code:
$game_actors[1].face_index == 10 || $game_actors[1].face_index == 20
You could also do this, which is shorter:
Code:
[10, 20].include?($game_actors[1].face_index)
It basically makes an array of numbers and checks if any of them are equal to actor 1's face index.

You can view some more on Ruby operators here: https://www.tutorialspoint.com/ruby/ruby_operators.htm
There is a method in Ruby for integers called between? You can use it like so:

All these years I've been using the long method, not knowing such a thing exists... XD
There is a method in Ruby for integers called between? You can use it like so:
Code:
$game_actors[1].face_index.between?(5, 8)
Just to add something to this: the "between?" method is defined in the Comparable module. As such, it can be called on any instance of a class that includes the said module, even if it is not an Integer.

@Christopher Riel Talking about Ruby syntax, there is also a nice documentation inside RPG Maker VX Ace help file as well, you can simply press F1 and read it. It does not come with exercises to aid you in the learning process, but a good portion of the language is still included and properly explained.
@Heirukichi Yes, I have it a lot in mind, that it is a bit difficult for me to interpret Ruby syntax, because the documentation is in English, and let's say I still don't know the language well. But I try to learn little by little. Thanks anyway c:


@A-Moonless-Night Really thank you very much, it worked! 😀
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/conditional-between-with-2-numbers.114552/