Script call for conditional branch checking multiple conditions

JDevain

Veteran
Veteran
Joined
Oct 21, 2018
Messages
121
Reaction score
46
First Language
English
Primarily Uses
RMMV
I need to check two separate variables at the same time, like this:

if $gameVariables.value(25) = 0 AND $gameVariables.value(26) = 3
(do some stuff)
else
(change values for vars 25 and 26)
if $gameVariables.value(25) = 0 AND $gameVariables.value(26) = 3
(do some stuff)
else
etc.

I remember seeing something about it a long time ago, but I can't seem to find it now.

Thanks!
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
698
Reaction score
3,450
First Language
English
Primarily Uses
N/A
Use && instead of the word AND

Also use == to check for basic equality. Just a single = is for assignment.

e.g. your condition could be
$gameVariables.value(10) < 20 && $gameVariables.value(10) > 10

$gameVariables.value(12) == 15 && $gameVariables.value(2) <= 10
 
Last edited:

JDevain

Veteran
Veteran
Joined
Oct 21, 2018
Messages
121
Reaction score
46
First Language
English
Primarily Uses
RMMV
@standardplayer

Thanks. Now I realized that I don't really grasp how to just do a basic condition in script form. Following is a screenshot of a test event I set up. The idea is that you add 1 to a variable and keep getting the message "No" until the variable equals 3, and then you get a "Yes". I get the error message "Unexpected end of input".

forum_question.png

Obviously I don't know what I'm doing. The list of script calls here says that the format for conditions is:

if (code) { stuff } else { stuff }

but that's not working for me here.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
One Script command knows nothing about another Script command: they are entirely separate. To use the if (condition) {result1;} else {result2;} structure, you would have to have the whole thing in one Script command, i.e. everything in code. That's way overcomplicating things here, though. :kaoswt2:

Instead, you can use Conditional Branch > Script:
Code:
$gameVariables.value(43) === 3
This will evaluate the script to true or false, and use that to decide which branch of the Conditional Branch command to run. It'll look something like this in the editor:
Code:
◆If:Script:$gameVariables.value(25) === 0 && $gameVariables.value(26) === 3
  ◆Text:None, Window, Bottom
  :    :Everything is ready, let's go!
  ◆
:Else
  ◆Text:None, Window, Bottom
  :    :Not ready yet, return later.
  ◆
:End
(You can use == or === to check equality; there are obscure differences but those shouldn't make much difference in this context.)

Alternatively you can simply nest one Conditional Branch command inside another; can be a little messier but it means no need for scripting~ :kaothx:
 

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

Latest Threads

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,854
Messages
1,016,998
Members
137,562
Latest member
tamedeathman
Top