Hasiva

Space Traveller
Member
Joined
Jun 20, 2019
Messages
4
Reaction score
1
First Language
polish
Primarily Uses
RMVXA
Hello.
It's probably a beginners' question, but can you make conditional branches with AND and OR operators in Ace? I specifically want to do some statements with switches, but a solution for normal variables would be appreciated too. I know you can make one condition after another for AND, but I believe there is probably more efficient solution, that's why I'm asking.

Sorry if this was asked before, I'm completly new to RPG Makers and this forum and I couldn't find the info about this anywhere.
 

Hasiva

Space Traveller
Member
Joined
Jun 20, 2019
Messages
4
Reaction score
1
First Language
polish
Primarily Uses
RMVXA
Thanks for the info!
 

Heirukichi

Regular
Regular
Joined
Sep 24, 2015
Messages
1,502
Reaction score
655
First Language
Italian
Primarily Uses
RMVXA
Actually, even without that script, there is a "Script" option in the conditional branch Event Command, you can use that to place a code to evaluate.
 

Shiro-chan

Friendly Neighbourhood Neppy Maid
Regular
Joined
Aug 7, 2018
Messages
199
Reaction score
64
First Language
German
Primarily Uses
RMVXA
Code:
$game_variables[x]>y or $game_switches[z]==true
$game_variables[x]>y and $game_switches[z]==true

Put things like this into the script option of your Conditional Branch.
 

Hasiva

Space Traveller
Member
Joined
Jun 20, 2019
Messages
4
Reaction score
1
First Language
polish
Primarily Uses
RMVXA
Code:
$game_variables[x]>y or $game_switches[z]==true
$game_variables[x]>y and $game_switches[z]==true

Put things like this into the script option of your Conditional Branch.

Thank you, that's even better!
I knew you could do this probably by scripting or something. Man, I must start learning Ruby as quick as possible.
 

Shiro-chan

Friendly Neighbourhood Neppy Maid
Regular
Joined
Aug 7, 2018
Messages
199
Reaction score
64
First Language
German
Primarily Uses
RMVXA
It helps to check the scriptcall collection threads. Problem is mainly that Conditional Branches have so many possibilities that they're not covered, so for those it's best to ask in the help thread.

Also note that I tried both "xor" and "nand" operators, and neither works (! for negative also does not btw), so you will have to be a tad clever with just "and" and "or".
 

Heirukichi

Regular
Regular
Joined
Sep 24, 2015
Messages
1,502
Reaction score
655
First Language
Italian
Primarily Uses
RMVXA
Code:
$game_variables[x]>y or $game_switches[z]==true
$game_variables[x]>y and $game_switches[z]==true
Just try to avoid using "and" or "or" and use "&&" or "||" respectively. Using and/or is bad coding etiquette.
On top of it, there is absolutely no need to compare a switch to a boolean value. Switches are boolean values by themselves.
Code:
($game_variables[x]>y) && $game_switches[z] # and
($game_variables[x]>y) || $game_switches[z] # or
This does the same thing while being shorter.
 
Last edited:

Hasiva

Space Traveller
Member
Joined
Jun 20, 2019
Messages
4
Reaction score
1
First Language
polish
Primarily Uses
RMVXA
[...]Just try to avoid using "and" or "or" and use "&&" or "||" respectively. Using and/or is bad coding etiquette. [...]
Oh, in ruby you can use || and &&?
No worries, I'll be using this notation from now on then! ("and" and "or" looked too SQLish for me anyway.:kaoswt2:)
 

Heirukichi

Regular
Regular
Joined
Sep 24, 2015
Messages
1,502
Reaction score
655
First Language
Italian
Primarily Uses
RMVXA
Oh, in ruby you can use || and &&?
That syntax is the same for any programming language that I have ever used (except for Fortran). The main difference about them in ruby is operator precedence: "&&" has higher priority compared to "and" (similarly for "||" and "or"). If you want to know more about this you can take a look at the help file (F1 in your engine), these things are under Ruby Syntax.

However, just to give you a rough idea, what happens is this:
Code:
a && b or a || b = (a && b) || (a || b)
 
Last edited:

Shiro-chan

Friendly Neighbourhood Neppy Maid
Regular
Joined
Aug 7, 2018
Messages
199
Reaction score
64
First Language
German
Primarily Uses
RMVXA
On top of it, there is absolutely no need to compare a switch to a boolean value. Switches are boolean values by themselves.
Code:
($game_variables[x]>y) && $game_switches[z] # and
($game_variables[x]>y) || $game_switches[z] # or
This does the same thing while being shorter.

So how do I short-write "switch is false" as the requirement?
 

Shiro-chan

Friendly Neighbourhood Neppy Maid
Regular
Joined
Aug 7, 2018
Messages
199
Reaction score
64
First Language
German
Primarily Uses
RMVXA
Nvm, it was clearly a typo.
 

Heirukichi

Regular
Regular
Joined
Sep 24, 2015
Messages
1,502
Reaction score
655
First Language
Italian
Primarily Uses
RMVXA
Code:
!($game_switches[x])
Well, using parenthesis does not bring any harm.

@Shiro-chan anyway, you should always be wary when writing in ruby. Ruby is easy to read, but sometimes it does nasty things.
Code:
puts(2+3) # -> 5
puts(2 + 3) # -> 5
puts(2+ 3) # -> if I am not wrong this is 5 as well
puts(2 +3) # -> ERROR
 
Last edited:

Shiro-chan

Friendly Neighbourhood Neppy Maid
Regular
Joined
Aug 7, 2018
Messages
199
Reaction score
64
First Language
German
Primarily Uses
RMVXA
Yeah, I noticed that when personalising some scripts. Anyway, looks like I'll have to do some improvements in various scriptcalls. Thanks again for the lessons.
 

Latest Threads

Latest Profile Posts

I've been thinking about doing a jokey submission for the Christmas jam in which, like a cartoon special where all the characters "play" a counterpart in A Christmas Carol, my MagiCats would each play a role from the C.A. Smith story The Coming of the White Worm, with Cyprian as Evagh, Rousalie as Dooni and so forth. But in the end, I figure all my development efforts should go toward the game proper.
In twitter, square phoenix had successfully prompted chatgpt to make the mini game watermelon pangpang.

drew some stuff to see how frontview might look. not entirely sold on or off of it yet. "could" work, but something feels missing.
Shower Thoughts: ". . . Scammers would be OP in the Elder Scrolls. They could just get speech 100 and blatantly ask everyone for all of their money, and everyone would think it's a great investment. And then after being robbed blind, they'd say, with a smile on their face, 'need something?' "
Day #2 for advent is compiled. Please, go to their threads to share love! But, if you wanna talk to me…what’s your favorite Christmas carol or holiday song?

Forum statistics

Threads
136,694
Messages
1,268,858
Members
180,408
Latest member
Asahina
Top