Efficient way to handle two different calls for different values of a same variable?

Davinel

Warper
Member
Joined
Apr 12, 2018
Messages
4
Reaction score
0
First Language
French
Primarily Uses
RMVXA
Is there an easy/short way to write the exact same event for multiple values of a variable, without having to write it for each values separately?

Basically, I want to use the same call when the variable = 1,3,5,etc, and a different call when it = 2,4,6,etc.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
it depends on what exactly you want to do - and you didn't give any info on that.
It would help a lot if you describe what you want to do (ingame terms) instead of how you want to do it (programming method).

That said, you might try to search for a set of scripts called the "self-data suite", because self-variables might help you here.
 

Davinel

Warper
Member
Joined
Apr 12, 2018
Messages
4
Reaction score
0
First Language
French
Primarily Uses
RMVXA
It doesn't have any visible impact ingame. It's just a skeleton to implement future events related to those values. But that variable is interlinked with two other variables and switches, and it requires different calls for different values. For some values, though, the call is identical. Rather than writing these calls one by one for each values, I was wondering if there was a way to shorten it.

i.e:
if var = 1,3,5 do this, else if var = 2, 4 do that, else if var = 6,7 do that
rather than
if var = 1 do this, if var = 2 do that, if var = 3 do that, etc.

In other words. Is there a way to do a conditionnal that does something like this: @>Conditionnal branch: Variable [000N:Name] == [1,3,5]?
 

GuanyuMaker

Veteran
Veteran
Joined
Mar 9, 2015
Messages
63
Reaction score
74
First Language
Portuguese
Primarily Uses
RMMV
Use "or" in JS is "|| "for this. In your own example:

@>Conditionnal branch: Variable [000N:Name]==1|| Variable [000N:Name]==3|| Variable [000N:Name] == 5|| etc...
 

GuanyuMaker

Veteran
Veteran
Joined
Mar 9, 2015
Messages
63
Reaction score
74
First Language
Portuguese
Primarily Uses
RMMV
@GuanyuMaker Please note that this is for Ace which uses Ruby not JavaScript.
I keep doing this! Will pay more atention before posting anything. Said that it should work on ruby too as it is the same operator for both. Or make it easier to read using the operator "or" itself instead of "||". While they are a bit different(priority order) in ruby it works the same way for the case =)
 

Davinel

Warper
Member
Joined
Apr 12, 2018
Messages
4
Reaction score
0
First Language
French
Primarily Uses
RMVXA
How would I input that, then? I tried writing that in the script box on the Conditional pop-up but ended up with a Syntax error unexpected ':' expected ']'.
 

GuanyuMaker

Veteran
Veteran
Joined
Mar 9, 2015
Messages
63
Reaction score
74
First Language
Portuguese
Primarily Uses
RMMV
For scrpit conditonal should be:
"n" for your variable ID
1,3,5 are the values you want the condition to trigger

Code:
$game_variables[n] == 1 || $game_variables[n] == 3 || $game_variables[n] == 5 || etc
Remove "|| ETC" or put more numbers you want to use.
 
Last edited:

Rinobi

Veteran
Veteran
Joined
Mar 24, 2014
Messages
579
Reaction score
219
First Language
English
Primarily Uses
RMVXA
[1,3,5].include?($game_variables[n])

Use this in a conditional branch. (Script entry)
 

Davinel

Warper
Member
Joined
Apr 12, 2018
Messages
4
Reaction score
0
First Language
French
Primarily Uses
RMVXA
Thank you very much! This makes everything much easier.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,048
Messages
1,018,545
Members
137,834
Latest member
EverNoir
Top